summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorPavel Boldin <[email protected]>2016-03-28 01:28:32 +0300
committerBrian Behlendorf <[email protected]>2016-03-30 12:39:21 -0700
commit88cfff182432e4d1c24c877f33b47ee6cf109eee (patch)
treead329613fada477c3e2a11ebe08239421b67e1fe /cmd
parent726c4a25659bfc0b3458da48a115dad67ddcb2ab (diff)
zfs_main: fix `zfs userspace` squashing unresolved entries
The `zfs userspace` squashes all entries with unresolved numeric values into a single output entry due to the comparsion always made by the string name which is empty in case of unresolved IDs. Fix this by falling to a numerical comparison when either one of string values is not found. This then compares any numerical values after all with a name resolved. Signed-off-by: Pavel Boldin <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #4440
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zfs/zfs_main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index ee413a541..579607451 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -2300,6 +2300,7 @@ us_compare(const void *larg, const void *rarg, void *unused)
case ZFS_PROP_NAME:
propname = "name";
if (numname) {
+compare_nums:
(void) nvlist_lookup_uint64(lnvl, propname,
&lv64);
(void) nvlist_lookup_uint64(rnvl, propname,
@@ -2307,10 +2308,12 @@ us_compare(const void *larg, const void *rarg, void *unused)
if (rv64 != lv64)
rc = (rv64 < lv64) ? 1 : -1;
} else {
- (void) nvlist_lookup_string(lnvl, propname,
- &lvstr);
- (void) nvlist_lookup_string(rnvl, propname,
- &rvstr);
+ if ((nvlist_lookup_string(lnvl, propname,
+ &lvstr) == ENOENT) ||
+ (nvlist_lookup_string(rnvl, propname,
+ &rvstr) == ENOENT)) {
+ goto compare_nums;
+ }
rc = strcmp(lvstr, rvstr);
}
break;