diff options
author | jdp <jdp@FreeBSD.org> | 1998-07-09 03:57:26 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 1998-07-09 03:57:26 +0000 |
commit | eca7605ba4fa5895ad5ae3fd87d22b6e18c96185 (patch) | |
tree | 5aca1ae0bb5a1d1739f6a6412641d2eabb5ffdfa /sbin | |
parent | 8c57af43f0be6d4d032faa8e8fc0afeb53ef5f61 (diff) | |
download | FreeBSD-src-eca7605ba4fa5895ad5ae3fd87d22b6e18c96185.zip FreeBSD-src-eca7605ba4fa5895ad5ae3fd87d22b6e18c96185.tar.gz |
Fix a bug that prevented the restoration of hard links to files that
had the schg flag set. Reported by Matthew Thyer <thyerm@camtech.net.au>.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/restore/utilities.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sbin/restore/utilities.c b/sbin/restore/utilities.c index 3232b9b..265b596 100644 --- a/sbin/restore/utilities.c +++ b/sbin/restore/utilities.c @@ -218,11 +218,26 @@ linkit(existing, new, type) return (FAIL); } } else if (type == HARDLINK) { - if (!Nflag && link(existing, new) < 0) { - fprintf(stderr, - "warning: cannot create hard link %s->%s: %s\n", - new, existing, strerror(errno)); - return (FAIL); + int ret; + + if (!Nflag && (ret = link(existing, new)) < 0) { + struct stat s; + + /* + * Most likely, the schg flag is set. Clear the + * flags and try again. + */ + if (stat(existing, &s) == 0 && s.st_flags != 0 && + chflags(existing, 0) == 0) { + ret = link(existing, new); + chflags(existing, s.st_flags); + } + if (ret < 0) { + fprintf(stderr, "warning: cannot create " + "hard link %s->%s: %s\n", + new, existing, strerror(errno)); + return (FAIL); + } } } else { panic("linkit: unknown type %d\n", type); |