linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io/attr.c: Disallow specifying both -D and -R options for chattr command
@ 2020-07-23  5:27 Xiao Yang
  2020-07-23  6:08 ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Xiao Yang @ 2020-07-23  5:27 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs, Xiao Yang

-D and -R options are mutually exclusive actually but chattr command
doesn't check it so that always applies -D option when both of them
are specified.  For example:
------------------------------------
# mkdir testdir
# mkdir testdir/tdir
# touch testdir/tfile
# xfs_io -c "chattr -D -R +s" testdir
# xfs_io -c "lsattr -R" testdir
----s----------- testdir/tdir
---------------- testdir/tfile
----s----------- testdir
------------------------------------

Add a check to disallow the combination.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 io/attr.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/io/attr.c b/io/attr.c
index 80e28514..f82a0881 100644
--- a/io/attr.c
+++ b/io/attr.c
@@ -320,6 +320,13 @@ chattr_f(
 		}
 	}
 
+	if (recurse_all && recurse_dir) {
+		fprintf(stderr, _("%s: -R and -D options are mutually exclusive\n"),
+			progname);
+		exitcode = 1;
+		return 0;
+	}
+
 	if (recurse_all || recurse_dir) {
 		nftw(name, chattr_callback,
 			100, FTW_PHYS | FTW_MOUNT | FTW_DEPTH);
-- 
2.21.0




^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-24  1:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23  5:27 [PATCH] io/attr.c: Disallow specifying both -D and -R options for chattr command Xiao Yang
2020-07-23  6:08 ` Christoph Hellwig
2020-07-23  6:39   ` Xiao Yang
2020-07-23 22:10     ` Dave Chinner
2020-07-23 22:15     ` Eric Sandeen
2020-07-24  1:09       ` Xiao Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).