find: Fix -fstype with stacked mounts

If you stack two mounts on top of each other, e.g.

    # mount -t ext4 /dev/sdX /mnt
    # mount -t f2fs /dev/sdY /mnt

then read_fs_list() will return two entries for that mount point.  The
later one is the one with the correct type, since the later mount is on
top of the earlier one.
This commit is contained in:
Tavian Barnes
2025-04-10 09:52:26 -04:00
parent b94b5f0122
commit cd8790239f
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -53,7 +53,8 @@ pub fn get_file_system_type(path: &Path, cache: &RefCell<Option<Cache>>) -> URes
let fs_list = uucore::fsext::read_fs_list()?;
let result = fs_list
.into_iter()
.find(|fs| fs.dev_id == dev_id)
.filter(|fs| fs.dev_id == dev_id)
.next_back()
.map_or_else(String::new, |fs| fs.fs_type);
// cache the latest query if not a match before
+2 -1
View File
@@ -451,7 +451,8 @@ fn format_directive<'entry>(
uucore::fsext::read_fs_list().expect("Could not find the filesystem info");
fs_list
.into_iter()
.find(|fs| fs.dev_id == dev_id)
.filter(|fs| fs.dev_id == dev_id)
.next_back()
.map_or_else(String::new, |fs| fs.fs_type)
.into()
}