@@ -76,13 +76,14 @@ enum _flags {
FLAG_XATTRS,
FLAG_OPEN_ERROR,
FLAG_STRUCTURE,
+ FLAG_SIZE,
NUM_FLAGS
};
-const char flchar[] = "ugoamcdtes";
+const char flchar[] = "ugoamcdtesz";
char line[65536];
-int flags[NUM_FLAGS] = {1, 1, 1, 1, 1, 0, 1, 1, 0, 0};
+int flags[NUM_FLAGS] = {1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1};
char *
getln(char *buf, int size, FILE *fp)
@@ -137,7 +138,7 @@ usage(void)
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, " -[ugoamcdtesz]: 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");
@@ -148,13 +149,14 @@ usage(void)
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, " z : include file size\n");
+ fprintf(stderr, " -[UGOAMCDTESZ]: 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, " -R : traverse dirs non-recursively (recursive is default)\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, "The default field mask is ugoamCdtESz. 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);
@@ -649,7 +651,8 @@ sum_one(int dirfd, int level, sum_t *dircs, char *path_prefix,
close(fd);
}
} else if (S_ISREG(st.st_mode)) {
- sum_add_u64(&meta, st.st_size);
+ if (flags[FLAG_SIZE])
+ sum_add_u64(&meta, st.st_size);
if (flags[FLAG_DATA]) {
if (verbose)
fprintf(stderr, "file %s\n",
@@ -730,7 +733,7 @@ main(int argc, char *argv[])
int plen;
int elen;
int n_flags = 0;
- const char *allopts = "heEfuUgGoOaAmMcCdDtTsSnNRw:r:vx:";
+ const char *allopts = "heEfuUgGoOaAmMcCdDtTsSzZnNRw:r:vx:";
out_fp = stdout;
while ((c = getopt(argc, argv, allopts)) != EOF) {
@@ -761,6 +764,8 @@ main(int argc, char *argv[])
case 'E':
case 's':
case 'S':
+ case 'z':
+ case 'Z':
++n_flags;
parse_flag(c);
break;