There's a serious problem in the hardlink detection code in the new mkfs
protofile functionality that copies a directory tree into the new
filesystem. It's been long established that hardlinks can only be
detected by comparing st_ino *and* st_dev, but the new code doesn't do
that. Fix the detector.
Cc: <linux-xfs@vger.kernel.org> # v6.17.0
Fixes: 8a4ea72724930c ("proto: add ability to populate a filesystem from a directory")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
}
struct hardlink {
+ dev_t src_dev;
ino_t src_ino;
xfs_ino_t dst_ino;
};
size_t i = 0;
for (; i < hardlink_tracker.count; i++, h++) {
- if (h->src_ino == filestat->st_ino)
+ if (h->src_dev == filestat->st_dev &&
+ h->src_ino == filestat->st_ino)
return h->dst_ino;
}
return 0;
}
h = &hardlink_tracker.entries[hardlink_tracker.count];
+ h->src_dev = filestat->st_dev;
h->src_ino = filestat->st_ino;
h->dst_ino = dst_ino;
hardlink_tracker.count++;