mountpoint-util: do not assume symlinks are not mountpoints
authorMike Yuan <me@yhndnzj.com>
Wed, 26 Jun 2024 16:11:30 +0000 (18:11 +0200)
committerMike Yuan <me@yhndnzj.com>
Thu, 27 Jun 2024 12:57:16 +0000 (14:57 +0200)
They very much can be with the new mount API.

src/basic/mountpoint-util.c

index de15ac73ca319e1f716231dc56997880accd9aed..c3c245b259695627aec2351d82d0036af423322c 100644 (file)
@@ -231,8 +231,6 @@ int fd_is_mount_point(int fd, const char *filename, int flags) {
                 /* If statx() is not available or forbidden, fall back to name_to_handle_at() below */
         } else if (FLAGS_SET(sx.stx_attributes_mask, STATX_ATTR_MOUNT_ROOT)) /* yay! */
                 return FLAGS_SET(sx.stx_attributes, STATX_ATTR_MOUNT_ROOT);
-        else if (FLAGS_SET(sx.stx_mask, STATX_TYPE) && S_ISLNK(sx.stx_mode))
-                return false; /* symlinks are never mount points */
 
         r = name_to_handle_at_loop(fd, filename, &h, &mount_id, flags);
         if (r < 0) {
@@ -311,8 +309,6 @@ fallback_fstat:
                 flags |= AT_SYMLINK_NOFOLLOW;
         if (fstatat(fd, filename, &a, flags) < 0)
                 return -errno;
-        if (S_ISLNK(a.st_mode)) /* Symlinks are never mount points */
-                return false;
 
         if (isempty(filename))
                 r = fstatat(fd, "..", &b, 0);