Fix 'zfs list -t snapshot' depth

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
This commit is contained in:
Brian Behlendorf 2019-04-08 09:14:45 -07:00 committed by GitHub
parent ac4985e48d
commit c375c69eca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1926,7 +1926,7 @@ zfs_do_get(int argc, char **argv)
* Handle users who want to get all snapshots of the current * Handle users who want to get all snapshots of the current
* dataset (ex. 'zfs get -t snapshot refer <dataset>'). * 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_RECURSE) == 0 && limit == 0) {
flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE); flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE);
limit = 1; limit = 1;
@ -3430,7 +3430,7 @@ zfs_do_list(int argc, char **argv)
* Handle users who want to list all snapshots of the current * Handle users who want to list all snapshots of the current
* dataset (ex. 'zfs list -t snapshot <dataset>'). * 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_RECURSE) == 0 && limit == 0) {
flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE); flags |= (ZFS_ITER_DEPTH_LIMIT | ZFS_ITER_RECURSE);
limit = 1; limit = 1;