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>.
This commit is contained in:
parent
4ec1acf055
commit
adb915cb28
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37523
@ -218,12 +218,27 @@ 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",
|
||||
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);
|
||||
return (FAIL);
|
||||
|
Loading…
Reference in New Issue
Block a user