]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hardlink: make it possible to compare paths
authorKarel Zak <kzak@redhat.com>
Thu, 17 Feb 2022 12:59:08 +0000 (13:59 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 17 Feb 2022 12:59:08 +0000 (13:59 +0100)
Addresses: https://github.com/util-linux/util-linux/issues/1602
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/hardlink.c

index ebb0aba722c129e3f501236036550b203a4c56dd..9320486227a2dedeb83485fddc939296e433bdf1 100644 (file)
@@ -1363,8 +1363,15 @@ int main(int argc, char *argv[])
 
        jlog(JLOG_VERBOSE2, _("Scanning [device/inode/links]:"));
        for (; optind < argc; optind++) {
-               if (nftw(argv[optind], inserter, 20, FTW_PHYS) == -1)
-                       warn(_("cannot process %s"), argv[optind]);
+               char *path = realpath(argv[optind], NULL);
+
+               if (!path) {
+                       warn(_("cannot get realpath: %s"), argv[optind]);
+                       continue;
+               }
+               if (nftw(path, inserter, 20, FTW_PHYS) == -1)
+                       warn(_("cannot process %s"), path);
+               free(path);
        }
 
        twalk(files, visitor);