]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix 'zfs list -t snapshot' depth
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 8 Apr 2019 16:14:45 +0000 (09:14 -0700)
committerGitHub <noreply@github.com>
Mon, 8 Apr 2019 16:14:45 +0000 (09:14 -0700)
Commit df583073 introduced the ability to list the snapshots for a
specified dataset.  This change inadvertently resulted in only the top-
level snapshots being listed when no dataset was specified.  Fix this
issue by adding an additional check to determine if a dataset was
provided to avoid incorrectly restricting the depth.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Alek Pinchuk <apinchuk@datto.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8591
Closes #8594

cmd/zfs/zfs_main.c

index 57eb305281d2bf807a0f2680e9af830188493460..5df20629333b7351adc061862d761608df7efe76 100644 (file)
@@ -1926,7 +1926,7 @@ zfs_do_get(int argc, char **argv)
         * Handle users who want to get all snapshots of the current
         * dataset (ex. 'zfs get -t snapshot refer <dataset>').
         */
-       if (types == ZFS_TYPE_SNAPSHOT &&
+       if (types == ZFS_TYPE_SNAPSHOT && argc > 1 &&
            (flags & ZFS_ITER_RECURSE) == 0 && limit == 0) {
                flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE);
                limit = 1;
@@ -3430,7 +3430,7 @@ zfs_do_list(int argc, char **argv)
         * Handle users who want to list all snapshots of the current
         * dataset (ex. 'zfs list -t snapshot <dataset>').
         */
-       if (types == ZFS_TYPE_SNAPSHOT &&
+       if (types == ZFS_TYPE_SNAPSHOT && argc > 0 &&
            (flags & ZFS_ITER_RECURSE) == 0 && limit == 0) {
                flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE);
                limit = 1;