From c85756e50988acd79a5f1c907dd7d3fd0a3ee2b4 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 30 Apr 2020 23:02:22 +0200 Subject: [PATCH] fix(df): Linux: Fix the mount path and type --- src/uu/df/df.rs | 6 ++++-- tests/test_df.rs | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/uu/df/df.rs b/src/uu/df/df.rs index 6b7dfc0d9..732e48afb 100644 --- a/src/uu/df/df.rs +++ b/src/uu/df/df.rs @@ -356,11 +356,13 @@ impl MountInfo { #[cfg(target_os = "linux")] fn new(file_name: &str, raw: Vec<&str>) -> Option { match file_name { + // Format: 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue + // "man proc" for more details "/proc/self/mountinfo" => { let mut m = MountInfo { dev_id: "".to_string(), - dev_name: raw[8].to_string(), - fs_type: raw[7].to_string(), + dev_name: raw[9].to_string(), + fs_type: raw[8].to_string(), mount_root: raw[3].to_string(), mount_dir: raw[4].to_string(), mount_option: raw[5].to_string(), diff --git a/tests/test_df.rs b/tests/test_df.rs index e97a34b49..03903049a 100644 --- a/tests/test_df.rs +++ b/tests/test_df.rs @@ -6,4 +6,11 @@ fn test_df_compatible() { let result = ucmd.arg("-ah").run(); assert!(result.success); } + +#[test] +fn test_df_compatible_type() { + let (_, mut ucmd) = at_and_ucmd!(); + let result = ucmd.arg("-aT").run(); + assert!(result.success); +} // TODO