diff mbox

[3/4] btrfs-progs: Fix a regression that btrfs filesystem label doesn't work

Message ID 56E602AE.7080203@jp.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Satoru Takeuchi March 14, 2016, 12:15 a.m. UTC
The number of arguments which is allowed to pass became wrong
from the following commit.

commit 176aeca9a148c5e29de0 ("btrfs-progs: add getopt stubs where needed")

* actual result

  ===========================================================
  # ./btrfs prop get /btrfs label
  label=foo
  # ./btrfs fi label /btrfs
  btrfs filesystem label: too few arguments
  usage: btrfs filesystem label [<device>|<mount_point>] [<newlabel>]

      Get or change the label of a filesystem

      With one argument, get the label of filesystem on <device>.
      If <newlabel> is passed, set the filesystem label to <newlabel>.

  # ./btrfs fi label /btrfs bar
  foo
  # ./btrfs prop get /btrfs label
  label=foo
  ===========================================================

* expected result

  ===========================================================
  # ./btrfs prop get /btrfs label
  label=foo
  # ./btrfs fi label /btrfs
  foo
  # ./btrfs fi label /btrfs bar
  # ./btrfs prop get /btrfs label
  label=bar
  ===========================================================

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
 cmds-filesystem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

David Sterba March 14, 2016, 12:19 p.m. UTC | #1
On Mon, Mar 14, 2016 at 09:15:42AM +0900, Satoru Takeuchi wrote:
> The number of arguments which is allowed to pass became wrong
> from the following commit.
> 
> commit 176aeca9a148c5e29de0 ("btrfs-progs: add getopt stubs where needed")
> 
> * actual result
> 
>   ===========================================================
>   # ./btrfs prop get /btrfs label
>   label=foo
>   # ./btrfs fi label /btrfs
>   btrfs filesystem label: too few arguments
>   usage: btrfs filesystem label [<device>|<mount_point>] [<newlabel>]
> 
>       Get or change the label of a filesystem
> 
>       With one argument, get the label of filesystem on <device>.
>       If <newlabel> is passed, set the filesystem label to <newlabel>.
> 
>   # ./btrfs fi label /btrfs bar
>   foo
>   # ./btrfs prop get /btrfs label
>   label=foo
>   ===========================================================
> 
> * expected result
> 
>   ===========================================================
>   # ./btrfs prop get /btrfs label
>   label=foo
>   # ./btrfs fi label /btrfs
>   foo
>   # ./btrfs fi label /btrfs bar
>   # ./btrfs prop get /btrfs label
>   label=bar
>   ===========================================================
> 
> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 7e74e1b..45c16d2 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -1255,11 +1255,11 @@  static int cmd_filesystem_label(int argc, char **argv)
 {
 	clean_args_no_options(argc, argv, cmd_filesystem_label_usage);

-	if (check_argc_min(argc - optind, 2) ||
-			check_argc_max(argc - optind, 3))
+	if (check_argc_min(argc - optind, 1) ||
+			check_argc_max(argc - optind, 2))
 		usage(cmd_filesystem_label_usage);

-	if (argc - optind > 2) {
+	if (argc - optind > 1) {
 		return set_label(argv[optind], argv[optind + 1]);
 	} else {
 		char label[BTRFS_LABEL_SIZE];