From: Mike Yuan Date: Thu, 13 Mar 2025 15:09:55 +0000 (+0100) Subject: mountpoint-util: use get_proc_field() X-Git-Tag: v258-rc1~704^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1313fea9b54d3e2bae5fdc82e016d73a3371873;p=thirdparty%2Fsystemd.git mountpoint-util: use get_proc_field() --- 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); }