From: Mike Yuan Date: Mon, 11 Nov 2024 17:55:10 +0000 (+0100) Subject: mountpoint-util: our baseline includes fdinfo and mnt_id now X-Git-Tag: v258-rc1~1536^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e5a3127339915a7fd275d04b7fc633510fc91ff3;p=thirdparty%2Fsystemd.git mountpoint-util: our baseline includes fdinfo and mnt_id now --- diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index c112f8dbad5..be22d6a04f2 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -1113,8 +1113,6 @@ int fds_are_same_mount(int fd1, int fd2) { int mntid; r = path_get_mnt_id_at_fallback(fd1, "", &mntid); - if (ERRNO_IS_NEG_NOT_SUPPORTED(r)) - return true; /* skip the mount ID check */ if (r < 0) return r; assert(mntid >= 0); @@ -1127,8 +1125,6 @@ int fds_are_same_mount(int fd1, int fd2) { int mntid; r = path_get_mnt_id_at_fallback(fd2, "", &mntid); - if (ERRNO_IS_NEG_NOT_SUPPORTED(r)) - return true; /* skip the mount ID check */ if (r < 0) return r; assert(mntid >= 0); diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index f87e7342de5..b596d32680c 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -147,11 +147,10 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *ret_mn char path[STRLEN("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)]; _cleanup_free_ char *fdinfo = NULL; _cleanup_close_ int subfd = -EBADF; - char *p; int r; - assert(ret_mnt_id); assert((flags & ~(AT_SYMLINK_FOLLOW|AT_EMPTY_PATH)) == 0); + assert(ret_mnt_id); if ((flags & AT_EMPTY_PATH) && isempty(filename)) xsprintf(path, "/proc/self/fdinfo/%i", fd); @@ -164,16 +163,16 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *ret_mn } r = read_full_virtual_file(path, &fdinfo, NULL); - if (r == -ENOENT) /* The fdinfo directory is a relatively new addition */ - return proc_mounted() > 0 ? -EOPNOTSUPP : -ENOSYS; + if (r == -ENOENT) + return proc_fd_enoent_errno(); if (r < 0) return r; - p = find_line_startswith(fdinfo, "mnt_id:"); - if (!p) /* The mnt_id field is a relatively new addition */ - return -EOPNOTSUPP; + char *p = find_line_startswith(fdinfo, "mnt_id:"); + if (!p) + return -EBADMSG; - p += strspn(p, WHITESPACE); + p = skip_leading_chars(p, /* bad = */ NULL); p[strcspn(p, WHITESPACE)] = 0; return safe_atoi(p, ret_mnt_id);