Skip to contentSkip to conversation

fstests: Fix duplicate CLI arguments in fssum

PATCH In review Arvind Raghavan 2 participants 2 messages Apr 30, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fstests: Fix duplicate CLI arguments in fssum

fssum currently has a duplicate '-x' flag, which is used for both excluding paths and including xattrs. As the former is the only one currently used in xfstests, this patch renames the latter to use '-t'.

---
 src/fssum.c | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)
src/fssum.c +25 -24
index a243839a..3d97a70b 100644
@@ -77,7 +77,7 @@ enum _flags {
 	NUM_FLAGS
 };
 
-const char flchar[] = "ugoamcdxes";
+const char flchar[] = "ugoamcdtes";
 char line[65536];
 
 int flags[NUM_FLAGS] = {1, 1, 1, 1, 1, 0, 1, 1, 0, 0};
@@ -131,28 +131,27 @@ usage(void)
 {
 	fprintf(stderr, "usage: fssum <options> <path>\n");
 	fprintf(stderr, "  options:\n");
-	fprintf(stderr, "    -f          : write out a full manifest file\n");
-	fprintf(stderr, "    -w <file>   : send output to file\n");
-	fprintf(stderr, "    -v          : verbose mode (debugging only)\n");
-	fprintf(stderr,
-		"    -r <file>   : read checksum or manifest from file\n");
-	fprintf(stderr, "    -[ugoamcdxe]: specify which fields to include in checksum calculation.\n");
-	fprintf(stderr, "         u      : include uid\n");
-	fprintf(stderr, "         g      : include gid\n");
-	fprintf(stderr, "         o      : include mode\n");
-	fprintf(stderr, "         m      : include mtime\n");
-	fprintf(stderr, "         a      : include atime\n");
-	fprintf(stderr, "         c      : include ctime\n");
-	fprintf(stderr, "         d      : include file data\n");
-	fprintf(stderr, "         x      : include xattrs\n");
-	fprintf(stderr, "         e      : include open errors (aborts otherwise)\n");
-	fprintf(stderr, "         s      : include block structure (holes)\n");
-	fprintf(stderr, "    -[UGOAMCDXES]: exclude respective field from calculation\n");
-	fprintf(stderr, "    -n          : reset all flags\n");
-	fprintf(stderr, "    -N          : set all flags\n");
-	fprintf(stderr, "    -x path     : exclude path when building checksum (multiple ok)\n");
-	fprintf(stderr, "    -h          : this help\n\n");
-	fprintf(stderr, "The default field mask is ugoamCdES. If the checksum/manifest is read from a\n");
+	fprintf(stderr, "    -f           : write out a full manifest file\n");
+	fprintf(stderr, "    -w <file>    : send output to file\n");
+	fprintf(stderr, "    -v           : verbose mode (debugging only)\n");
+	fprintf(stderr, "    -r <file>    : read checksum or manifest from file\n");
+	fprintf(stderr, "    -[ugoamcdtes]: specify which fields to include in checksum calculation.\n");
+	fprintf(stderr, "         u       : include uid\n");
+	fprintf(stderr, "         g       : include gid\n");
+	fprintf(stderr, "         o       : include mode\n");
+	fprintf(stderr, "         m       : include mtime\n");
+	fprintf(stderr, "         a       : include atime\n");
+	fprintf(stderr, "         c       : include ctime\n");
+	fprintf(stderr, "         d       : include file data\n");
+	fprintf(stderr, "         t       : include xattrs\n");
+	fprintf(stderr, "         e       : include open errors (aborts otherwise)\n");
+	fprintf(stderr, "         s       : include block structure (holes)\n");
+	fprintf(stderr, "    -[UGOAMCDTES]: exclude respective field from calculation\n");
+	fprintf(stderr, "    -n           : reset all flags\n");
+	fprintf(stderr, "    -N           : set all flags\n");
+	fprintf(stderr, "    -x path      : exclude path when building checksum (multiple ok)\n");
+	fprintf(stderr, "    -h           : this help\n\n");
+	fprintf(stderr, "The default field mask is ugoamCdtES. If the checksum/manifest is read from a\n");
 	fprintf(stderr, "file, the mask is taken from there and the values given on the command line\n");
 	fprintf(stderr, "are ignored.\n");
 	exit(-1);
@@ -713,7 +712,7 @@ main(int argc, char *argv[])
 	int plen;
 	int elen;
 	int n_flags = 0;
-	const char *allopts = "heEfuUgGoOaAmMcCdDsSnNw:r:vx:";
+	const char *allopts = "heEfuUgGoOaAmMcCdDtTsSnNw:r:vx:";
 
 	out_fp = stdout;
 	while ((c = getopt(argc, argv, allopts)) != EOF) {
@@ -735,6 +734,8 @@ main(int argc, char *argv[])
 		case 'C':
 		case 'd':
 		case 'D':
+		case 'T':
+		case 't':
 		case 'e':
 		case 'E':
 		case 's':
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Arvind Raghavan

fssum currently has a duplicate '-x' flag, which is used for both excluding paths and including xattrs. As the former is the only one currently used in xfstests, this patch renames the latter to use '-t'.

Quoted 53 lines
---
 src/fssum.c | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)
src/fssum.c +11 -23
index a243839a..3d97a70b 100644
@@ -77,7 +77,7 @@ enum _flags {
        NUM_FLAGS
 };
 
-const char flchar[] = "ugoamcdxes";
+const char flchar[] = "ugoamcdtes";
 char line[65536];
 
 int flags[NUM_FLAGS] = {1, 1, 1, 1, 1, 0, 1, 1, 0, 0};
@@ -131,28 +131,27 @@ usage(void)
 {
        fprintf(stderr, "usage: fssum <options> <path>\n");
        fprintf(stderr, "  options:\n");
-       fprintf(stderr, "    -f          : write out a full manifest file\n");
-       fprintf(stderr, "    -w <file>   : send output to file\n");
-       fprintf(stderr, "    -v          : verbose mode (debugging only)\n");
-       fprintf(stderr,
-               "    -r <file>   : read checksum or manifest from file\n");
-       fprintf(stderr, "    -[ugoamcdxe]: specify which fields to include in checksum calculation.\n");
-       fprintf(stderr, "         u      : include uid\n");
-       fprintf(stderr, "         g      : include gid\n");
-       fprintf(stderr, "         o      : include mode\n");
-       fprintf(stderr, "         m      : include mtime\n");
-       fprintf(stderr, "         a      : include atime\n");
-       fprintf(stderr, "         c      : include ctime\n");
-       fprintf(stderr, "         d      : include file data\n");
-       fprintf(stderr, "         x      : include xattrs\n");
-       fprintf(stderr, "         e      : include open errors (aborts otherwise)\n");
-       fprintf(stderr, "         s      : include block structure (holes)\n");
-       fprintf(stderr, "    -[UGOAMCDXES]: exclude respective field from calculation\n");
-       fprintf(stderr, "    -n          : reset all flags\n");
-       fprintf(stderr, "    -N          : set all flags\n");
-       fprintf(stderr, "    -x path     : exclude path when building checksum (multiple ok)\n");
-       fprintf(stderr, "    -h          : this help\n\n");
-       fprintf(stderr, "The default field mask is ugoamCdES. If the checksum/manifest is read from a\n");
+       fprintf(stderr, "    -f           : write out a full manifest file\n");
+       fprintf(stderr, "    -w <file>    : send output to file\n");
+       fprintf(stderr, "    -v           : verbose mode (debugging only)\n");
+       fprintf(stderr, "    -r <file>    : read checksum or manifest from file\n");
+       fprintf(stderr, "    -[ugoamcdtes]: specify which fields to include in checksum calculation.\n");
+       fprintf(stderr, "         u       : include uid\n");
+       fprintf(stderr, "         g       : include gid\n");
+       fprintf(stderr, "         o       : include mode\n");
+       fprintf(stderr, "         m       : include mtime\n");
+       fprintf(stderr, "         a       : include atime\n");

src/fssum.c usage(void) · line 153

Quoted 10 lines
src/fssum.c +10 -0
+       fprintf(stderr, "         c       : include ctime\n");
+       fprintf(stderr, "         d       : include file data\n");
+       fprintf(stderr, "         t       : include xattrs\n");
+       fprintf(stderr, "         e       : include open errors (aborts otherwise)\n");
+       fprintf(stderr, "         s       : include block structure (holes)\n");
+       fprintf(stderr, "    -[UGOAMCDTES]: exclude respective field from calculation\n");
+       fprintf(stderr, "    -n           : reset all flags\n");
+       fprintf(stderr, "    -N           : set all flags\n");
+       fprintf(stderr, "    -x path      : exclude path when building checksum (multiple ok)\n");
+       fprintf(stderr, "    -h           : this help\n\n");

Changing whitespaces on unrelated lines clutters the diff from the actual changes.
I would fight the urge to do that or do it in a separate patch.

Thanks,
Amir.