]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: (refactor) make the steps for new_file consistent
authorMasatake YAMATO <yamato@redhat.com>
Mon, 15 Jan 2024 17:50:23 +0000 (02:50 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 2 Feb 2024 19:27:50 +0000 (04:27 +0900)
In parse_maps_line of the original code, we called readlink after stat
for gathering arguments that were passed to new_file().

The order was different from that in collect_file_symlink.
In parse_maps_line, we called stat after readlink.

The difference of the order may make the way of handling
errors of readlink and stat complicated.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.c

index 63a59f200b534c439553bfa20d1f0c7796d7bc8d..b4162159c1f068a3cca247549e2582b1dc48e6d3 100644 (file)
@@ -926,10 +926,10 @@ static void parse_maps_line(struct path_cxt *pc, char *buf, struct proc *proc)
 
        try_map_files:
                snprintf(map_file, sizeof(map_file), "map_files/%"PRIx64"-%"PRIx64, start, end);
-               if (ul_path_stat(pc, &sb, 0, map_file) < 0)
-                       return;
                if (ul_path_readlink(pc, sym, sizeof(sym), map_file) < 0)
                        return;
+               if (ul_path_stat(pc, &sb, 0, map_file) < 0)
+                       return;
                f = new_file(proc, stat2class(&sb), &sb, sym, -assoc);
        }