From d1313fea9b54d3e2bae5fdc82e016d73a3371873 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Thu, 13 Mar 2025 16:09:55 +0100 Subject: [PATCH] mountpoint-util: use get_proc_field() --- src/basic/mountpoint-util.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 6fc5e52a8e4..23653160a0f 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -141,7 +141,6 @@ int name_to_handle_at_try_fid( static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *ret_mnt_id) { char path[STRLEN("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)]; - _cleanup_free_ char *fdinfo = NULL; _cleanup_close_ int subfd = -EBADF; int r; @@ -158,19 +157,13 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *ret_mn xsprintf(path, "/proc/self/fdinfo/%i", subfd); } - r = read_full_virtual_file(path, &fdinfo, NULL); + _cleanup_free_ char *p = NULL; + r = get_proc_field(path, "mnt_id", &p); if (r == -ENOENT) - return proc_fd_enoent_errno(); + return -EBADF; if (r < 0) return r; - char *p = find_line_startswith(fdinfo, "mnt_id:"); - if (!p) - return -EBADMSG; - - p = skip_leading_chars(p, /* bad = */ NULL); - p[strcspn(p, WHITESPACE)] = 0; - return safe_atoi(p, ret_mnt_id); } -- 2.47.3