From 852fc815f832c4c9db34200de268c622077831a2 Mon Sep 17 00:00:00 2001 From: avg Date: Sun, 1 Oct 2017 16:51:05 +0000 Subject: [PATCH] MFV r323794: 8605 zfs channel programs: zfs.exists undocumented and non-working illumos/illumos-gate@5f39f884e2035d671ec02148fc4d8420c670bcb4 https://github.com/illumos/illumos-gate/commit/5f39f884e2035d671ec02148fc4d8420c670bcb4 https://www.illumos.org/issues/8605 zfs.exists() in channel programs doesn't return any result, and should have a man page entry. Reviewed by: Paul Dagnelie Reviewed by: Dan Kimmel Reviewed by: Matt Ahrens Approved by: Robert Mustacchi Author: Chris Williamson MFC after: 5 weeks X-MFC after: r324163 --- cddl/contrib/opensolaris/cmd/zfs/zfs-program.8 | 12 ++++++++++++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zcp.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs-program.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs-program.8 index 8b47d5f3aa4c..c6680978193f 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs-program.8 +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs-program.8 @@ -289,6 +289,18 @@ msg (string) .Bd -ragged -compact -offset "xxxx" Debug message to be printed. .Ed +.It Em zfs.exists(dataset) +Returns true if the given dataset exists, or false if it doesn't. +A fatal error will be thrown if the dataset is not in the target pool. +That is, in a channel program running on rpool, +zfs.exists("rpool/nonexistent_fs") returns false, but +zfs.exists("somepool/fs_that_may_exist") will error. +.Pp +dataset (string) +.Bd -ragged -compact -offset "xxxx" +Dataset to check for existence. +Must be in the target pool. +.Ed .It Em zfs.get_prop(dataset, property) Returns two values. First, a string, number or table containing the property value for the given diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zcp.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zcp.c index e0c39a819fbf..0d8e16fbee8f 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zcp.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zcp.c @@ -717,7 +717,7 @@ zcp_exists(lua_State *state) return (luaL_error(state, "unexpected error %d", error)); } - return (0); + return (1); } /*