diff options
| author | John Polstra <jdp@FreeBSD.org> | 1998-07-09 03:57:26 +0000 |
|---|---|---|
| committer | John Polstra <jdp@FreeBSD.org> | 1998-07-09 03:57:26 +0000 |
| commit | adb915cb280cdc76d25ef1fcdef56caf79b49993 (patch) | |
| tree | 827067ff9141f515071bbe6e2b8abc4a1701d755 | |
| parent | 4ec1acf055e41e0e45420af2c7172464fbe8c03c (diff) | |
Notes
| -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 3232b9b2e9dd..265b596f8721 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); |
