diff options
author | Brian Behlendorf <[email protected]> | 2009-02-18 12:51:31 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2009-02-18 12:51:31 -0800 |
commit | d164b2093561a9771db07346e6fffc9ca19427a2 (patch) | |
tree | b24adaf8695cebdd827968ac1df3cc0093936be1 /lib | |
parent | c65e71073f45e6e549c825969740cb15a96ea547 (diff) |
Rebase master to b108
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/include/libzfs.h | 13 | ||||
-rw-r--r-- | lib/libzfs/libzfs_mount.c | 10 | ||||
-rw-r--r-- | lib/libzfs/libzfs_pool.c | 38 | ||||
-rw-r--r-- | lib/libzfs/libzfs_sendrecv.c | 4 | ||||
-rw-r--r-- | lib/libzfs/libzfs_util.c | 5 | ||||
-rw-r--r-- | lib/libzpool/include/sys/zfs_context.h | 4 | ||||
-rw-r--r-- | lib/libzpool/kernel.c | 7 |
7 files changed, 58 insertions, 23 deletions
diff --git a/lib/libzfs/include/libzfs.h b/lib/libzfs/include/libzfs.h index 511ee79e3..a259fb469 100644 --- a/lib/libzfs/include/libzfs.h +++ b/lib/libzfs/include/libzfs.h @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -264,9 +264,15 @@ typedef enum { ZPOOL_STATUS_HOSTID_MISMATCH, /* last accessed by another system */ ZPOOL_STATUS_IO_FAILURE_WAIT, /* failed I/O, failmode 'wait' */ ZPOOL_STATUS_IO_FAILURE_CONTINUE, /* failed I/O, failmode 'continue' */ + ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */ + + /* + * These faults have no corresponding message ID. At the time we are + * checking the status, the original reason for the FMA fault (I/O or + * checksum errors) has been lost. + */ ZPOOL_STATUS_FAULTED_DEV_R, /* faulted device with replicas */ ZPOOL_STATUS_FAULTED_DEV_NR, /* faulted device with no replicas */ - ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */ /* * The following are not faults per se, but still an error possibly @@ -466,6 +472,9 @@ typedef struct recvflags { /* byteswap flag is used internally; callers need not specify */ int byteswap : 1; + + /* do not mount file systems as they are extracted (private) */ + int nomount : 1; } recvflags_t; extern int zfs_receive(libzfs_handle_t *, const char *, recvflags_t, diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 0668dea36..7810e5d68 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1180,10 +1180,12 @@ zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags) /* * And mount all the datasets, keeping track of which ones - * succeeded or failed. By using zfs_alloc(), the good pointer - * will always be non-NULL. + * succeeded or failed. */ - good = zfs_alloc(zhp->zpool_hdl, cb.cb_used * sizeof (int)); + if ((good = zfs_alloc(zhp->zpool_hdl, + cb.cb_used * sizeof (int))) == NULL) + goto out; + ret = 0; for (i = 0; i < cb.cb_used; i++) { if (zfs_mount(cb.cb_datasets[i], mntopts, flags) != 0) diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 9cb5d7642..75ecc54e2 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -217,12 +217,39 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, uint_t vsc; if (zpool_get_state(zhp) == POOL_STATE_UNAVAIL) { - if (prop == ZPOOL_PROP_NAME) + switch (prop) { + case ZPOOL_PROP_NAME: (void) strlcpy(buf, zpool_get_name(zhp), len); - else if (prop == ZPOOL_PROP_HEALTH) + break; + + case ZPOOL_PROP_HEALTH: (void) strlcpy(buf, "FAULTED", len); - else + break; + + case ZPOOL_PROP_GUID: + intval = zpool_get_prop_int(zhp, prop, &src); + (void) snprintf(buf, len, "%llu", intval); + break; + + case ZPOOL_PROP_ALTROOT: + case ZPOOL_PROP_CACHEFILE: + if (zhp->zpool_props != NULL || + zpool_get_all_props(zhp) == 0) { + (void) strlcpy(buf, + zpool_get_prop_string(zhp, prop, &src), + len); + if (srctype != NULL) + *srctype = src; + return (0); + } + /* FALLTHROUGH */ + default: (void) strlcpy(buf, "-", len); + break; + } + + if (srctype != NULL) + *srctype = src; return (0); } @@ -532,9 +559,6 @@ zpool_set_prop(zpool_handle_t *zhp, const char *propname, const char *propval) dgettext(TEXT_DOMAIN, "cannot set property for '%s'"), zhp->zpool_name); - if (zhp->zpool_props == NULL && zpool_get_all_props(zhp)) - return (zfs_error(zhp->zpool_hdl, EZFS_POOLPROPS, errbuf)); - if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) return (no_memory(zhp->zpool_hdl)); diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index a3ed5cea8..5a2e2aeb6 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -2077,7 +2077,7 @@ zfs_receive(libzfs_handle_t *hdl, const char *tosnap, recvflags_t flags, err = zfs_receive_impl(hdl, tosnap, flags, infd, stream_avl, &top_zfs); - if (err == 0 && top_zfs) { + if (err == 0 && !flags.nomount && top_zfs) { zfs_handle_t *zhp; prop_changelist_t *clp; diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 4270ac520..259f5fd49 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -480,7 +480,6 @@ zfs_realloc(libzfs_handle_t *hdl, void *ptr, size_t oldsize, size_t newsize) if ((ret = realloc(ptr, newsize)) == NULL) { (void) no_memory(hdl); - free(ptr); return (NULL); } @@ -1018,9 +1017,9 @@ zfs_nicestrtonum(libzfs_handle_t *hdl, const char *value, uint64_t *num) return (-1); } - /* Rely on stroll() to process the numeric portion. */ + /* Rely on stroull() to process the numeric portion. */ errno = 0; - *num = strtoll(value, &end, 10); + *num = strtoull(value, &end, 10); /* * Check for ERANGE, which indicates that the value is too large to fit diff --git a/lib/libzpool/include/sys/zfs_context.h b/lib/libzpool/include/sys/zfs_context.h index 0e7019bba..a50e4b0ac 100644 --- a/lib/libzpool/include/sys/zfs_context.h +++ b/lib/libzpool/include/sys/zfs_context.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -490,7 +490,7 @@ typedef struct callb_cpr { /* * Hostname information */ -extern char hw_serial[]; +extern char hw_serial[]; /* for userland-emulated hostid access */ extern int ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result); diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index fe817cc64..89108fe5b 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -36,6 +36,7 @@ #include <sys/zfs_context.h> #include <sys/zmod.h> #include <sys/utsname.h> +#include <sys/systeminfo.h> /* * Emulation of kernel services in userland. @@ -43,7 +44,7 @@ uint64_t physmem; vnode_t *rootdir = (vnode_t *)0xabcd1234; -char hw_serial[11]; +char hw_serial[HW_HOSTID_LEN]; struct utsname utsname = { "userland", "libzpool", "1", "1", "na" @@ -778,7 +779,7 @@ kernel_init(int mode) dprintf("physmem = %llu pages (%.2f GB)\n", physmem, (double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30)); - snprintf(hw_serial, sizeof (hw_serial), "%ld", gethostid()); + (void) snprintf(hw_serial, sizeof (hw_serial), "%ld", gethostid()); VERIFY((random_fd = open("/dev/random", O_RDONLY)) != -1); VERIFY((urandom_fd = open("/dev/urandom", O_RDONLY)) != -1); |