From a66fbaaf30e8d311c02f7602c9cf46dd7358839a Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 17 Feb 2022 13:59:08 +0100 Subject: [PATCH] hardlink: make it possible to compare paths Addresses: https://github.com/util-linux/util-linux/issues/1602 Signed-off-by: Karel Zak --- misc-utils/hardlink.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c index ebb0aba722..9320486227 100644 --- a/misc-utils/hardlink.c +++ b/misc-utils/hardlink.c @@ -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); -- 2.47.2