linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Xiao Yang <yangx.jy@cn.fujitsu.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	sandeen@sandeen.net, darrick.wong@oracle.com,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH] io/attr.c: Disallow specifying both -D and -R options for chattr command
Date: Fri, 24 Jul 2020 08:10:20 +1000	[thread overview]
Message-ID: <20200723221020.GG2005@dread.disaster.area> (raw)
In-Reply-To: <5F19308A.2060109@cn.fujitsu.com>

On Thu, Jul 23, 2020 at 02:39:06PM +0800, Xiao Yang wrote:
> On 2020/7/23 14:08, Christoph Hellwig wrote:
> > On Thu, Jul 23, 2020 at 01:27:23PM +0800, Xiao Yang wrote:
> > > -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:
> > Looks good,
> > 
> > Reviewed-by: Christoph Hellwig<hch@lst.de>
> Hi,
> 
> Ah,  I have a question after sending the patch:
> Other commands(e.g. cowextsize) including the same options seem to avoid the
> issue by accepting the last option, as below:
> --------------------------------------------------------
> io/cowextsize.c
> 141         while ((c = getopt(argc, argv, "DR")) != EOF) {
> 142                 switch (c) {
> 143                 case 'D':
> 144                         recurse_all = 0;
> 145                         recurse_dir = 1;
> 146                         break;
> 147                 case 'R':
> 148                         recurse_all = 1;
> 149                         recurse_dir = 0;
> 150                         break;
> 
> Test:
> # xfs_io -c "cowextsize -D -R" testdir
> [0] testdir/tdir
> [0] testdir/tfile
> [0] testdir
> [root@Fedora-31 ~]# xfs_io -c "cowextsize -R -D" testdir
> [0] testdir/tdir
> [0] testdir
> --------------------------------------------------------
> 
> Perhaps, we should use the same solution. (not sure) :-)

They should all operate the same way and, IMO, the order of the
parameters on the command line should not change the behaviour of
the command. Hence I think erroring out is better than what the
cowextsize code does above.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2020-07-23 22:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-07-23 22:15     ` Eric Sandeen
2020-07-24  1:09       ` Xiao Yang

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=20200723221020.GG2005@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    --cc=yangx.jy@cn.fujitsu.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).