mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
df: add binfmt_misc to is_dummy_filesystem (#9975)
* df: add binfmt_misc to is_dummy_filesystem * df: add spell-checker ignore for binfmt * uucore: rmaix flag
This commit is contained in:
@@ -380,7 +380,7 @@ impl From<StatFs> for MountInfo {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(any(target_os = "aix", target_os = "redox"))))]
|
||||
#[cfg(all(unix, not(target_os = "redox")))]
|
||||
fn is_dummy_filesystem(fs_type: &str, mount_option: &str) -> bool {
|
||||
// spell-checker:disable
|
||||
match fs_type {
|
||||
@@ -392,7 +392,9 @@ fn is_dummy_filesystem(fs_type: &str, mount_option: &str) -> bool {
|
||||
// for NetBSD 3.0
|
||||
| "kernfs"
|
||||
// for Irix 6.5
|
||||
| "ignore" => true,
|
||||
| "ignore"
|
||||
// Binary format support pseudo-filesystem
|
||||
| "binfmt_misc" => true,
|
||||
_ => fs_type == "none"
|
||||
&& !mount_option.contains(MOUNT_OPT_BIND)
|
||||
}
|
||||
@@ -1220,4 +1222,12 @@ mod tests {
|
||||
crate::os_str_from_bytes(b"/mnt/some- -dir-\xf3").unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "redox")))]
|
||||
// spell-checker:ignore (word) binfmt
|
||||
fn test_binfmt_misc_is_dummy() {
|
||||
use super::is_dummy_filesystem;
|
||||
assert!(is_dummy_filesystem("binfmt_misc", ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore udev pcent iuse itotal iused ipcent
|
||||
// spell-checker:ignore udev pcent iuse itotal iused ipcent binfmt
|
||||
#![allow(
|
||||
clippy::similar_names,
|
||||
clippy::cast_possible_truncation,
|
||||
@@ -1046,3 +1046,48 @@ fn test_nonexistent_file() {
|
||||
.stderr_is("df: does-not-exist: No such file or directory\n")
|
||||
.stdout_is("File\n.\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_df_all_shows_binfmt_misc() {
|
||||
// Check if binfmt_misc is mounted
|
||||
let is_mounted = std::fs::read_to_string("/proc/self/mountinfo")
|
||||
.map(|content| content.lines().any(|line| line.contains("binfmt_misc")))
|
||||
.unwrap_or(false);
|
||||
|
||||
if is_mounted {
|
||||
let output = new_ucmd!()
|
||||
.args(&["--all", "--output=fstype,target"])
|
||||
.succeeds()
|
||||
.stdout_str_lossy();
|
||||
|
||||
assert!(
|
||||
output.contains("binfmt_misc"),
|
||||
"Expected binfmt_misc filesystem to appear in df --all output when it's mounted"
|
||||
);
|
||||
}
|
||||
// If binfmt_misc is not mounted, skip the test silently
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_df_hides_binfmt_misc_by_default() {
|
||||
// Check if binfmt_misc is mounted
|
||||
let is_mounted = std::fs::read_to_string("/proc/self/mountinfo")
|
||||
.map(|content| content.lines().any(|line| line.contains("binfmt_misc")))
|
||||
.unwrap_or(false);
|
||||
|
||||
if is_mounted {
|
||||
let output = new_ucmd!()
|
||||
.args(&["--output=fstype,target"])
|
||||
.succeeds()
|
||||
.stdout_str_lossy();
|
||||
|
||||
// binfmt_misc should NOT appear in the output without --all
|
||||
assert!(
|
||||
!output.contains("binfmt_misc"),
|
||||
"Expected binfmt_misc filesystem to be hidden in df output without --all"
|
||||
);
|
||||
}
|
||||
// If binfmt_misc is not mounted, skip the test silently
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user