diff --git a/libcitadel/src/mount.rs b/libcitadel/src/mount.rs index 8122d50..46b6642 100644 --- a/libcitadel/src/mount.rs +++ b/libcitadel/src/mount.rs @@ -15,12 +15,17 @@ impl Mount { /// Returns `true` if `path` matches the source field (first field) /// of any of the mount lines listed in /proc/mounts /// - pub fn is_path_mounted>(path: P) -> Result { + pub fn is_source_mounted>(path: P) -> Result { let path_str = path.as_ref().to_string_lossy(); let mounts = Mount::all_mounts()?; Ok(mounts.into_iter().any(|m| m.source == path_str)) } + pub fn is_target_mounted>(path: P) -> Result { + let mounts = Mount::all_mounts()?; + Ok(mounts.into_iter().any(|m| m.target == path.as_ref())) + } + pub fn all_mounts() -> Result> { let s = fs::read_to_string("/proc/mounts")?; Ok(s.lines().flat_map(Mount::parse_mount_line).collect())