diff options
author | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2013-03-28 15:30:00 +0100 |
---|---|---|
committer | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2013-03-28 15:30:37 +0100 |
commit | 50548d480eb847cb6a00774b55a37e69fa7f6ec4 (patch) | |
tree | 321b97de23d985b3521c4bd51482bf51238c3b1d | |
parent | 166a57e7a62c0dde6a46e6e961ebf7fb3b13d1c3 (diff) | |
download | far-progs-50548d480eb847cb6a00774b55a37e69fa7f6ec4.tar.gz |
fssum: verbose mode added (-v option)
-rw-r--r-- | fssum.c | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -66,6 +66,7 @@ int in_manifest = 0; char *checksum = NULL; struct excludes *excludes; int n_excludes = 0; +int verbose = 0; FILE *out_fp; FILE *in_fp; @@ -138,6 +139,7 @@ usage(void) 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, " -[ugoamcde] : specify which fields to include in checksum calculation.\n"); @@ -266,18 +268,29 @@ sum_file_data_permissive(int fd, sum_t *dst) if (i == ret) break; if (zeros) { + if (verbose >= 2) + fprintf(stderr, + "adding %llu zeros to sum\n", + (unsigned long long)zeros); sum_add_u64(dst, 0); sum_add_u64(dst, zeros); zeros = 0; } for (old = i; buf[i] != 0 && i < ret; ++i) ; + if (verbose >= 2) + fprintf(stderr, "adding %u non-zeros to sum\n", + i - (int)old); sum_add(dst, buf + old, i - old); } pos += ret; } if (zeros) { + if (verbose >= 2) + fprintf(stderr, + "adding %llu zeros to sum (finishing)\n", + (unsigned long long)zeros); sum_add_u64(dst, 0); sum_add_u64(dst, zeros); } @@ -303,6 +316,10 @@ sum_file_data_strict(int fd, sum_t *dst) assert(ret); /* eof found by lseek */ if (ret <= 0) return ret; + if (verbose >= 2) + fprintf(stderr, + "adding to sum at file offset %llu, %d bytes\n", + (unsigned long long)pos, ret); sum_add_u64(dst, (uint64_t)pos); sum_add(dst, buf, ret); pos += ret; @@ -553,6 +570,9 @@ sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in) } else if (S_ISREG(st.st_mode)) { sum_add_u64(&meta, st.st_size); if (flags[FLAG_DATA]) { + if (verbose) + fprintf(stderr, "file %s\n", + namelist[i]); fd = openat(dirfd, namelist[i], 0); if (fd == -1 && flags[FLAG_OPEN_ERROR]) { sum_add_u64(&meta, errno); @@ -629,7 +649,7 @@ main(int argc, char *argv[]) int plen; int elen; int n_flags = 0; - const char *allopts = "heEfuUgGoOaAmMcCdDsSnNw:r:x:"; + const char *allopts = "heEfuUgGoOaAmMcCdDsSnNw:r:vx:"; out_fp = stdout; while ((c = getopt(argc, argv, allopts)) != EOF) { @@ -695,6 +715,9 @@ main(int argc, char *argv[]) } excludes[n_excludes - 1].path = optarg; break; + case 'v': + ++verbose; + break; case 'h': case '?': usage(); |