Add support to background fsck to delete zero-length directories.
This commit is contained in:
parent
4f3a410a62
commit
a3bdf68993
@ -274,6 +274,7 @@ static int
|
||||
pass2check(struct inodesc *idesc)
|
||||
{
|
||||
struct direct *dirp = idesc->id_dirp;
|
||||
char dirname[MAXPATHLEN + 1];
|
||||
struct inoinfo *inp;
|
||||
int n, entrysize, ret = 0;
|
||||
union dinode *dp;
|
||||
@ -436,9 +437,37 @@ pass2check(struct inodesc *idesc)
|
||||
errmsg = "DUP/BAD";
|
||||
else if (!preen && !usedsoftdep)
|
||||
errmsg = "ZERO LENGTH DIRECTORY";
|
||||
else {
|
||||
else if (cursnapshot == 0) {
|
||||
n = 1;
|
||||
break;
|
||||
} else {
|
||||
getpathname(dirname, idesc->id_number,
|
||||
dirp->d_ino);
|
||||
pwarn("ZERO LENGTH DIRECTORY %s I=%d",
|
||||
dirname, dirp->d_ino);
|
||||
/*
|
||||
* We need to:
|
||||
* setcwd(idesc->id_parent);
|
||||
* rmdir(dirp->d_name);
|
||||
*/
|
||||
cmd.value = idesc->id_number;
|
||||
if (sysctlbyname("vfs.ffs.setcwd", 0, 0,
|
||||
&cmd, sizeof cmd) == -1) {
|
||||
/* kernel lacks support */
|
||||
printf(" (IGNORED)\n");
|
||||
n = 1;
|
||||
break;
|
||||
}
|
||||
if (rmdir(dirp->d_name) == -1) {
|
||||
printf(" (REMOVAL FAILED: %s)\n",
|
||||
strerror(errno));
|
||||
n = 1;
|
||||
break;
|
||||
}
|
||||
/* ".." reference to parent is removed */
|
||||
inoinfo(idesc->id_number)->ino_linkcnt--;
|
||||
printf(" (REMOVED)\n");
|
||||
break;
|
||||
}
|
||||
fileerror(idesc->id_number, dirp->d_ino, errmsg);
|
||||
if ((n = reply("REMOVE")) == 1)
|
||||
|
@ -97,6 +97,9 @@ pass4(void)
|
||||
break;
|
||||
|
||||
case DCLEAR:
|
||||
/* if on snapshot, already cleared */
|
||||
if (cursnapshot != 0)
|
||||
break;
|
||||
dp = ginode(inumber);
|
||||
if (DIP(dp, di_size) == 0) {
|
||||
clri(&idesc, "ZERO LENGTH", 1);
|
||||
|
Loading…
Reference in New Issue
Block a user