summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris/lib/libzfs/common
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libzfs/common')
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h7
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c3
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c9
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c35
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c16
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c21
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c24
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c39
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c49
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c6
10 files changed, 116 insertions, 93 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
index 246449c..1b4b46c 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
@@ -28,6 +28,7 @@
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#ifndef _LIBZFS_H
@@ -326,7 +327,7 @@ typedef enum {
ZPOOL_STATUS_VERSION_OLDER, /* older legacy on-disk version */
ZPOOL_STATUS_FEAT_DISABLED, /* supported features are disabled */
ZPOOL_STATUS_RESILVERING, /* device being resilvered */
- ZPOOL_STATUS_OFFLINE_DEV, /* device online */
+ ZPOOL_STATUS_OFFLINE_DEV, /* device offline */
ZPOOL_STATUS_REMOVED_DEV, /* removed device */
ZPOOL_STATUS_NON_NATIVE_ASHIFT, /* (e.g. 512e dev with ashift of 9) */
@@ -800,10 +801,10 @@ extern boolean_t libzfs_fru_compare(libzfs_handle_t *, const char *,
extern boolean_t libzfs_fru_notself(libzfs_handle_t *, const char *);
extern int zpool_fru_set(zpool_handle_t *, uint64_t, const char *);
-#ifndef sun
+#ifndef illumos
extern int zmount(const char *, const char *, int, char *, char *, int, char *,
int);
-#endif /* !sun */
+#endif
#ifdef __cplusplus
}
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c
index 833e1b6..b9ecd9d 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_compat.c
@@ -74,6 +74,9 @@ zcmd_ioctl(int fd, int request, zfs_cmd_t *zc)
if (zfs_ioctl_version >= ZFS_IOCVER_DEADMAN) {
switch (zfs_ioctl_version) {
+ case ZFS_IOCVER_RESUME:
+ cflag = ZFS_CMD_COMPAT_RESUME;
+ break;
case ZFS_IOCVER_EDBP:
cflag = ZFS_CMD_COMPAT_EDBP;
break;
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c
index d5ba20f..2f332a8 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_config.c
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2015 by Syneto S.R.L. All rights reserved.
*/
/*
@@ -246,8 +247,9 @@ zpool_get_features(zpool_handle_t *zhp)
config = zpool_get_config(zhp, NULL);
}
- verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURE_STATS,
- &features) == 0);
+ if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURE_STATS,
+ &features) != 0)
+ return (NULL);
return (features);
}
@@ -316,8 +318,7 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
verify(nvlist_lookup_uint64(config,
ZPOOL_CONFIG_POOL_TXG, &newtxg) == 0);
- if (zhp->zpool_old_config != NULL)
- nvlist_free(zhp->zpool_old_config);
+ nvlist_free(zhp->zpool_old_config);
if (oldtxg != newtxg) {
nvlist_free(zhp->zpool_config);
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
index 44a9f00..dd09928 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
@@ -29,6 +29,7 @@
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <ctype.h>
@@ -1113,7 +1114,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
}
case ZFS_PROP_MLSLABEL:
{
-#ifdef sun
+#ifdef illumos
/*
* Verify the mlslabel string and convert to
* internal hex label string.
@@ -1162,11 +1163,11 @@ badlabel:
"invalid mlslabel '%s'"), strval);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
m_label_free(new_sl); /* OK if null */
-#else /* !sun */
+#else /* !illumos */
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"mlslabel is not supported on FreeBSD"));
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
-#endif /* !sun */
+#endif /* illumos */
goto error;
}
@@ -2057,8 +2058,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
zcmd_free_nvlists(&zc);
return (-1);
}
- if (zplprops)
- nvlist_free(zplprops);
+ nvlist_free(zplprops);
zcmd_free_nvlists(&zc);
break;
@@ -2504,7 +2504,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
case ZFS_PROP_MLSLABEL:
{
-#ifdef sun
+#ifdef illumos
m_label_t *new_sl = NULL;
char *ascii = NULL; /* human readable label */
@@ -2538,9 +2538,9 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
(void) strlcpy(propbuf, ascii, proplen);
free(ascii);
-#else /* !sun */
+#else /* !illumos */
propbuf[0] = '\0';
-#endif /* !sun */
+#endif /* illumos */
}
break;
@@ -2652,7 +2652,7 @@ static int
idmap_id_to_numeric_domain_rid(uid_t id, boolean_t isuser,
char **domainp, idmap_rid_t *ridp)
{
-#ifdef sun
+#ifdef illumos
idmap_get_handle_t *get_hdl = NULL;
idmap_stat status;
int err = EINVAL;
@@ -2677,10 +2677,10 @@ out:
if (get_hdl)
idmap_get_destroy(get_hdl);
return (err);
-#else /* !sun */
+#else /* !illumos */
assert(!"invalid code path");
return (EINVAL); // silence compiler warning
-#endif /* !sun */
+#endif /* illumos */
}
/*
@@ -2715,7 +2715,7 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
cp = strchr(propname, '@') + 1;
if (strchr(cp, '@')) {
-#ifdef sun
+#ifdef illumos
/*
* It's a SID name (eg "user@domain") that needs to be
* turned into S-1-domainID-RID.
@@ -2761,9 +2761,9 @@ userquota_propname_decode(const char *propname, boolean_t zoned,
cp = numericsid;
*ridp = rid;
/* will be further decoded below */
-#else /* !sun */
+#else /* !illumos */
return (ENOENT);
-#endif /* !sun */
+#endif /* illumos */
}
if (strncmp(cp, "S-1-", 4) == 0) {
@@ -4286,7 +4286,7 @@ zfs_prune_proplist(zfs_handle_t *zhp, uint8_t *props)
}
}
-#ifdef sun
+#ifdef illumos
static int
zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
zfs_smb_acl_op_t cmd, char *resource1, char *resource2)
@@ -4333,8 +4333,7 @@ zfs_smb_acl_mgmt(libzfs_handle_t *hdl, char *dataset, char *path,
return (-1);
}
error = ioctl(hdl->libzfs_fd, ZFS_IOC_SMB_ACL, &zc);
- if (nvlist)
- nvlist_free(nvlist);
+ nvlist_free(nvlist);
return (error);
}
@@ -4368,7 +4367,7 @@ zfs_smb_acl_rename(libzfs_handle_t *hdl, char *dataset, char *path,
return (zfs_smb_acl_mgmt(hdl, dataset, path, ZFS_SMB_ACL_RENAME,
oldname, newname));
}
-#endif /* sun */
+#endif /* illumos */
int
zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type,
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
index 3b17579..28b1e2e 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
/*
@@ -136,12 +137,13 @@ get_stats_for_obj(differ_info_t *di, const char *dsname, uint64_t obj,
static void
stream_bytes(FILE *fp, const char *string)
{
- while (*string) {
- if (*string > ' ' && *string != '\\' && *string < '\177')
- (void) fprintf(fp, "%c", *string++);
- else {
- (void) fprintf(fp, "\\%03hho",
- (unsigned char)*string++);
+ char c;
+
+ while ((c = *string++) != '\0') {
+ if (c > ' ' && c != '\\' && c < '\177') {
+ (void) fprintf(fp, "%c", c);
+ } else {
+ (void) fprintf(fp, "\\%03o", (uint8_t)c);
}
}
}
@@ -495,7 +497,7 @@ find_shares_object(differ_info_t *di)
(void) strlcat(fullpath, ZDIFF_SHARESDIR, MAXPATHLEN);
if (stat64(fullpath, &sb) != 0) {
-#ifdef sun
+#ifdef illumos
(void) snprintf(di->errbuf, sizeof (di->errbuf),
dgettext(TEXT_DOMAIN, "Cannot stat %s"), fullpath);
return (zfs_error(di->zhp->zfs_hdl, EZFS_DIFF, di->errbuf));
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
index 87b41cf..133cc6f 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
@@ -958,7 +958,7 @@ slice_cache_compare(const void *arg1, const void *arg2)
return (rv > 0 ? 1 : -1);
}
-#ifdef sun
+#ifdef illumos
static void
check_one_slice(avl_tree_t *r, char *diskname, uint_t partno,
diskaddr_t size, uint_t blksz)
@@ -981,12 +981,12 @@ check_one_slice(avl_tree_t *r, char *diskname, uint_t partno,
(node = avl_find(r, &tmpnode, NULL)))
node->rn_nozpool = B_TRUE;
}
-#endif /* sun */
+#endif /* illumos */
static void
nozpool_all_slices(avl_tree_t *r, const char *sname)
{
-#ifdef sun
+#ifdef illumos
char diskname[MAXNAMELEN];
char *ptr;
int i;
@@ -1002,10 +1002,10 @@ nozpool_all_slices(avl_tree_t *r, const char *sname)
ptr[0] = 'p';
for (i = 0; i <= FD_NUMPART; i++)
check_one_slice(r, diskname, i, 0, 1);
-#endif /* sun */
+#endif /* illumos */
}
-#ifdef sun
+#ifdef illumos
static void
check_slices(avl_tree_t *r, int fd, const char *sname)
{
@@ -1039,7 +1039,7 @@ check_slices(avl_tree_t *r, int fd, const char *sname)
efi_free(gpt);
}
}
-#endif /* sun */
+#endif /* illumos */
static void
zpool_open_func(void *arg)
@@ -1069,7 +1069,7 @@ zpool_open_func(void *arg)
return;
}
/* this file is too small to hold a zpool */
-#ifdef sun
+#ifdef illumos
if (S_ISREG(statbuf.st_mode) &&
statbuf.st_size < SPA_MINDEVSIZE) {
(void) close(fd);
@@ -1081,12 +1081,12 @@ zpool_open_func(void *arg)
*/
check_slices(rn->rn_avl, fd, rn->rn_name);
}
-#else /* !sun */
+#else /* !illumos */
if (statbuf.st_size < SPA_MINDEVSIZE) {
(void) close(fd);
return;
}
-#endif /* sun */
+#endif /* illumos */
if ((zpool_read_label(fd, &config)) != 0) {
(void) close(fd);
@@ -1331,8 +1331,7 @@ error:
venext = ve->ve_next;
for (ce = ve->ve_configs; ce != NULL; ce = cenext) {
cenext = ce->ce_next;
- if (ce->ce_config)
- nvlist_free(ce->ce_config);
+ nvlist_free(ce->ce_config);
free(ce);
}
free(ve);
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
index b94af5b..f03da99 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
@@ -139,7 +139,7 @@ is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto)
*tab = '\0';
if (strcmp(buf, mountpoint) == 0) {
-#ifdef sun
+#ifdef illumos
/*
* the protocol field is the third field
* skip over second field
@@ -172,7 +172,7 @@ is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto)
return (SHARED_NOT_SHARED);
}
-#ifdef sun
+#ifdef illumos
/*
* Returns true if the specified directory is empty. If we can't open the
* directory at all, return true so that the mount can fail with a more
@@ -297,7 +297,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
}
}
-#ifdef sun /* FreeBSD: overlay mounts are not checked. */
+#ifdef illumos /* FreeBSD: overlay mounts are not checked. */
/*
* Determine if the mountpoint is empty. If so, refuse to perform the
* mount. We don't perform this check if MS_OVERLAY is specified, which
@@ -507,7 +507,7 @@ zfs_is_shared_smb(zfs_handle_t *zhp, char **where)
* initialized in _zfs_init_libshare() are actually present.
*/
-#ifdef sun
+#ifdef illumos
static sa_handle_t (*_sa_init)(int);
static void (*_sa_fini)(sa_handle_t);
static sa_share_t (*_sa_find_share)(sa_handle_t, char *);
@@ -534,7 +534,7 @@ static void (*_sa_update_sharetab_ts)(sa_handle_t);
static void
_zfs_init_libshare(void)
{
-#ifdef sun
+#ifdef illumos
void *libshare;
char path[MAXPATHLEN];
char isa[MAXISALEN];
@@ -605,7 +605,7 @@ zfs_init_libshare(libzfs_handle_t *zhandle, int service)
{
int ret = SA_OK;
-#ifdef sun
+#ifdef illumos
if (_sa_init == NULL)
ret = SA_CONFIG_ERR;
@@ -646,7 +646,7 @@ void
zfs_uninit_libshare(libzfs_handle_t *zhandle)
{
if (zhandle != NULL && zhandle->libzfs_sharehdl != NULL) {
-#ifdef sun
+#ifdef illumos
if (_sa_fini != NULL)
_sa_fini(zhandle->libzfs_sharehdl);
#endif
@@ -663,7 +663,7 @@ zfs_uninit_libshare(libzfs_handle_t *zhandle)
int
zfs_parse_options(char *options, zfs_share_proto_t proto)
{
-#ifdef sun
+#ifdef illumos
if (_sa_parse_legacy_options != NULL) {
return (_sa_parse_legacy_options(NULL, options,
proto_table[proto].p_name));
@@ -674,7 +674,7 @@ zfs_parse_options(char *options, zfs_share_proto_t proto)
#endif
}
-#ifdef sun
+#ifdef illumos
/*
* zfs_sa_find_share(handle, path)
*
@@ -716,7 +716,7 @@ zfs_sa_disable_share(sa_share_t share, char *proto)
return (_sa_disable_share(share, proto));
return (SA_CONFIG_ERR);
}
-#endif /* sun */
+#endif /* illumos */
/*
* Share the given filesystem according to the options in the specified
@@ -767,7 +767,7 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
if (zfs_prop_get_int(zhp, ZFS_PROP_ZONED))
continue;
-#ifdef sun
+#ifdef illumos
share = zfs_sa_find_share(hdl->libzfs_sharehdl, mountpoint);
if (share == NULL) {
/*
@@ -856,7 +856,7 @@ static int
unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint,
zfs_share_proto_t proto)
{
-#ifdef sun
+#ifdef illumos
sa_share_t share;
int err;
char *mntpt;
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
index 5fd9612..4dc48fa 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
@@ -1054,12 +1054,9 @@ zpool_open(libzfs_handle_t *hdl, const char *pool)
void
zpool_close(zpool_handle_t *zhp)
{
- if (zhp->zpool_config)
- nvlist_free(zhp->zpool_config);
- if (zhp->zpool_old_config)
- nvlist_free(zhp->zpool_old_config);
- if (zhp->zpool_props)
- nvlist_free(zhp->zpool_props);
+ nvlist_free(zhp->zpool_config);
+ nvlist_free(zhp->zpool_old_config);
+ nvlist_free(zhp->zpool_props);
free(zhp);
}
@@ -1577,8 +1574,7 @@ zpool_import(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
ret = zpool_import_props(hdl, config, newname, props,
ZFS_IMPORT_NORMAL);
- if (props)
- nvlist_free(props);
+ nvlist_free(props);
return (ret);
}
@@ -2339,7 +2335,7 @@ zpool_get_physpath(zpool_handle_t *zhp, char *physpath, size_t phypath_size)
static int
zpool_relabel_disk(libzfs_handle_t *hdl, const char *name)
{
-#ifdef sun
+#ifdef illumos
char path[MAXPATHLEN];
char errbuf[1024];
int fd, error;
@@ -2369,7 +2365,7 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *name)
"relabel '%s': unable to read disk capacity"), name);
return (zfs_error(hdl, EZFS_NOCAP, errbuf));
}
-#endif /* sun */
+#endif /* illumos */
return (0);
}
@@ -2901,8 +2897,7 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot,
&children) != 0) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"Source pool is missing vdev tree"));
- if (zc_props)
- nvlist_free(zc_props);
+ nvlist_free(zc_props);
return (-1);
}
@@ -3050,10 +3045,8 @@ out:
free(varray);
}
zcmd_free_nvlists(&zc);
- if (zc_props)
- nvlist_free(zc_props);
- if (newconfig)
- nvlist_free(newconfig);
+ nvlist_free(zc_props);
+ nvlist_free(newconfig);
if (freelist) {
nvlist_free(*newroot);
*newroot = NULL;
@@ -3417,7 +3410,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
devid_str_free(newdevid);
}
-#ifdef sun
+#ifdef illumos
if (strncmp(path, "/dev/dsk/", 9) == 0)
path += 9;
@@ -3442,10 +3435,10 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv,
}
return (tmp);
}
-#else /* !sun */
+#else /* !illumos */
if (strncmp(path, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
path += sizeof(_PATH_DEV) - 1;
-#endif /* !sun */
+#endif /* illumos */
} else {
verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0);
@@ -3835,7 +3828,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
free(mntpnt);
}
-#ifdef sun
+#ifdef illumos
/*
* Read the EFI label from the config, if a label does not exist then
* pass back the error to the caller. If the caller has passed a non-NULL
@@ -3900,7 +3893,7 @@ find_start_block(nvlist_t *config)
}
return (MAXOFFSET_T);
}
-#endif /* sun */
+#endif /* illumos */
/*
* Label an individual disk. The name provided is the short name,
@@ -3909,7 +3902,7 @@ find_start_block(nvlist_t *config)
int
zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
{
-#ifdef sun
+#ifdef illumos
char path[MAXPATHLEN];
struct dk_gpt *vtoc;
int fd;
@@ -4007,7 +4000,7 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
(void) close(fd);
efi_free(vtoc);
-#endif /* sun */
+#endif /* illumos */
return (0);
}
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
index e99231d..723cd42 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
@@ -26,6 +26,8 @@
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
+ * Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
+ * Copyright (c) 2014 Integros [integros.com]
*/
#include <assert.h>
@@ -67,7 +69,7 @@ extern void zfs_setprop_error(libzfs_handle_t *, zfs_prop_t, int, char *);
static int zfs_receive_impl(libzfs_handle_t *, const char *, const char *,
recvflags_t *, int, const char *, nvlist_t *, avl_tree_t *, char **, int,
- uint64_t *);
+ uint64_t *, const char *);
static int guid_to_name(libzfs_handle_t *, const char *,
uint64_t, boolean_t, char *);
@@ -955,7 +957,7 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj,
case EIO:
case ENOLINK:
case ENOSPC:
-#ifdef sun
+#ifdef illumos
case ENOSTR:
#endif
case ENXIO:
@@ -2602,6 +2604,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
nvlist_t *stream_nv = NULL;
avl_tree_t *stream_avl = NULL;
char *fromsnap = NULL;
+ char *sendsnap = NULL;
char *cp;
char tofs[ZFS_MAXNAMELEN];
char sendfs[ZFS_MAXNAMELEN];
@@ -2750,8 +2753,16 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
*/
(void) strlcpy(sendfs, drr->drr_u.drr_begin.drr_toname,
ZFS_MAXNAMELEN);
- if ((cp = strchr(sendfs, '@')) != NULL)
+ if ((cp = strchr(sendfs, '@')) != NULL) {
*cp = '\0';
+ /*
+ * Find the "sendsnap", the final snapshot in a replication
+ * stream. zfs_receive_one() handles certain errors
+ * differently, depending on if the contained stream is the
+ * last one or not.
+ */
+ sendsnap = (cp + 1);
+ }
/* Finally, receive each contained stream */
do {
@@ -2764,7 +2775,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
*/
error = zfs_receive_impl(hdl, destname, NULL, flags, fd,
sendfs, stream_nv, stream_avl, top_zfs, cleanup_fd,
- action_handlep);
+ action_handlep, sendsnap);
if (error == ENODATA) {
error = 0;
break;
@@ -2783,8 +2794,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
out:
fsavl_destroy(stream_avl);
- if (stream_nv)
- nvlist_free(stream_nv);
+ nvlist_free(stream_nv);
if (softerr)
error = -2;
if (anyerr)
@@ -2930,7 +2940,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
const char *originsnap, recvflags_t *flags, dmu_replay_record_t *drr,
dmu_replay_record_t *drr_noswap, const char *sendfs, nvlist_t *stream_nv,
avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
- uint64_t *action_handlep)
+ uint64_t *action_handlep, const char *finalsnap)
{
zfs_cmd_t zc = { 0 };
time_t begin_time;
@@ -2947,6 +2957,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
nvlist_t *snapprops_nvlist = NULL;
zprop_errflags_t prop_errflags;
boolean_t recursive;
+ char *snapname = NULL;
begin_time = time(NULL);
@@ -2957,7 +2968,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
ENOENT);
if (stream_avl != NULL) {
- char *snapname;
nvlist_t *fs = fsavl_find(stream_avl, drrb->drr_toguid,
&snapname);
nvlist_t *props;
@@ -3313,7 +3323,21 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
ZPROP_N_MORE_ERRORS) == 0) {
trunc_prop_errs(intval);
break;
- } else {
+ } else if (snapname == NULL || finalsnap == NULL ||
+ strcmp(finalsnap, snapname) == 0 ||
+ strcmp(nvpair_name(prop_err),
+ zfs_prop_to_name(ZFS_PROP_REFQUOTA)) != 0) {
+ /*
+ * Skip the special case of, for example,
+ * "refquota", errors on intermediate
+ * snapshots leading up to a final one.
+ * That's why we have all of the checks above.
+ *
+ * See zfs_ioctl.c's extract_delay_props() for
+ * a list of props which can fail on
+ * intermediate snapshots, but shouldn't
+ * affect the overall receive.
+ */
(void) snprintf(tbuf, sizeof (tbuf),
dgettext(TEXT_DOMAIN,
"cannot receive %s property on %s"),
@@ -3498,7 +3522,7 @@ static int
zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
const char *originsnap, recvflags_t *flags, int infd, const char *sendfs,
nvlist_t *stream_nv, avl_tree_t *stream_avl, char **top_zfs, int cleanup_fd,
- uint64_t *action_handlep)
+ uint64_t *action_handlep, const char *finalsnap)
{
int err;
dmu_replay_record_t drr, drr_noswap;
@@ -3594,10 +3618,11 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
if ((cp = strchr(nonpackage_sendfs, '@')) != NULL)
*cp = '\0';
sendfs = nonpackage_sendfs;
+ VERIFY(finalsnap == NULL);
}
return (zfs_receive_one(hdl, infd, tosnap, originsnap, flags,
&drr, &drr_noswap, sendfs, stream_nv, stream_avl, top_zfs,
- cleanup_fd, action_handlep));
+ cleanup_fd, action_handlep, finalsnap));
} else {
assert(DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo) ==
DMU_COMPOUNDSTREAM);
@@ -3632,7 +3657,7 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, nvlist_t *props,
VERIFY(cleanup_fd >= 0);
err = zfs_receive_impl(hdl, tosnap, originsnap, flags, infd, NULL, NULL,
- stream_avl, &top_zfs, cleanup_fd, &action_handle);
+ stream_avl, &top_zfs, cleanup_fd, &action_handle, NULL);
VERIFY(0 == close(cleanup_fd));
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
index 6f70604..1316aec 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
@@ -686,7 +686,7 @@ libzfs_fini(libzfs_handle_t *hdl)
(void) fclose(hdl->libzfs_sharetab);
zfs_uninit_libshare(hdl);
zpool_free_handles(hdl);
-#ifdef sun
+#ifdef illumos
libzfs_fru_clear(hdl, B_TRUE);
#endif
namespace_clear(hdl);
@@ -738,7 +738,7 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl, char *path, zfs_type_t argtype)
return (NULL);
}
-#ifdef sun
+#ifdef illumos
rewind(hdl->libzfs_mnttab);
while ((ret = getextmntent(hdl->libzfs_mnttab, &entry, 0)) == 0) {
if (makedevice(entry.mnt_major, entry.mnt_minor) ==
@@ -758,7 +758,7 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl, char *path, zfs_type_t argtype)
strerror(errno));
}
}
-#endif /* sun */
+#endif /* illumos */
if (ret != 0) {
return (NULL);
}
OpenPOWER on IntegriCloud