]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
volinfo: accept -sizeonly for -sizeOnly
authorMichael Meffie <mmeffie@sinenomine.net>
Fri, 27 May 2011 22:17:44 +0000 (18:17 -0400)
committerStephan Wiesand <stephan.wiesand@desy.de>
Wed, 13 Aug 2014 18:17:29 +0000 (14:17 -0400)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 1a4262253e78aa7a4e8c58006abd3301f71bab89)

Change-Id: Ic630a7c0b29bd62525dd2211a7771c647e1be8df
Reviewed-on: http://gerrit.openafs.org/11258
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
doc/man-pages/pod8/volinfo.pod
src/vol/vol-info.c

index 0e4bbe81b50bd4c56526551a53f0a8df952b988d..7cb62f15bb7fc206634a33b418838f8cfd6b7ce4 100644 (file)
@@ -9,7 +9,7 @@ volinfo - Produces detailed statistics about AFS volume headers
 
 B<volinfo> [B<-online>] [B<-vnode>] [B<-date>] [B<-inode>] [B<-itime>]
     S<<< [B<-part> <I<AFS partition name (default current partition)>>+] >>>
-    S<<< [B<-volumeid> <I<volume id>>+] >>> [B<-header>] [B<-sizeOnly>]
+    S<<< [B<-volumeid> <I<volume id>>+] >>> [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
index 822e449839daa0dd6a3e2d6946d56d35e7d35f28..1776a009fb8e23e06ecc98607a3ccfc2bc2fcb9d 100644 (file)
 
 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,