Add quitclean command to fsdb(8) to request a filesystem not be marked dirty.

A new command, quitclean, is added to fsdb(8) to request that the
filesystem not be marked as needing a full fsck(8). This is useful
when creating deliberately bad filesystem images to be used to check
that fsck is properly able to clean them up.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
This commit is contained in:
Kirk McKusick 2023-07-25 19:42:41 -07:00
parent d51bdf327d
commit d059e44b80

View file

@ -163,6 +163,7 @@ CMDFUNC(uplink); /* incr link */
CMDFUNC(downlink); /* decr link */
CMDFUNC(linkcount); /* set link count */
CMDFUNC(quit); /* quit */
CMDFUNC(quitclean); /* quit with filesystem marked clean */
CMDFUNC(findblk); /* find block */
CMDFUNC(ls); /* list directory */
CMDFUNC(rm); /* remove name */
@ -217,6 +218,7 @@ struct cmdtable cmds[] = {
{ "ctime", "Change ctime of current inode to CTIME", 2, 2, FL_WR, chctime },
{ "atime", "Change atime of current inode to ATIME", 2, 2, FL_WR, chatime },
{ "chdb", "Change db pointer N of current inode to BLKNO", 3, 3, FL_CWR, chdb },
{ "quitclean", "Exit with filesystem marked clean", 1, 1, FL_RO, quitclean },
{ "quit", "Exit", 1, 1, FL_RO, quit },
{ "q", "Exit", 1, 1, FL_RO, quit },
{ "exit", "Exit", 1, 1, FL_RO, quit },
@ -402,6 +404,16 @@ CMDFUNCSTART(quit)
return -1;
}
CMDFUNCSTART(quitclean)
{
if (fscritmodified) {
printf("Warning: modified filesystem marked clean\n");
fscritmodified = 0;
sblock.fs_clean = 1;
}
return -1;
}
CMDFUNCSTART(uplink)
{
if (!checkactive())