From: Michael Meffie Date: Fri, 27 May 2011 22:17:44 +0000 (-0400) Subject: volinfo: accept -sizeonly for -sizeOnly X-Git-Tag: upstream/1.6.10_pre1^2~26 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=eed61c2f865757074b55ae6ccfb91f50d7715f0e;p=packages%2Fo%2Fopenafs.git volinfo: accept -sizeonly for -sizeOnly For consistency, allow -sizeonly (all lowercase letters) to request the size summary. The old option name, -sizeOnly is available as an alias. Define the command line option parameter positions and use those to set and look up the options. 1.6 note: The libcmd in 1.6 lacks parameter aliases and offsets. Instead we create params the normal way and make the offsets enum line up with the default offsets. To get an alias for -sizeonly, we create a new parameter that just does the same thing (P_SIZEONLY_COMPAT). Reviewed-on: http://gerrit.openafs.org/4741 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 1a4262253e78aa7a4e8c58006abd3301f71bab89) Change-Id: Ic630a7c0b29bd62525dd2211a7771c647e1be8df Reviewed-on: http://gerrit.openafs.org/11258 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- diff --git a/doc/man-pages/pod8/volinfo.pod b/doc/man-pages/pod8/volinfo.pod index 0e4bbe81b..7cb62f15b 100644 --- a/doc/man-pages/pod8/volinfo.pod +++ b/doc/man-pages/pod8/volinfo.pod @@ -9,7 +9,7 @@ volinfo - Produces detailed statistics about AFS volume headers B [B<-online>] [B<-vnode>] [B<-date>] [B<-inode>] [B<-itime>] S<<< [B<-part> >+] >>> - S<<< [B<-volumeid> >+] >>> [B<-header>] [B<-sizeOnly>] + S<<< [B<-volumeid> >+] >>> [B<-header>] [B<-sizeonly>] [B<-fixheader>] [B<-saveinodes>] [B<-orphaned>] [B<-filenames>] [B<-help>] =for html @@ -75,7 +75,7 @@ houses the volume. Displays statistics about the volume header of each volume, in addition to the default output. -=item B<-sizeOnly> +=item B<-sizeonly> Displays a single line of output for each volume, reporting the size of various structures associated with it. The default output is suppressed diff --git a/src/vol/vol-info.c b/src/vol/vol-info.c index 822e44983..1776a009f 100644 --- a/src/vol/vol-info.c +++ b/src/vol/vol-info.c @@ -72,6 +72,24 @@ static const char *progname = "volinfo"; +/* Command line options */ +typedef enum { + P_ONLINE, + P_VNODE, + P_DATE, + P_INODE, + P_ITIME, + P_PART, + P_VOLUMEID, + P_HEADER, + P_SIZEONLY, + P_SIZEONLY_COMPAT, + P_FIXHEADER, + P_SAVEINODES, + P_ORPHANED, + P_FILENAMES +} volinfo_parm_t; + /* Modes */ static int DumpInfo = 1; /**< Dump volume information, defualt mode*/ static int DumpHeader = 0; /**< Dump volume header files info */ @@ -437,45 +455,45 @@ handleit(struct cmd_syndesc *as, void *arock) } #endif - if (as->parms[0].items) { /* -online */ + if (as->parms[P_ONLINE].items) { fprintf(stderr, "%s: -online not supported\n", progname); return 1; } - if (as->parms[1].items) { /* -vnode */ + if (as->parms[P_VNODE].items) { DumpVnodes = 1; } - if (as->parms[2].items) { /* -date */ + if (as->parms[P_DATE].items) { DumpDate = 1; } - if (as->parms[3].items) { /* -inode */ + if (as->parms[P_INODE].items) { DumpInodeNumber = 1; } - if (as->parms[4].items) { /* -itime */ + if (as->parms[P_ITIME].items) { InodeTimes = 1; } - if ((ti = as->parms[5].items)) { /* -part */ + if ((ti = as->parms[P_PART].items)) { partNameOrId = ti->data; } - if ((ti = as->parms[6].items)) { /* -volumeid */ + if ((ti = as->parms[P_VOLUMEID].items)) { volumeId = strtoul(ti->data, NULL, 10); } - if (as->parms[7].items) { /* -header */ + if (as->parms[P_HEADER].items) { DumpHeader = 1; } - if (as->parms[8].items) { /* -sizeOnly */ + if (as->parms[P_SIZEONLY].items || as->parms[P_SIZEONLY_COMPAT].items) { ShowSizes = 1; } - if (as->parms[9].items) { /* -FixHeader */ + if (as->parms[P_FIXHEADER].items) { FixHeader = 1; } - if (as->parms[10].items) { /* -saveinodes */ + if (as->parms[P_SAVEINODES].items) { SaveInodes = 1; } - if (as->parms[11].items) { /* -orphaned */ + if (as->parms[P_ORPHANED].items) { ShowOrphaned = 1; } #if defined(AFS_NAMEI_ENV) - if (as->parms[12].items) { /* -filenames */ + if (as->parms[P_FILENAMES].items) { PrintFileNames = 1; } #endif @@ -854,6 +872,7 @@ HandleVolume(struct DiskPartition64 *dp, char *name) free(vp); } + /** * volinfo program entry */ @@ -878,8 +897,11 @@ main(int argc, char **argv) cmd_AddParm(ts, "-volumeid", CMD_LIST, CMD_OPTIONAL, "Volume id"); cmd_AddParm(ts, "-header", CMD_FLAG, CMD_OPTIONAL, "Dump volume's header info"); - cmd_AddParm(ts, "-sizeOnly", CMD_FLAG, CMD_OPTIONAL, + cmd_AddParm(ts, "-sizeonly", CMD_FLAG, CMD_OPTIONAL, "Dump volume's size"); + /* For compatibility with older versions. */ + cmd_AddParm(ts, "-sizeOnly", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, + "Alias for -sizeonly"); cmd_AddParm(ts, "-fixheader", CMD_FLAG, CMD_OPTIONAL, "Try to fix header"); cmd_AddParm(ts, "-saveinodes", CMD_FLAG, CMD_OPTIONAL,