FSTests Archive on lore.kernel.org
 help / color / Atom feed
From: Arvind Raghavan <raghavan.arvind@gmail.com>
To: fstests <fstests@vger.kernel.org>, Amir Goldstein <amir73il@gmail.com>
Cc: Jayashree Mohan <jaya@cs.utexas.edu>,
	Vijay Chidambaram <vijay@cs.utexas.edu>,
	Arvind Raghavan <raghavan.arvind@gmail.com>
Subject: [PATCH 3/6] src/fssum: Add flag -R for non-recursive mode
Date: Wed, 20 May 2020 17:19:57 -0400
Message-ID: <eb38e3787260cdc7871eba58455edd57f1ba679b.1590006879.git.raghavan.arvind@gmail.com> (raw)
In-Reply-To: <cover.1590006879.git.raghavan.arvind@gmail.com>

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@gmail.com>
Signed-off-by: Jayashree Mohan <jaya@cs.utexas.edu>
Signed-off-by: Vijay Chidambaram <vijay@cs.utexas.edu>
---
 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


  parent reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 21:16 [PATCH 0/6] Changes to fssum to support POSIX Arvind Raghavan
2020-05-20 21:18 ` [PATCH 1/6] src/fssum: Make sum_file_data global Arvind Raghavan
2020-05-20 21:19 ` [PATCH 2/6] src/fssum: Refactor recursive traversal Arvind Raghavan
2020-05-20 21:19 ` Arvind Raghavan [this message]
2020-05-20 21:20 ` [PATCH 4/6] src/fssum: Add a flag for including file size in checksum Arvind Raghavan
2020-05-20 21:21 ` [PATCH 5/6] src/fssum: Allow single file input Arvind Raghavan
2020-05-21  9:18   ` Amir Goldstein
2020-05-22  1:06     ` Arvind Raghavan
2020-05-22  5:37       ` Amir Goldstein
2020-05-31 18:28         ` Arvind Raghavan
2020-05-31 19:31           ` Amir Goldstein
2020-05-20 21:21 ` [PATCH 6/6] src/fssum: Fix whitespace in usage Arvind Raghavan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb38e3787260cdc7871eba58455edd57f1ba679b.1590006879.git.raghavan.arvind@gmail.com \
    --to=raghavan.arvind@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=jaya@cs.utexas.edu \
    --cc=vijay@cs.utexas.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
		fstests@vger.kernel.org
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.fstests


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git