[systemd-devel] [PATCH] path_is_mount_point: handle false positive on some fs
Didier Roche
didrocks at ubuntu.com
Mon Mar 9 03:27:09 PDT 2015
Hey,
path_is_mount_point() can report some false positive that a file is a
mount point on some file systems (like overlayfs).
The function tries to call name_to_handle_at(), if this one isn't
supported by the file system, then a fallback using stat() is triggered
on the entity (which can be a file). This compares the parent directory
and entity st_dev.
However, some file systems (seems overlayfs at least) would report a
major(st_dev) as 0 on directories and not on files. The current
path_is_mount_point() fallback logic would thus reports that every files
is a mount point. The enclosed patch introduces a second fallback to
read /proc/mounts, and ensures there is no shadowing by later mounting
of parent directories. This slower path is only used when the 2 first
methods failed to determine with assurance if the path is a mount point
or not.
Note that from what I heard, glib is going to use a similar mechanism.
Also we could on the longer term maybe getting the whole
path_is_mount_point() logic into libmount from util-linux, using
mnt_get_mountpoint() (but this one only use st_dev comparison presently)?
As usual, I'm opened on any modification on this patch.
Cheers,
Didier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-path_is_mount_point-handle-false-positive-on-some-fs.patch
Type: text/x-diff
Size: 3739 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150309/3acc880c/attachment.patch>
More information about the systemd-devel
mailing list