Bug 110181

Summary: btrfs-show(8) inconsistency: double dash
Product: File System Reporter: moviuro+kernel
Component: btrfsAssignee: Josef Bacik (josef)
Status: RESOLVED CODE_FIX    
Severity: enhancement CC: dsterba, moviuro+kernel
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: all Subsystem:
Regression: No Bisected commit-id:

Description moviuro+kernel 2015-12-30 22:20:02 UTC
The btrfs-show(8) command does not consider '--' to be the end of arguments.
For the sake of consistency and future enhancements, it should.

Behavior:
# btrfs subvolume show -- /
btrfs subvolume show: too many arguments
usage: btrfs subvolume show <subvol-path>

    Show more information of the subvolume

Expected Behavior:
# btrfs subvolume show -- /
/
        Name:                   root
        UUID:                   814a917c-c11f-eb4d-b7a4-94699bd37afb
        Parent UUID:            8d1737f8-2e1f-4047-9300-1b87e02445c8
[...]

I can't write C code yet, so I can't help with enhancing the code directly and sending patches.
Comment 1 David Sterba 2016-01-13 14:21:41 UTC
As the command does not take any parameters it does not parse the command line via getopt, which handles "--". Fix on the way.
Comment 2 David Sterba 2016-01-13 14:41:06 UTC
Patch in devel, will be released in 4.4.
Comment 3 David Sterba 2016-01-13 15:40:27 UTC
There are way more commands that do not understand "--". The code for that is simple and can be copied from https://github.com/kdave/btrfs-progs/commit/dc361b45aced1982485ced74cd80476811ff0fa3 if you'd like to do that. Search for all command callbacks (start with cmd_ in the cmds-*.c files) that do not use getopt.
Comment 4 moviuro+kernel 2016-01-13 16:36:15 UTC
Okay, I forked the repo and will come back to you in time.
Comment 5 David Sterba 2016-01-18 17:35:20 UTC
Fixed in 4.4.