diff options
author | Matt Fiddaman <illumos@m.fiddaman.uk> | 2021-03-28 21:32:03 +0000 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2021-04-08 16:54:42 -0400 |
commit | 99ea293e719ac006d413e4fde6ac0d5cd4dd6c59 (patch) | |
tree | 649b0b86ff7217e51bac28e8e3f7e6b42b3812d2 /usr/src | |
parent | c7b656fc7125adc5888ce934f1a3433da4b1bbc5 (diff) | |
download | illumos-joyent-99ea293e719ac006d413e4fde6ac0d5cd4dd6c59.tar.gz |
7668 zfs get only outputs 3 columns if "clones" property is empty
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src')
3 files changed, 22 insertions, 5 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_dataset.c b/usr/src/lib/libzfs/common/libzfs_dataset.c index 4e5ef6f292..49d4283d19 100644 --- a/usr/src/lib/libzfs/common/libzfs_dataset.c +++ b/usr/src/lib/libzfs/common/libzfs_dataset.c @@ -34,6 +34,7 @@ * Copyright 2018 Nexenta Systems, Inc. * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com> * Copyright 2017-2018 RackTop Systems. + * Copyright (c) 2021 Matt Fiddaman */ #include <ctype.h> @@ -2413,7 +2414,7 @@ get_clones_string(zfs_handle_t *zhp, char *propbuf, size_t proplen) nvpair_t *pair; value = zfs_get_clones_nvl(zhp); - if (value == NULL) + if (value == NULL || nvlist_empty(value)) return (-1); propbuf[0] = '\0'; diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh index 45f44be179..100556e077 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_001_pos.ksh @@ -27,6 +27,7 @@ # # Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2021 Matt Fiddaman # . $STF_SUITE/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib @@ -61,13 +62,14 @@ typeset zfs_props=("type" used available creation volsize referenced \ sharenfs checksum compression atime devices exec readonly setuid zoned \ snapdir aclmode aclinherit canmount primarycache secondarycache \ usedbychildren usedbydataset usedbyrefreservation usedbysnapshots \ - version) + version clones) typeset userquota_props=(userquota@root groupquota@root userused@root \ groupused@root) typeset all_props=("${zfs_props[@]}" "${userquota_props[@]}") typeset dataset=($TESTPOOL/$TESTCTR $TESTPOOL/$TESTFS $TESTPOOL/$TESTVOL \ - $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP) + $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTVOL@$TESTSNAP + $TESTPOOL/$TESTFS@$TESTSNAP1 $TESTPOOL/$TESTCLONE) typeset bookmark_props=(creation) typeset bookmark=($TESTPOOL/$TESTFS#$TESTBKMARK $TESTPOOL/$TESTVOL#$TESTBKMARK) @@ -97,6 +99,7 @@ function check_return_value if [[ $item == $p ]]; then ((found += 1)) + cols=$(echo $line | awk '{print NF}') break fi done < $TESTDIR/$TESTFILE0 @@ -104,6 +107,9 @@ function check_return_value if ((found == 0)); then log_fail "'zfs get $opt $props $dst' return " \ "error message.'$p' haven't been found." + elif [[ "$opt" == "-p" ]] && ((cols != 4)); then + log_fail "'zfs get $opt $props $dst' returned " \ + "$cols columns instead of 4." fi done @@ -118,6 +124,10 @@ log_onexit cleanup create_snapshot $TESTPOOL/$TESTFS $TESTSNAP create_snapshot $TESTPOOL/$TESTVOL $TESTSNAP +# Create second snapshot and clone it +create_snapshot $TESTPOOL/$TESTFS $TESTSNAP1 +create_clone $TESTPOOL/$TESTFS@$TESTSNAP1 $TESTPOOL/$TESTCLONE + # Create filesystem and volume's bookmark create_bookmark $TESTPOOL/$TESTFS $TESTSNAP $TESTBKMARK create_bookmark $TESTPOOL/$TESTVOL $TESTSNAP $TESTBKMARK diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib index d8cb9af028..d207431b36 100644 --- a/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib +++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zfs_get/zfs_get_common.kshlib @@ -26,6 +26,7 @@ # # Copyright (c) 2016 by Delphix. All rights reserved. +# Copyright (c) 2021 Matt Fiddaman # . $STF_SUITE/include/libtest.shlib @@ -87,8 +88,8 @@ function gen_option_str # $elements $prefix $separator $counter } # -# Cleanup the volume snapshot, filesystem snapshot, volume bookmark, and -# filesystem bookmark that were created for this test case. +# Cleanup the volume snapshot, filesystem snapshots, clones, volume bookmark, +# and filesystem bookmark that were created for this test case. # function cleanup { @@ -97,6 +98,11 @@ function cleanup datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \ destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP + datasetexists $TESTPOOL/$TESTCLONE && \ + destroy_clone $TESTPOOL/$TESTCLONE + datasetexists $TESTPOOL/$TESTFS@$TESTSNAP1 && \ + destroy_snapshot $TESTPOOL/$TESTFS@$TESTSNAP1 + bkmarkexists $TESTPOOL/$TESTVOL#$TESTBKMARK && \ destroy_bookmark $TESTPOOL/$TESTVOL#$TESTBKMARK bkmarkexists $TESTPOOL/$TESTFS#$TESTBKMARK && \ |