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 <boldin.pavel@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4440
This commit is contained in:
parent
726c4a2565
commit
88cfff1824
|
@ -2300,6 +2300,7 @@ us_compare(const void *larg, const void *rarg, void *unused)
|
||||||
case ZFS_PROP_NAME:
|
case ZFS_PROP_NAME:
|
||||||
propname = "name";
|
propname = "name";
|
||||||
if (numname) {
|
if (numname) {
|
||||||
|
compare_nums:
|
||||||
(void) nvlist_lookup_uint64(lnvl, propname,
|
(void) nvlist_lookup_uint64(lnvl, propname,
|
||||||
&lv64);
|
&lv64);
|
||||||
(void) nvlist_lookup_uint64(rnvl, propname,
|
(void) nvlist_lookup_uint64(rnvl, propname,
|
||||||
|
@ -2307,10 +2308,12 @@ us_compare(const void *larg, const void *rarg, void *unused)
|
||||||
if (rv64 != lv64)
|
if (rv64 != lv64)
|
||||||
rc = (rv64 < lv64) ? 1 : -1;
|
rc = (rv64 < lv64) ? 1 : -1;
|
||||||
} else {
|
} else {
|
||||||
(void) nvlist_lookup_string(lnvl, propname,
|
if ((nvlist_lookup_string(lnvl, propname,
|
||||||
&lvstr);
|
&lvstr) == ENOENT) ||
|
||||||
(void) nvlist_lookup_string(rnvl, propname,
|
(nvlist_lookup_string(rnvl, propname,
|
||||||
&rvstr);
|
&rvstr) == ENOENT)) {
|
||||||
|
goto compare_nums;
|
||||||
|
}
|
||||||
rc = strcmp(lvstr, rvstr);
|
rc = strcmp(lvstr, rvstr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue