diff options
author | Alexander Hall <halex@cvs.openbsd.org> | 2021-09-01 18:16:53 +0000 |
---|---|---|
committer | Alexander Hall <halex@cvs.openbsd.org> | 2021-09-01 18:16:53 +0000 |
commit | 8d3f724f2d1e7155cf54fb2be9c9d2dd2f3085a2 (patch) | |
tree | bede65f64e6eb98b72e3f1316e09768f3033dbdd /usr.bin/diff | |
parent | ad0a623b68ebb274f4199542ad6a0afed2e5fa65 (diff) |
consider two files sharing the same inode identical
This gives a substantial speedup when comparing directory
structures with many hardlinked files, e.g. when using
rsnapshot for incremental backup.
ok stsp@ millert@
Diffstat (limited to 'usr.bin/diff')
-rw-r--r-- | usr.bin/diff/diffreg.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index e834fd4aae3..ae49b7f25a3 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.93 2019/06/28 13:35:00 deraadt Exp $ */ +/* $OpenBSD: diffreg.c,v 1.94 2021/09/01 18:16:52 halex Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -429,6 +429,10 @@ files_differ(FILE *f1, FILE *f2, int flags) if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != stb2.st_size || (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT)) return (1); + + if (stb1.st_dev == stb2.st_dev && stb1.st_ino == stb2.st_ino) + return (0); + for (;;) { i = fread(buf1, 1, sizeof(buf1), f1); j = fread(buf2, 1, sizeof(buf2), f2); |