Do not print UINT64_MAX value for some of zfs properties

The values of next properties: filesystem_limit, filesystem_count,
snapshot_limit, snapshot_count were returned to user as UINT64_MAX
integers in case if -p cli option is used, return 'none' value instead.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Fedor Uporov <fuporov.vstack@gmail.com>
Closes #9306 
Closes #12690
This commit is contained in:
Fedor Uporov 2021-10-29 16:18:13 -07:00 committed by GitHub
parent 1139e170d4
commit 475e41b9f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 9 deletions

View File

@ -2767,16 +2767,15 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
return (-1);
/*
* If limit is UINT64_MAX, we translate this into 'none' (unless
* literal is set), and indicate that it's the default value.
* Otherwise, we print the number nicely and indicate that it's
* set locally.
* If limit is UINT64_MAX, we translate this into 'none', and
* indicate that it's the default value. Otherwise, we print
* the number nicely and indicate that it's set locally.
*/
if (literal) {
if (val == UINT64_MAX) {
(void) strlcpy(propbuf, "none", proplen);
} else if (literal) {
(void) snprintf(propbuf, proplen, "%llu",
(u_longlong_t)val);
} else if (val == UINT64_MAX) {
(void) strlcpy(propbuf, "none", proplen);
} else {
zfs_nicenum(val, propbuf, proplen);
}

View File

@ -57,11 +57,14 @@ do
((i+=1))
done
typeset -r uint64_max="18446744073709551615"
typeset zfs_props=("type" used available creation volsize referenced \
compressratio mounted origin recordsize quota reservation mountpoint \
sharenfs checksum compression atime devices exec readonly setuid \
snapdir aclinherit canmount primarycache secondarycache version \
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots)
usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \
filesystem_limit snapshot_limit filesystem_count snapshot_count)
if is_freebsd; then
typeset zfs_props_os=(jailed aclmode)
else
@ -100,11 +103,21 @@ function check_return_value
while read line; do
typeset item
item=$(echo $line | awk '{print $2}' 2>&1)
typeset value
item=$(echo $line | awk '{print $2}' 2>&1)
if [[ $item == $p ]]; then
((found += 1))
cols=$(echo $line | awk '{print NF}')
fi
value=$(echo $line | awk '{print $3}' 2>&1)
if [[ $value == $uint64_max ]]; then
log_fail "'zfs get $opt $props $dst' return " \
"UINT64_MAX constant."
fi
if ((found > 0)); then
break
fi
done < $TESTDIR/$TESTFILE0