Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zfs get -p only outputs 3 columns if "clones" property is empty #11837

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Copyright 2017-2018 RackTop Systems.
* Copyright (c) 2019 Datto Inc.
* Copyright (c) 2019, loli10K <ezomori.nozomu@gmail.com>
* Copyright (c) 2021 Matt Fiddaman
*/

#include <ctype.h>
Expand Down Expand Up @@ -2385,7 +2386,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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,7 +73,8 @@ typeset all_props=("${zfs_props[@]}" \
"${zfs_props_os[@]}" \
"${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)
Expand Down Expand Up @@ -102,13 +104,17 @@ function check_return_value

if [[ $item == $p ]]; then
((found += 1))
cols=$(echo $line | awk '{print NF}')
break
fi
done < $TESTDIR/$TESTFILE0

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

Expand All @@ -123,6 +129,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#
# Copyright (c) 2016 by Delphix. All rights reserved.
# Copyright (c) 2021 Matt Fiddaman
#

. $STF_SUITE/include/libtest.shlib
Expand Down Expand Up @@ -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, clone, volume bookmark,
# and filesystem bookmark that were created for this test case.
#
function cleanup
{
Expand All @@ -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 && \
Expand Down