diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-01-14 21:10:21 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-01-14 21:10:21 +0000 |
commit | 7f121358b3fd2d05447c7baf77745550da856f64 (patch) | |
tree | d0de86e7e052479db108d53d8e6ad10d089629a7 /sbin/growfs | |
parent | bc29e9e720e9ca8a392d1a5b7edfb0a1c9e68a3a (diff) |
Add a -q flag to reduce output a la newfs, and print the raw device we are
operating on instead of ``growfs'' (a la newfs as well).
ok millert@ pedro@
Diffstat (limited to 'sbin/growfs')
-rw-r--r-- | sbin/growfs/growfs.8 | 9 | ||||
-rw-r--r-- | sbin/growfs/growfs.c | 41 |
2 files changed, 33 insertions, 17 deletions
diff --git a/sbin/growfs/growfs.8 b/sbin/growfs/growfs.8 index 55d42c01022..5d3f2cb5dd1 100644 --- a/sbin/growfs/growfs.8 +++ b/sbin/growfs/growfs.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: growfs.8,v 1.6 2004/07/28 21:20:02 jmc Exp $ +.\" $OpenBSD: growfs.8,v 1.7 2006/01/14 21:10:20 miod Exp $ .\" Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz .\" Copyright (c) 1980, 1989, 1993 The Regents of the University of California. .\" All rights reserved. @@ -46,7 +46,7 @@ .Nd grow size of an existing ffs file system .Sh SYNOPSIS .Nm -.Op Fl Ny +.Op Fl Nqy .Op Fl s Ar size .Ar special .Sh DESCRIPTION @@ -83,6 +83,11 @@ The following options are available: Test mode. Causes the new file system parameters to be printed out without actually enlarging the file system. +.It Fl q +Operate in quiet mode. +With this option, +.Nm +will not print extraneous information like superblock backups. .It Fl s Ar size Determines the .Ar size diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c index e0b0c863cfb..534eff2506a 100644 --- a/sbin/growfs/growfs.c +++ b/sbin/growfs/growfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: growfs.c,v 1.13 2005/12/19 15:18:01 pedro Exp $ */ +/* $OpenBSD: growfs.c,v 1.14 2006/01/14 21:10:20 miod Exp $ */ /* * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. @@ -46,7 +46,7 @@ static const char copyright[] = Copyright (c) 1980, 1989, 1993 The Regents of the University of California.\n\ All rights reserved.\n"; -static const char rcsid[] = "$OpenBSD: growfs.c,v 1.13 2005/12/19 15:18:01 pedro Exp $"; +static const char rcsid[] = "$OpenBSD: growfs.c,v 1.14 2006/01/14 21:10:20 miod Exp $"; #endif /* not lint */ /* ********************************************************** INCLUDES ***** */ @@ -75,6 +75,8 @@ static const char rcsid[] = "$OpenBSD: growfs.c,v 1.13 2005/12/19 15:18:01 pedro int _dbg_lvl_ = (DL_INFO); /* DL_TRC */ #endif /* FS_DEBUG */ +int quiet = 0; /* quiet flag */ + static union { struct fs fs; char pad[SBSIZE]; @@ -124,7 +126,7 @@ struct gfs_bpp { }; /* ******************************************************** PROTOTYPES ***** */ -static void growfs(int, int, unsigned int); +static void growfs(char *, int, int, unsigned int); static void rdfs(daddr_t, size_t, void *, int); static void wtfs(daddr_t, size_t, void *, int, unsigned int); static daddr_t alloc(void); @@ -158,7 +160,7 @@ static void updrefs(int, ino_t, struct gfs_bpp *, int, int, unsigned int); * copies. */ static void -growfs(int fsi, int fso, unsigned int Nflag) +growfs(char *fsys, int fsi, int fso, unsigned int Nflag) { DBG_FUNC("growfs") int i; @@ -209,8 +211,8 @@ growfs(int fsi, int fso, unsigned int Nflag) /* * Dump out summary information about filesystem. */ - printf("growfs:\t%d sectors in %d %s of %d tracks, %d sectors\n", - sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, + printf("%s:\t%d sectors in %d %s of %d tracks, %d sectors\n", + fsys, sblock.fs_size * NSPF(&sblock), sblock.fs_ncyl, "cylinders", sblock.fs_ntrak, sblock.fs_nsect); #define B2MBFACTOR (1 / (1024.0 * 1024.0)) printf("\t%.1fMB in %d cyl groups (%d c/g, %.2fMB/g, %d i/g)\n", @@ -224,7 +226,8 @@ growfs(int fsi, int fso, unsigned int Nflag) * Now build the cylinders group blocks and * then print out indices of cylinder groups. */ - printf("superblock backups (for fsck -b #) at:\n"); + if (!quiet) + printf("superblock backups (for fsck -b #) at:\n"); i = 0; width = charsperline(); @@ -233,6 +236,8 @@ growfs(int fsi, int fso, unsigned int Nflag) */ for (cylno = osblock.fs_ncg; cylno < sblock.fs_ncg; cylno++) { initcg(cylno, utime, fso, Nflag); + if (quiet) + continue; j = snprintf(tmpbuf, sizeof tmpbuf, " %d%s", (int)fsbtodb(&sblock, cgsblock(&sblock, cylno)), cylno < (sblock.fs_ncg - 1) ? "," : ""); @@ -246,7 +251,8 @@ growfs(int fsi, int fso, unsigned int Nflag) printf("%s", tmpbuf); fflush(stdout); } - printf("\n"); + if (!quiet) + printf("\n"); /* * Do all needed changes in the first cylinder group. @@ -1868,11 +1874,14 @@ main(int argc, char **argv) DBG_ENTER; - while ((ch = getopt(argc, argv, "Ns:y")) != -1) { + while ((ch = getopt(argc, argv, "Nqs:y")) != -1) { switch (ch) { case 'N': Nflag = 1; break; + case 'q': + quiet = 1; + break; case 's': size = (size_t)atol(optarg); if (size < 1) { @@ -2002,7 +2011,8 @@ main(int argc, char **argv) } } - printf("new file system size is: %d frags\n", sblock.fs_size); + if (!quiet) + printf("new file system size is: %d frags\n", sblock.fs_size); /* * Try to access our new last block in the filesystem. Even if we @@ -2051,9 +2061,10 @@ main(int argc, char **argv) sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg; #endif sblock.fs_ncyl -= sblock.fs_ncyl % sblock.fs_cpg; - printf("Warning: %d sector(s) cannot be allocated.\n", - (sblock.fs_size-(sblock.fs_ncg)*sblock.fs_fpg) * - NSPF(&sblock)); + if (!quiet) + printf("Warning: %d sector(s) cannot be allocated.\n", + (sblock.fs_size-(sblock.fs_ncg)*sblock.fs_fpg) * + NSPF(&sblock)); sblock.fs_size = sblock.fs_ncyl * sblock.fs_spc / NSPF(&sblock); } @@ -2073,7 +2084,7 @@ main(int argc, char **argv) /* * Ok, everything prepared, so now let's do the tricks. */ - growfs(fsi, fso, Nflag); + growfs(rdev, fsi, fso, Nflag); /* * Update the disk label. @@ -2167,7 +2178,7 @@ usage(void) DBG_ENTER; - fprintf(stderr, "usage: growfs [-Ny] [-s size] special\n"); + fprintf(stderr, "usage: growfs [-Nqy] [-s size] special\n"); DBG_LEAVE; exit(1); |