dumpfs(8): add option to only print superblock information

Add an option to dumpfs, `-s`, that only prints the super block information.

Reviewed by:	chs, imp
Differential Revision:	https://reviews.freebsd.org/D30881
This commit is contained in:
Robert Wing 2021-07-02 14:18:17 -08:00
parent aa0ab681ae
commit dc35484536
2 changed files with 20 additions and 9 deletions

View File

@ -28,7 +28,7 @@
.\" @(#)dumpfs.8 8.1 (Berkeley) 6/5/93 .\" @(#)dumpfs.8 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd May 16, 2013 .Dd July 2, 2021
.Dt DUMPFS 8 .Dt DUMPFS 8
.Os .Os
.Sh NAME .Sh NAME
@ -39,6 +39,7 @@
.Op Fl f .Op Fl f
.Op Fl l .Op Fl l
.Op Fl m .Op Fl m
.Op Fl s
.Ar filesys | device .Ar filesys | device
.Sh DESCRIPTION .Sh DESCRIPTION
The The
@ -46,9 +47,10 @@ The
utility prints out the UFS super block and cylinder group information utility prints out the UFS super block and cylinder group information
for the file system or special device specified, unless the for the file system or special device specified, unless the
.Fl f , .Fl f ,
.Fl l .Fl l ,
.Fl m ,
or or
.Fl m .Fl s
flag is specified. flag is specified.
The listing is very long and detailed. The listing is very long and detailed.
This This
@ -97,6 +99,10 @@ The
.Fl r .Fl r
flag is needed if the filesystem uses flag is needed if the filesystem uses
.Xr gjournal 8 . .Xr gjournal 8 .
.Pp
If
.Fl s
is specified, only the super block information is printed.
.Sh SEE ALSO .Sh SEE ALSO
.Xr fs 5 , .Xr fs 5 ,
.Xr fsck 8 , .Xr fsck 8 ,

View File

@ -81,7 +81,7 @@ static const char rcsid[] =
static struct uufsd disk; static struct uufsd disk;
static int dumpfs(const char *); static int dumpfs(const char *, int);
static int dumpfsid(void); static int dumpfsid(void);
static int dumpcg(void); static int dumpcg(void);
static int dumpfreespace(const char *, int); static int dumpfreespace(const char *, int);
@ -96,11 +96,11 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
const char *name; const char *name;
int ch, dofreespace, domarshal, dolabel, eval; int ch, dofreespace, domarshal, dolabel, dosb, eval;
dofreespace = domarshal = dolabel = eval = 0; dofreespace = domarshal = dolabel = dosb = eval = 0;
while ((ch = getopt(argc, argv, "lfm")) != -1) { while ((ch = getopt(argc, argv, "lfms")) != -1) {
switch (ch) { switch (ch) {
case 'f': case 'f':
dofreespace++; dofreespace++;
@ -111,6 +111,9 @@ main(int argc, char *argv[])
case 'l': case 'l':
dolabel = 1; dolabel = 1;
break; break;
case 's':
dosb = 1;
break;
case '?': case '?':
default: default:
usage(); usage();
@ -139,7 +142,7 @@ main(int argc, char *argv[])
else if (dolabel) else if (dolabel)
eval |= dumpfsid(); eval |= dumpfsid();
else else
eval |= dumpfs(name); eval |= dumpfs(name, dosb);
ufs_disk_close(&disk); ufs_disk_close(&disk);
} }
exit(eval); exit(eval);
@ -154,7 +157,7 @@ dumpfsid(void)
} }
static int static int
dumpfs(const char *name) dumpfs(const char *name, int dosb)
{ {
time_t fstime, fsmtime; time_t fstime, fsmtime;
int64_t fssize; int64_t fssize;
@ -324,6 +327,8 @@ dumpfs(const char *name)
printf("blocks in last group %ld\n\n", printf("blocks in last group %ld\n\n",
(long)((fssize % afs.fs_fpg) / afs.fs_frag)); (long)((fssize % afs.fs_fpg) / afs.fs_frag));
} }
if (dosb)
return (0);
while ((i = cgread(&disk)) != 0) { while ((i = cgread(&disk)) != 0) {
if (i == -1 || dumpcg()) if (i == -1 || dumpcg())
goto err; goto err;