fix(utils): map verified Linux filesystem magic values (#3051)

This commit is contained in:
安正超
2026-05-22 10:37:50 +08:00
committed by GitHub
parent ed2078e025
commit 0d94437788
2 changed files with 25 additions and 2 deletions
+24 -1
View File
@@ -23,7 +23,6 @@
/// "61756673" => "AUFS",
/// "ef51" => "EXT2OLD",
/// "2fc12fc1" => "zfs",
/// "ff534d42" => "cifs",
/// "53464846" => "wslfs",
pub(crate) fn get_fs_type(fs_type: u64) -> &'static str {
// Magic numbers for various filesystems.
@@ -37,6 +36,16 @@ pub(crate) fn get_fs_type(fs_type: u64) -> &'static str {
0x52654973 => "REISERFS",
0x58465342 => "XFS",
0x9123683E => "BTRFS",
0x00c36400 => "CEPH",
0x2011BAB0 => "EXFAT",
0xE0F5E1E2 => "EROFS",
0xF2F52010 => "F2FS",
0x9660 => "ISOFS",
0x65735546 => "FUSE",
0x73717368 => "SQUASHFS",
0xFF534D42 => "CIFS",
0xFE534D42 => "SMB2",
0xca451a4e => "BCACHEFS",
_ => "UNKNOWN",
}
}
@@ -50,4 +59,18 @@ mod tests {
assert_eq!(get_fs_type(0x58465342), "XFS");
assert_eq!(get_fs_type(0x9123683E), "BTRFS");
}
#[test]
fn map_verified_linux_uapi_filesystem_magic_numbers() {
assert_eq!(get_fs_type(0x00c36400), "CEPH");
assert_eq!(get_fs_type(0x2011BAB0), "EXFAT");
assert_eq!(get_fs_type(0xE0F5E1E2), "EROFS");
assert_eq!(get_fs_type(0xF2F52010), "F2FS");
assert_eq!(get_fs_type(0x9660), "ISOFS");
assert_eq!(get_fs_type(0x65735546), "FUSE");
assert_eq!(get_fs_type(0x73717368), "SQUASHFS");
assert_eq!(get_fs_type(0xFF534D42), "CIFS");
assert_eq!(get_fs_type(0xFE534D42), "SMB2");
assert_eq!(get_fs_type(0xca451a4e), "BCACHEFS");
}
}
+1 -1
View File
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", test))]
mod fs_type;
#[cfg(target_os = "linux")]