Bug 474680 - KMountPoint::List::findByPath does not handle btrfs mounts
Summary: KMountPoint::List::findByPath does not handle btrfs mounts
Status: RESOLVED DUPLICATE of bug 395023
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-19 06:18 UTC by mike
Modified: 2023-11-01 14:45 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mike 2023-09-19 06:18:05 UTC
currently this method matches the mountpoint by comparing the st_dev returned by stat and comparing this to /proc/self/mountinfo

in the case of btrfs st_dev is used differently. Mainly st_dev is used to differentiate btrfs subvolumes. there is no matching entry in mountinfo.

the "btrfs" way would be stat upwards in the tree until a different st_dev is found (or you hit the root directory). This is the mountpoint (it will probably not be in mountinfo, but technically this is the filesystem (=subvolume) root)

Then there is the question about the mounted dev. Since btrfs in that regard is more like raid and lvm there is probably more than one device. The device list is in /sys/fs/btrfs/<fs uuid>/devices/
The device uuid is apparently read with a BTRFS_IOC_FS_INFO ioctl

If the filesystem is btrfs in the first place seems to be using a (deprecated?) statfs system call. There also exists statvfs, but that misses the f_type.

I would suggest the following:
in currentMountPoints check if the m_mountType == "btrfs" stat the root of that and use that st_dev, that way the simplest case will be matched in findByPath. It would be nice using the device list in /sys/fs.. instead of the one in mountinfo. If in findByPath there is no match we could at first just search the mount by "string comparing" (that would also be a generic way should another filesystem do the same), but imo the correct way would be search the fs root, add that to the list and return that element.
Comment 1 mike 2023-09-19 08:11:25 UTC
just some findings: zfs, the filesystem that would be comparable, does add matching st_dev entries in mountinfo. It also shows every subvolume there with a matching st_dev, so no special handling is required here.

The underlying device is obviously "missing" since it is, like with btrfs it would be 1..n devices. the "device" in mountinfo is more or less the same string as the mountpoint. Btrfs puts the device used when mounting the filesystem (that could be any of the devices that are part of that fs)
Comment 2 fanzhuyifan 2023-11-01 14:45:11 UTC
This seems a duplicate of 395023. Closing this so we could move all the discussion there.

*** This bug has been marked as a duplicate of bug 395023 ***