Skip to content

Commit cf4c62d

Browse files
authored
Merge pull request #159 from Lu-yq/fix-verify-path
cgroups-rs: fix verify_path() logic
2 parents 6a11b32 + c1a99ff commit cf4c62d

File tree

1 file changed

+0
-17
lines changed

1 file changed

+0
-17
lines changed

src/fs/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,10 @@ mod sealed {
164164
false
165165
}
166166

167-
fn verify_path(&self) -> Result<()> {
168-
if self.get_path().starts_with(self.get_base()) {
169-
Ok(())
170-
} else {
171-
Err(Error::new(ErrorKind::InvalidPath))
172-
}
173-
}
174-
175167
fn open_path(&self, p: &str, w: bool) -> Result<File> {
176168
let mut path = self.get_path().clone();
177169
path.push(p);
178170

179-
self.verify_path()?;
180-
181171
if w {
182172
match File::create(&path) {
183173
Err(e) => Err(Error::with_cause(
@@ -213,10 +203,6 @@ mod sealed {
213203

214204
#[doc(hidden)]
215205
fn path_exists(&self, p: &str) -> bool {
216-
if self.verify_path().is_err() {
217-
return false;
218-
}
219-
220206
std::path::Path::new(p).exists()
221207
}
222208
}
@@ -323,9 +309,6 @@ where
323309

324310
/// Create this controller
325311
fn create(&self) -> Result<()> {
326-
self.verify_path()
327-
.unwrap_or_else(|_| panic!("path should be valid: {:?}", self.path()));
328-
329312
std::fs::create_dir_all(self.get_path())
330313
.map_err(|err| Error::with_cause(ErrorKind::FsError, err))?;
331314
self.post_create();

0 commit comments

Comments
 (0)