G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT is False for /
G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT
is documented thus:
This attribute is TRUE if the file is a UNIX mount point.
man 5 fstab
says this:
The second field (fs_file).
This field describes the mount point (target) for the filesystem.
My /etc/fstab
contains, in part, these lines:
/dev/mapper/gelf-root / ext4 defaults,x-systemd.device-timeout=0 1 1
/dev/mapper/gelf-home /home ext4 defaults,x-systemd.device-timeout=0 1 2
I would therefore expect this attribute to be TRUE
for /
and /home
and FALSE
for /home/wjt
. However, it is FALSE
for /
:
In [15]: for path in ['/', '/home', '/home/wjt']:
...: f = Gio.File.new_for_path(path)
...: i = f.query_info('unix::is-mountpoint', 0, None)
...: print(path, i.get_attribute_boolean('unix::is-mountpoint'))
...:
/ False
/home True
/home/wjt False
This is because this attribute is actually defined to be true if the parent directory's st_dev
is different to the file's own:
if (stat_ok && parent_info && parent_info->device != 0 &&
_g_file_attribute_matcher_matches_id (attribute_matcher, G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT) &&
statbuf.st_dev != parent_info->device)
_g_file_info_set_attribute_boolean_by_id (info, G_FILE_ATTRIBUTE_ID_UNIX_IS_MOUNTPOINT, TRUE);
I think the behaviour at /
should at least be documented. The attribute could be made to behave how I expect by storing st_ino
in the GLocalParentFileInfo
and changing the above condition to statbuf.st_dev != parent_info->device || statbuf.st_ino == parent_info->inode
or similar. (A path is a mount point if its parent is on a different device, or if it is its own parent.) But changing this behaviour might have surprising consequences in the wild…