HomeFreeBSD

Make command line guid parsing more tolerant

Description

Make command line guid parsing more tolerant

Several of the zfs utilities allow you to pass a vdev's guid rather
than the device name. However, the utilities are not consistent in
how they parse that guid. For example, 'zinject' expects the guid
to be passed as a hex value while 'zpool replace' wants it as a
decimal. The user is forced to just know what format to use.

This patch improve things by making the parsing more tolerant.
When strtol(3) is called using 0 for the base, rather than say
10 or 16, it will then accept hex, decimal, or octal input based
on the prefix. From the man page.

If base is zero or 16, the string may then include a "0x"
prefix, and  the number  will  be read in base 16; otherwise,
a zero base is taken as 10 (decimal) unless the next character
is '0', in which case it  is  taken as 8 (octal).
NOTE: There may be additional conversions not caught be this patch.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chris Dunlap <cdunlap@llnl.gov>
Issue #2

Details

Provenance
Brian Behlendorf <behlendorf1@llnl.gov>Authored on Jan 24 2014, 11:27 PM
Parents
rG11a7043324b3: Add systemd unit file for zed
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG1a5c611a2281: Make command line guid parsing more tolerant (authored by Brian Behlendorf <behlendorf1@llnl.gov>).Apr 2 2014, 8:10 PM