Skip to content

Commit f4a69ad

Browse files
committed
df: add binfmt_misc to is_dummy_filesystem
1 parent 911bc15 commit f4a69ad

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/uucore/src/lib/features/fsext.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,9 @@ fn is_dummy_filesystem(fs_type: &str, mount_option: &str) -> bool {
392392
// for NetBSD 3.0
393393
| "kernfs"
394394
// for Irix 6.5
395-
| "ignore" => true,
395+
| "ignore"
396+
// Binary format support pseudo-filesystem
397+
| "binfmt_misc" => true,
396398
_ => fs_type == "none"
397399
&& !mount_option.contains(MOUNT_OPT_BIND)
398400
}
@@ -1220,4 +1222,11 @@ mod tests {
12201222
crate::os_str_from_bytes(b"/mnt/some- -dir-\xf3").unwrap()
12211223
);
12221224
}
1225+
1226+
#[test]
1227+
#[cfg(all(unix, not(any(target_os = "aix", target_os = "redox"))))]
1228+
fn test_binfmt_misc_is_dummy() {
1229+
use super::is_dummy_filesystem;
1230+
assert!(is_dummy_filesystem("binfmt_misc", ""));
1231+
}
12231232
}

tests/by-util/test_df.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,3 +1046,35 @@ fn test_nonexistent_file() {
10461046
.stderr_is("df: does-not-exist: No such file or directory\n")
10471047
.stdout_is("File\n.\n");
10481048
}
1049+
1050+
#[test]
1051+
#[cfg(target_os = "linux")]
1052+
fn test_df_all_shows_binfmt_misc() {
1053+
if std::path::Path::new("/proc/sys/fs/binfmt_misc").exists() {
1054+
let output = new_ucmd!()
1055+
.args(&["--all", "--output=fstype,target"])
1056+
.succeeds()
1057+
.stdout_str_lossy();
1058+
1059+
assert!(
1060+
output.contains("binfmt_misc"),
1061+
"Expected binfmt_misc filesystem to appear in df --all output"
1062+
);
1063+
}
1064+
}
1065+
1066+
#[test]
1067+
#[cfg(target_os = "linux")]
1068+
fn test_df_hides_binfmt_misc_by_default() {
1069+
if std::path::Path::new("/proc/sys/fs/binfmt_misc").exists() {
1070+
let output = new_ucmd!()
1071+
.args(&["--output=fstype,target"])
1072+
.succeeds()
1073+
.stdout_str_lossy();
1074+
1075+
assert!(
1076+
!output.contains("binfmt_misc"),
1077+
"Expected binfmt_misc filesystem to be hidden in df output without --all"
1078+
);
1079+
}
1080+
}

0 commit comments

Comments
 (0)