linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gene Czarcinski <gene@czarc.net>
To: linux-btrfs@vger.kernel.org
Cc: Wang Shilong <wangsl-fnst@cn.fujitsu.com>,
	Miao Xie <miaox@cn.fujitsu.com>, Gene Czarcinski <gene@czarc.net>
Subject: [PATCH 09/13] Btrfs-progs: fix arg parsing for btrfs qgroup limit commands
Date: Sun, 20 Jan 2013 16:04:14 -0500	[thread overview]
Message-ID: <1358715858-4469-10-git-send-email-gene@czarc.net> (raw)
In-Reply-To: <1358715858-4469-1-git-send-email-gene@czarc.net>

From: Wang Shilong <wangsl-fnst@cn.fujitsu.com>

We can use this command in two ways.
1. btrfs qgroup limit size qgroupid path
2. btrfs qgroup limit size path

Before applying this patch, we differentiate them by check the parsing result
of the second argument. It is not so good because it may make some mistakes,
For example:
  btrfs qgroup limit 1M 123456
 			^ It is a subvolume name.

In fact, we can differentiate them just by the number of arguments, so fix it
by this way.

Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Gene Czarcinski <gene@czarc.net>
---
 cmds-qgroup.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 1525c11..129a4f0 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -383,7 +383,6 @@ static int cmd_qgroup_limit(int argc, char **argv)
 	}
 
 	memset(&args, 0, sizeof(args));
-	args.qgroupid = parse_qgroupid(argv[optind + 1]);
 	if (size) {
 		if (compressed)
 			args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
@@ -397,9 +396,8 @@ static int cmd_qgroup_limit(int argc, char **argv)
 		}
 	}
 
-	if (args.qgroupid == 0) {
-		if (check_argc_exact(argc - optind, 2))
-			usage(cmd_qgroup_limit_usage);
+	if (argc - optind == 2) {
+		args.qgroupid = 0;
 		path = argv[optind + 1];
 		ret = test_issubvolume(path);
 		if (ret < 0) {
@@ -415,11 +413,11 @@ static int cmd_qgroup_limit(int argc, char **argv)
 		 * keep qgroupid at 0, this indicates that the subvolume the
 		 * fd refers to is to be limited
 		 */
-	} else {
-		if (check_argc_exact(argc - optind, 3))
-			usage(cmd_qgroup_limit_usage);
+	} else if (argc - optind == 3) {
+		args.qgroupid = parse_qgroupid(argv[optind + 1]);
 		path = argv[optind + 2];
-	}
+	} else
+		usage(cmd_qgroup_limit_usage);
 
 	fd = open_file_or_dir(path);
 	if (fd < 0) {
-- 
1.8.1


  parent reply	other threads:[~2013-01-20 21:04 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-20 21:04 [PATCH 00/13] Btrfs-progs: more patches for integration Gene Czarcinski
2013-01-20 21:04 ` [PATCH 01/13] btrfs-progs: btrfs-image.c: Added NULL pointer check Gene Czarcinski
2013-01-21 15:56   ` David Sterba
2013-01-22 17:34     ` Gene Czarcinski
2013-01-23 16:35       ` David Sterba
2013-01-23 18:16     ` Gene Czarcinski
2013-01-20 21:04 ` [PATCH 02/13] Btrfs-progs: fix resolving of loop devices Gene Czarcinski
2013-01-21 16:14   ` David Sterba
2013-01-22 17:50   ` David Sterba
2013-01-20 21:04 ` [PATCH 03/13] Btrfs-progs: correct btrfs receive usage string Gene Czarcinski
2013-01-20 21:04 ` [PATCH 04/13] Btrfs-progs: Fix a segmentation fault in btrfstune when <device> is invalid Gene Czarcinski
2013-01-20 21:04 ` [PATCH 05/13] Add btrfs-show-super Gene Czarcinski
2013-01-21 18:04   ` David Sterba
2013-01-21 19:54     ` Goffredo Baroncelli
2013-01-21 22:22       ` Stefan Behrens
2013-01-22 14:46         ` David Sterba
2013-01-20 21:04 ` [PATCH 06/13] btrfs-show-super.c Gene Czarcinski
2013-01-21 16:46   ` David Sterba
2013-01-22 18:00     ` Gene Czarcinski
2013-01-23 17:38       ` David Sterba
2013-01-22 20:51     ` [PATCH] Fix Makefile for gzip Gene Czarcinski
2013-01-22 20:51       ` [PATCH] fix btrfs-progs build Gene Czarcinski
2013-01-23 17:42         ` David Sterba
2013-01-20 21:04 ` [PATCH 07/13] Btrfs-progs: correcting misnamed parameter options for btrfs send Gene Czarcinski
2013-01-20 21:49   ` Gene Czarcinski
2013-01-20 23:59   ` [PATCH] " Gene Czarcinski
2013-01-20 21:04 ` [PATCH 08/13] Btrfs-progs: bugfix for subvolume parent determination in " Gene Czarcinski
2013-01-20 21:04 ` Gene Czarcinski [this message]
2013-01-20 21:04 ` [PATCH 10/13] Btrfs-progs: clean up reduplicate parse_qgroupid() and replace atoi with strtoull Gene Czarcinski
2013-01-20 21:04 ` [PATCH 11/13] Btrfs-progs: check the relation of two group by real level numbers Gene Czarcinski
2013-01-20 21:04 ` [PATCH 12/13] Btrfs-progs: disable qgroupid 0 for quota_tree Gene Czarcinski
2013-01-21 14:11   ` Gene Czarcinski
2013-01-20 21:04 ` [PATCH 13/13] trivial patch for btrfs-progs Gene Czarcinski
2013-01-21 17:40   ` David Sterba
2013-01-22 18:59     ` Gene Czarcinski
2013-01-21 18:40 ` [PATCH 00/13] Btrfs-progs: more patches for integration (integration-20130121) David Sterba
     [not found]   ` <CAMO4zugaABrbTJB75Yyi_UravfSX81YyqJtmc3yGALrby7+RTQ@mail.gmail.com>
2013-01-22 17:03     ` Fwd: " praneeth u
2013-01-22 18:09   ` Gene Czarcinski
2013-01-22 20:14   ` Gene Czarcinski
2013-01-24 18:13     ` David Sterba
2013-01-24 21:07       ` Gene Czarcinski

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=1358715858-4469-10-git-send-email-gene@czarc.net \
    --to=gene@czarc.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=miaox@cn.fujitsu.com \
    --cc=wangsl-fnst@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).