forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenZFS 8605 - zfs channel programs fix zfs.exists
Authored by: Chris Williamson <[email protected]> Reviewed by: Paul Dagnelie <[email protected]> Reviewed by: Dan Kimmel <[email protected]> Reviewed by: Matt Ahrens <[email protected]> Approved by: Robert Mustacchi <[email protected]> Ported-by: Don Brady <[email protected]> zfs.exists() in channel programs doesn't return any result, and should have a man page entry. This patch corrects zfs.exists so that it returns a value indicating if the dataset exists or not. It also adds documentation about it in the man page. OpenZFS-issue: https://www.illumos.org/issues/8605 OpenZFS-commit: openzfs/openzfs@1e85e111
- Loading branch information
1 parent
d99a015
commit 475eca4
Showing
6 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/ksh -p | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
|
||
# | ||
# Copyright (c) 2017 by Delphix. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib | ||
|
||
# | ||
# DESCRIPTION: | ||
# zfs.exists should accurately report whether a dataset exists, and | ||
# report an error if a dataset is in another pool. | ||
|
||
verify_runnable "global" | ||
|
||
# create $TESTSNAP and $TESTCLONE | ||
create_snapshot | ||
create_clone | ||
|
||
function cleanup | ||
{ | ||
datasetexists $TESTPOOL/$TESTFS@$TESTSNAP && \ | ||
log_must zfs destroy -R $TESTPOOL/$TESTFS@$TESTSNAP | ||
} | ||
|
||
log_must_program $TESTPOOL $ZCP_ROOT/lua_core/tst.exists.zcp \ | ||
$TESTPOOL $TESTPOOL/$TESTFS $TESTPOOL/$TESTFS@$TESTSNAP \ | ||
$TESTPOOL/$TESTCLONE | ||
|
||
log_mustnot_checkerr_program "not in the target pool" \ | ||
$TESTPOOL - <<-EOF | ||
return zfs.exists('rpool') | ||
EOF | ||
|
||
log_pass "zfs.exists() gives correct results" |
26 changes: 26 additions & 0 deletions
26
tests/zfs-tests/tests/functional/channel_program/lua_core/tst.exists.zcp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- | ||
-- This file and its contents are supplied under the terms of the | ||
-- Common Development and Distribution License ("CDDL"), version 1.0. | ||
-- You may only use this file in accordance with the terms of version | ||
-- 1.0 of the CDDL. | ||
-- | ||
-- A full copy of the text of the CDDL should have accompanied this | ||
-- source. A copy of the CDDL is also available via the Internet at | ||
-- http://www.illumos.org/license/CDDL. | ||
-- | ||
|
||
-- | ||
-- Copyright (c) 2017 by Delphix. All rights reserved. | ||
-- | ||
|
||
-- ensure zfs.exists works as expected. | ||
|
||
args = ... | ||
argv = args['argv'] | ||
pool = argv[1] | ||
|
||
for i = 1,4 do | ||
assert(zfs.exists(argv[i])) | ||
end | ||
|
||
assert(not zfs.exists(pool .. '/notadataset')) |