Re: [PATCH] io/attr.c: Disallow specifying both -D and -R options for chattr command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
> 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@xxxxxxxxxxxxx



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux