Filesystem utilities that modify the filesystem (growfs(8), tunefs(8),
and fsirand(8)) should check the filesystem status and require that fsck(8) be run if it is unclean. This requirement is not imposed on fsdb(8) or clri(8) since they may be used to clean up a filesystem. MFC after: 2 weeks Sponsored by: Netflix
This commit is contained in:
parent
5ce3cee7e7
commit
bae4112fd3
@ -134,6 +134,12 @@ fsirand(char *device)
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Check for unclean filesystem.
|
||||
*/
|
||||
if (sblock->fs_clean == 0 ||
|
||||
(sblock->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) != 0)
|
||||
errx(1, "%s is not clean - run fsck.\n", device);
|
||||
|
||||
if (sblock->fs_magic == FS_UFS1_MAGIC &&
|
||||
sblock->fs_old_inodefmt < FS_44INODEFMT) {
|
||||
|
@ -1460,6 +1460,12 @@ main(int argc, char **argv)
|
||||
errc(1, ret, "unable to read superblock");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Check for unclean filesystem.
|
||||
*/
|
||||
if (fs->fs_clean == 0 ||
|
||||
(fs->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) != 0)
|
||||
errx(1, "%s is not clean - run fsck.\n", *argv);
|
||||
memcpy(&osblock, fs, fs->fs_sbsize);
|
||||
free(fs);
|
||||
memcpy((void *)&fsun1, (void *)&fsun2, osblock.fs_sbsize);
|
||||
|
@ -115,12 +115,12 @@ main(int argc, char *argv[])
|
||||
switch (ch) {
|
||||
|
||||
case 'A':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
Aflag++;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "POSIX.1e ACLs";
|
||||
avalue = optarg;
|
||||
if (strcmp(avalue, "enable") &&
|
||||
@ -132,7 +132,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "maximum blocks per file in a cylinder group";
|
||||
evalue = atoi(optarg);
|
||||
if (evalue < 1)
|
||||
@ -142,7 +142,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "average file size";
|
||||
fvalue = atoi(optarg);
|
||||
if (fvalue < 1)
|
||||
@ -152,7 +152,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'j':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "softdep journaled file system";
|
||||
jvalue = optarg;
|
||||
if (strcmp(jvalue, "enable") &&
|
||||
@ -164,7 +164,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "gjournaled file system";
|
||||
Jvalue = optarg;
|
||||
if (strcmp(Jvalue, "enable") &&
|
||||
@ -176,7 +176,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "space to hold for metadata blocks";
|
||||
kvalue = atoi(optarg);
|
||||
if (kvalue < 0)
|
||||
@ -185,7 +185,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "volume label";
|
||||
Lvalue = optarg;
|
||||
i = -1;
|
||||
@ -205,7 +205,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "multilabel MAC file system";
|
||||
lvalue = optarg;
|
||||
if (strcmp(lvalue, "enable") &&
|
||||
@ -217,7 +217,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "minimum percentage of free space";
|
||||
mvalue = atoi(optarg);
|
||||
if (mvalue < 0 || mvalue > 99)
|
||||
@ -226,7 +226,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "NFSv4 ACLs";
|
||||
Nvalue = optarg;
|
||||
if (strcmp(Nvalue, "enable") &&
|
||||
@ -238,7 +238,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "soft updates";
|
||||
nvalue = optarg;
|
||||
if (strcmp(nvalue, "enable") != 0 &&
|
||||
@ -250,7 +250,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "optimization preference";
|
||||
if (strcmp(optarg, "space") == 0)
|
||||
ovalue = FS_OPTSPACE;
|
||||
@ -264,12 +264,12 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
pflag = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "expected number of files per directory";
|
||||
svalue = atoi(optarg);
|
||||
if (svalue < 1)
|
||||
@ -279,7 +279,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "Softdep Journal Size";
|
||||
Svalue = atoi(optarg);
|
||||
if (Svalue < SUJ_MIN)
|
||||
@ -288,7 +288,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 't':
|
||||
found_arg = 1;
|
||||
found_arg++;
|
||||
name = "trim";
|
||||
tvalue = optarg;
|
||||
if (strcmp(tvalue, "enable") != 0 &&
|
||||
@ -310,6 +310,13 @@ main(int argc, char *argv[])
|
||||
on = special = argv[0];
|
||||
if (ufs_disk_fillout(&disk, special) == -1)
|
||||
goto err;
|
||||
/*
|
||||
* Check for unclean filesystem.
|
||||
*/
|
||||
if ((sblock.fs_clean == 0 ||
|
||||
(sblock.fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) != 0) &&
|
||||
(found_arg > 1 || !pflag))
|
||||
errx(1, "%s is not clean - run fsck.\n", special);
|
||||
if (disk.d_name != special) {
|
||||
if (statfs(special, &stfs) != 0)
|
||||
warn("Can't stat %s", special);
|
||||
|
Loading…
Reference in New Issue
Block a user