By default, fssum walks the input directory recursively. This patch adds a non-recursive mode which is useful because POSIX standards dictate that fsyncing a directory only guarantees its immediate dirents are synced. Signed-off-by: Arvind Raghavan <raghavan.arvind@xxxxxxxxx> Signed-off-by: Jayashree Mohan <jaya@xxxxxxxxxxxxx> Signed-off-by: Vijay Chidambaram <vijay@xxxxxxxxxxxxx> --- src/fssum.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fssum.c b/src/fssum.c index 81e5cf5d..018ad4a6 100644 --- a/src/fssum.c +++ b/src/fssum.c @@ -56,6 +56,7 @@ typedef int (*sum_file_data_t)(int fd, sum_t *dst); int gen_manifest = 0; int in_manifest = 0; +int recursive = 1; char *checksum = NULL; struct excludes *excludes; int n_excludes = 0; @@ -151,6 +152,7 @@ usage(void) 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, "file, the mask is taken from there and the values given on the command line\n"); @@ -634,7 +636,7 @@ sum_one(int dirfd, int level, sum_t *dircs, char *path_prefix, } } } - if (S_ISDIR(st.st_mode)) { + if (S_ISDIR(st.st_mode) && recursive) { fd = openat(dirfd, name, 0); if (fd == -1 && flags[FLAG_OPEN_ERROR]) { sum_add_u64(&meta, errno); @@ -728,7 +730,7 @@ main(int argc, char *argv[]) int plen; int elen; int n_flags = 0; - const char *allopts = "heEfuUgGoOaAmMcCdDtTsSnNw:r:vx:"; + const char *allopts = "heEfuUgGoOaAmMcCdDtTsSnNRw:r:vx:"; out_fp = stdout; while ((c = getopt(argc, argv, allopts)) != EOF) { @@ -736,6 +738,9 @@ main(int argc, char *argv[]) case 'f': gen_manifest = 1; break; + case 'R': + recursive = 0; + break; case 'u': case 'U': case 'g': -- 2.20.1