]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: (refactor) use ul_path_statf and ul_path_readlinkf
authorMasatake YAMATO <yamato@redhat.com>
Mon, 13 May 2024 16:43:42 +0000 (01:43 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 13 May 2024 16:43:42 +0000 (01:43 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
lsfd-cmd/file.c
lsfd-cmd/lsfd.c

index 02db8da5ee5b2f31b4ce9ec4e042b00b9ea62910..b4629fdc39abb8759d233eb40e0442b026658087 100644 (file)
@@ -591,7 +591,6 @@ static unsigned long get_minor_for_sysvipc(void)
 
        pid_t self = getpid();
        struct path_cxt *pc = NULL;
-       char map_file[sizeof("map_files/0000000000000000-ffffffffffffffff")];
 
        struct stat sb;
        unsigned long m = 0;
@@ -613,9 +612,8 @@ static unsigned long get_minor_for_sysvipc(void)
        if (procfs_process_init_path(pc, self) != 0)
                goto out;
 
-       snprintf(map_file, sizeof(map_file),
-                "map_files/%lx-%lx", (long)start, (long)start + pagesize);
-       if (ul_path_stat(pc, &sb, 0, map_file) < 0)
+       if (ul_path_statf(pc, &sb, 0, "map_files/%lx-%lx",
+                         (long)start, (long)start + pagesize) < 0)
                goto out;
 
        m = minor(sb.st_dev);
index cf52c4aae76c77663d7e18ad630d94aca2ad7adb..6c99dcd4b157d19c83eff10deb5c54f2361b530e 100644 (file)
@@ -968,14 +968,14 @@ static void parse_maps_line(struct path_cxt *pc, char *buf, struct proc *proc)
                f = new_file(proc, stat2class(&sb), &sb, path, -assoc);
        } else {
                /* As used in tcpdump, AF_PACKET socket can be mmap'ed. */
-               char map_file[sizeof("map_files/0000000000000000-ffffffffffffffff")];
                char sym[PATH_MAX] = { '\0' };
 
        try_map_files:
-               snprintf(map_file, sizeof(map_file), "map_files/%"PRIx64"-%"PRIx64, start, end);
-               if (ul_path_readlink(pc, sym, sizeof(sym), map_file) < 0)
+               if (ul_path_readlinkf(pc, sym, sizeof(sym),
+                                     "map_files/%"PRIx64"-%"PRIx64, start, end) < 0)
                        f = new_readlink_error_file(proc, errno, -assoc);
-               else if (ul_path_stat(pc, &sb, 0, map_file) < 0)
+               else if (ul_path_statf(pc, &sb, 0,
+                                      "map_files/%"PRIx64"-%"PRIx64, start, end) < 0)
                        f = new_stat_error_file(proc, sym, errno, -assoc);
                else
                        f = new_file(proc, stat2class(&sb), &sb, sym, -assoc);