mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
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,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);
|
||||
|
|
Loading…
Reference in a new issue