Respect the enoent_ok flag if reporting error for holding an non-existing

snapshot.

Related illumos ZFS issue:
  3699 zfs hold or release of a non-existent snapshot does not output error

Reported by:	Steven Hartland <smh@FreeBSD.org>
MFC after:	3 days
This commit is contained in:
Martin Matuska 2013-04-25 06:55:57 +00:00
parent 5b1402e5e8
commit 7f168e5ddb

View File

@ -4207,10 +4207,13 @@ zfs_hold(zfs_handle_t *zhp, const char *snapname, const char *tag,
if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) {
fnvlist_free(ha.nvl);
ret = ENOENT;
(void) snprintf(errbuf, sizeof (errbuf),
dgettext(TEXT_DOMAIN, "cannot hold snapshot '%s@%s'"),
zhp->zfs_name, snapname);
(void) zfs_standard_error(hdl, ret, errbuf);
if (!enoent_ok) {
(void) snprintf(errbuf, sizeof (errbuf),
dgettext(TEXT_DOMAIN,
"cannot hold snapshot '%s@%s'"),
zhp->zfs_name, snapname);
(void) zfs_standard_error(hdl, ret, errbuf);
}
return (ret);
}