1
Fork 0
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:
Arcterus 2016-12-01 06:02:58 -08:00
parent dc6ba887ba
commit 5d9437bcaf

View file

@ -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 {