mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
chgrp: remove unwrap() in is_bind_root()
This commit is contained in:
parent
dc6ba887ba
commit
5d9437bcaf
1 changed files with 7 additions and 6 deletions
|
@ -219,17 +219,18 @@ impl Chgrper {
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn is_bind_root<P: AsRef<Path>>(&self, root: P) -> bool {
|
fn is_bind_root<P: AsRef<Path>>(&self, root: P) -> bool {
|
||||||
|
// TODO: is there an equivalent on Windows?
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn is_bind_root<P: AsRef<Path>>(&self, path: P) -> bool {
|
fn is_bind_root<P: AsRef<Path>>(&self, path: P) -> bool {
|
||||||
use std::os::unix::fs::MetadataExt;
|
if let (Ok(given), Ok(root)) = (fs::metadata(path), fs::metadata("/")) {
|
||||||
|
given.dev() == root.dev() && given.ino() == root.ino()
|
||||||
// FIXME: remove unwrap here
|
} else {
|
||||||
let given = std::fs::metadata(path).unwrap();
|
// FIXME: not totally sure if it's okay to just ignore an error here
|
||||||
let root = std::fs::metadata("/").unwrap();
|
false
|
||||||
given.dev() == root.dev() && given.ino() == root.ino()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn traverse<P: AsRef<Path>>(&self, root: P) -> i32 {
|
fn traverse<P: AsRef<Path>>(&self, root: P) -> i32 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue