mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Rebase to OpenSolaris b103, in the process we are removing any code which did not originate from the OpenSolaris source. These changes will be reintroduced in topic branches for easier tracking
This commit is contained in:
+318
-445
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zdb_il.c 1.6 07/10/25 SMI"
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
/*
|
||||
* Print intent log header and statistics.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zdump.c 1.15 06/12/06 SMI"
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
/*
|
||||
* zdump 7.24
|
||||
|
||||
+32
-20
@@ -19,12 +19,10 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zfs_iter.c 1.8 07/10/29 SMI"
|
||||
|
||||
#include <libintl.h>
|
||||
#include <libuutil.h>
|
||||
#include <stddef.h>
|
||||
@@ -56,7 +54,7 @@ typedef struct zfs_node {
|
||||
|
||||
typedef struct callback_data {
|
||||
uu_avl_t *cb_avl;
|
||||
int cb_recurse;
|
||||
int cb_flags;
|
||||
zfs_type_t cb_types;
|
||||
zfs_sort_column_t *cb_sortcol;
|
||||
zprop_list_t **cb_proplist;
|
||||
@@ -65,7 +63,23 @@ typedef struct callback_data {
|
||||
uu_avl_pool_t *avl_pool;
|
||||
|
||||
/*
|
||||
* Called for each dataset. If the object the object is of an appropriate type,
|
||||
* Include snaps if they were requested or if this a zfs list where types
|
||||
* were not specified and the "listsnapshots" property is set on this pool.
|
||||
*/
|
||||
static int
|
||||
zfs_include_snapshots(zfs_handle_t *zhp, callback_data_t *cb)
|
||||
{
|
||||
zpool_handle_t *zph;
|
||||
|
||||
if ((cb->cb_flags & ZFS_ITER_PROP_LISTSNAPS) == 0)
|
||||
return (cb->cb_types & ZFS_TYPE_SNAPSHOT);
|
||||
|
||||
zph = zfs_get_pool_handle(zhp);
|
||||
return (zpool_get_prop_int(zph, ZPOOL_PROP_LISTSNAPS, NULL));
|
||||
}
|
||||
|
||||
/*
|
||||
* Called for each dataset. If the object is of an appropriate type,
|
||||
* add it to the avl tree and recurse over any children as necessary.
|
||||
*/
|
||||
static int
|
||||
@@ -73,11 +87,10 @@ zfs_callback(zfs_handle_t *zhp, void *data)
|
||||
{
|
||||
callback_data_t *cb = data;
|
||||
int dontclose = 0;
|
||||
int include_snaps = zfs_include_snapshots(zhp, cb);
|
||||
|
||||
/*
|
||||
* If this object is of the appropriate type, add it to the AVL tree.
|
||||
*/
|
||||
if (zfs_get_type(zhp) & cb->cb_types) {
|
||||
if ((zfs_get_type(zhp) & cb->cb_types) ||
|
||||
((zfs_get_type(zhp) == ZFS_TYPE_SNAPSHOT) && include_snaps)) {
|
||||
uu_avl_index_t idx;
|
||||
zfs_node_t *node = safe_malloc(sizeof (zfs_node_t));
|
||||
|
||||
@@ -100,11 +113,10 @@ zfs_callback(zfs_handle_t *zhp, void *data)
|
||||
/*
|
||||
* Recurse if necessary.
|
||||
*/
|
||||
if (cb->cb_recurse) {
|
||||
if (cb->cb_flags & ZFS_ITER_RECURSE) {
|
||||
if (zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM)
|
||||
(void) zfs_iter_filesystems(zhp, zfs_callback, data);
|
||||
if (zfs_get_type(zhp) != ZFS_TYPE_SNAPSHOT &&
|
||||
(cb->cb_types & ZFS_TYPE_SNAPSHOT))
|
||||
if ((zfs_get_type(zhp) != ZFS_TYPE_SNAPSHOT) && include_snaps)
|
||||
(void) zfs_iter_snapshots(zhp, zfs_callback, data);
|
||||
}
|
||||
|
||||
@@ -296,7 +308,7 @@ zfs_sort(const void *larg, const void *rarg, void *data)
|
||||
|
||||
if (lstr)
|
||||
ret = strcmp(lstr, rstr);
|
||||
if (lnum < rnum)
|
||||
else if (lnum < rnum)
|
||||
ret = -1;
|
||||
else if (lnum > rnum)
|
||||
ret = 1;
|
||||
@@ -312,9 +324,9 @@ zfs_sort(const void *larg, const void *rarg, void *data)
|
||||
}
|
||||
|
||||
int
|
||||
zfs_for_each(int argc, char **argv, boolean_t recurse, zfs_type_t types,
|
||||
zfs_sort_column_t *sortcol, zprop_list_t **proplist, zfs_iter_f callback,
|
||||
void *data, boolean_t args_can_be_paths)
|
||||
zfs_for_each(int argc, char **argv, int flags, zfs_type_t types,
|
||||
zfs_sort_column_t *sortcol, zprop_list_t **proplist,
|
||||
zfs_iter_f callback, void *data)
|
||||
{
|
||||
callback_data_t cb;
|
||||
int ret = 0;
|
||||
@@ -331,7 +343,7 @@ zfs_for_each(int argc, char **argv, boolean_t recurse, zfs_type_t types,
|
||||
}
|
||||
|
||||
cb.cb_sortcol = sortcol;
|
||||
cb.cb_recurse = recurse;
|
||||
cb.cb_flags = flags;
|
||||
cb.cb_proplist = proplist;
|
||||
cb.cb_types = types;
|
||||
if ((cb.cb_avl = uu_avl_create(avl_pool, NULL, UU_DEFAULT)) == NULL) {
|
||||
@@ -344,7 +356,7 @@ zfs_for_each(int argc, char **argv, boolean_t recurse, zfs_type_t types,
|
||||
/*
|
||||
* If given no arguments, iterate over all datasets.
|
||||
*/
|
||||
cb.cb_recurse = 1;
|
||||
cb.cb_flags |= ZFS_ITER_RECURSE;
|
||||
ret = zfs_iter_root(g_zfs, zfs_callback, &cb);
|
||||
} else {
|
||||
int i;
|
||||
@@ -357,14 +369,14 @@ zfs_for_each(int argc, char **argv, boolean_t recurse, zfs_type_t types,
|
||||
* can take volumes as well.
|
||||
*/
|
||||
argtype = types;
|
||||
if (recurse) {
|
||||
if (flags & ZFS_ITER_RECURSE) {
|
||||
argtype |= ZFS_TYPE_FILESYSTEM;
|
||||
if (types & ZFS_TYPE_SNAPSHOT)
|
||||
argtype |= ZFS_TYPE_VOLUME;
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (args_can_be_paths) {
|
||||
if (flags & ZFS_ITER_ARGS_CAN_BE_PATHS) {
|
||||
zhp = zfs_path_to_zhandle(g_zfs, argv[i],
|
||||
argtype);
|
||||
} else {
|
||||
|
||||
@@ -19,15 +19,13 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef ZFS_ITER_H
|
||||
#define ZFS_ITER_H
|
||||
|
||||
#pragma ident "@(#)zfs_iter.h 1.6 07/09/17 SMI"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -40,8 +38,12 @@ typedef struct zfs_sort_column {
|
||||
boolean_t sc_reverse;
|
||||
} zfs_sort_column_t;
|
||||
|
||||
int zfs_for_each(int, char **, boolean_t, zfs_type_t, zfs_sort_column_t *,
|
||||
zprop_list_t **, zfs_iter_f, void *, boolean_t);
|
||||
#define ZFS_ITER_RECURSE (1 << 0)
|
||||
#define ZFS_ITER_ARGS_CAN_BE_PATHS (1 << 1)
|
||||
#define ZFS_ITER_PROP_LISTSNAPS (1 << 2)
|
||||
|
||||
int zfs_for_each(int, char **, int options, zfs_type_t,
|
||||
zfs_sort_column_t *, zprop_list_t **, zfs_iter_f, void *);
|
||||
int zfs_add_sort_column(zfs_sort_column_t **, const char *, boolean_t);
|
||||
void zfs_free_sort_columns(zfs_sort_column_t *);
|
||||
|
||||
|
||||
+182
-99
@@ -24,8 +24,6 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zfs_main.c 1.58 08/03/24 SMI"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@@ -81,9 +79,10 @@ static int zfs_do_allow(int argc, char **argv);
|
||||
static int zfs_do_unallow(int argc, char **argv);
|
||||
|
||||
/*
|
||||
* These libumem hooks provide a reasonable set of defaults for the allocator's
|
||||
* debugging facilities.
|
||||
* Enable a reasonable set of defaults for libumem debugging on DEBUG builds.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
const char *
|
||||
_umem_debug_init(void)
|
||||
{
|
||||
@@ -95,6 +94,7 @@ _umem_logging_init(void)
|
||||
{
|
||||
return ("fail,contents"); /* $UMEM_LOGGING setting */
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
HELP_CLONE,
|
||||
@@ -173,8 +173,8 @@ get_usage(zfs_help_t idx)
|
||||
{
|
||||
switch (idx) {
|
||||
case HELP_CLONE:
|
||||
return (gettext("\tclone [-p] <snapshot> "
|
||||
"<filesystem|volume>\n"));
|
||||
return (gettext("\tclone [-p] [-o property=value] ... "
|
||||
"<snapshot> <filesystem|volume>\n"));
|
||||
case HELP_CREATE:
|
||||
return (gettext("\tcreate [-p] [-o property=value] ... "
|
||||
"<filesystem>\n"
|
||||
@@ -190,7 +190,7 @@ get_usage(zfs_help_t idx)
|
||||
"[filesystem|volume|snapshot] ...\n"));
|
||||
case HELP_INHERIT:
|
||||
return (gettext("\tinherit [-r] <property> "
|
||||
"<filesystem|volume> ...\n"));
|
||||
"<filesystem|volume|snapshot> ...\n"));
|
||||
case HELP_UPGRADE:
|
||||
return (gettext("\tupgrade [-v]\n"
|
||||
"\tupgrade [-r] [-V version] <-a | filesystem ...>\n"));
|
||||
@@ -219,11 +219,11 @@ get_usage(zfs_help_t idx)
|
||||
return (gettext("\tsend [-R] [-[iI] snapshot] <snapshot>\n"));
|
||||
case HELP_SET:
|
||||
return (gettext("\tset <property=value> "
|
||||
"<filesystem|volume> ...\n"));
|
||||
"<filesystem|volume|snapshot> ...\n"));
|
||||
case HELP_SHARE:
|
||||
return (gettext("\tshare <-a | filesystem>\n"));
|
||||
case HELP_SNAPSHOT:
|
||||
return (gettext("\tsnapshot [-r] "
|
||||
return (gettext("\tsnapshot [-r] [-o property=value] ... "
|
||||
"<filesystem@snapname|volume@snapname>\n"));
|
||||
case HELP_UNMOUNT:
|
||||
return (gettext("\tunmount [-f] "
|
||||
@@ -281,14 +281,12 @@ usage_prop_cb(int prop, void *cb)
|
||||
{
|
||||
FILE *fp = cb;
|
||||
|
||||
(void) fprintf(fp, "\t%-14s ", zfs_prop_to_name(prop));
|
||||
(void) fprintf(fp, "\t%-15s ", zfs_prop_to_name(prop));
|
||||
|
||||
if (prop == ZFS_PROP_CASE)
|
||||
(void) fprintf(fp, "NO ");
|
||||
else if (zfs_prop_readonly(prop))
|
||||
(void) fprintf(fp, " NO ");
|
||||
if (zfs_prop_readonly(prop))
|
||||
(void) fprintf(fp, " NO ");
|
||||
else
|
||||
(void) fprintf(fp, " YES ");
|
||||
(void) fprintf(fp, "YES ");
|
||||
|
||||
if (zfs_prop_inheritable(prop))
|
||||
(void) fprintf(fp, " YES ");
|
||||
@@ -363,7 +361,7 @@ usage(boolean_t requested)
|
||||
|
||||
(void) fprintf(fp, gettext("\nSizes are specified in bytes "
|
||||
"with standard units such as K, M, G, etc.\n"));
|
||||
(void) fprintf(fp, gettext("\n\nUser-defined properties can "
|
||||
(void) fprintf(fp, gettext("\nUser-defined properties can "
|
||||
"be specified by using a name containing a colon (:).\n"));
|
||||
|
||||
} else if (show_permissions) {
|
||||
@@ -397,8 +395,35 @@ usage(boolean_t requested)
|
||||
exit(requested ? 0 : 2);
|
||||
}
|
||||
|
||||
static int
|
||||
parseprop(nvlist_t *props)
|
||||
{
|
||||
char *propname = optarg;
|
||||
char *propval, *strval;
|
||||
|
||||
if ((propval = strchr(propname, '=')) == NULL) {
|
||||
(void) fprintf(stderr, gettext("missing "
|
||||
"'=' for -o option\n"));
|
||||
return (-1);
|
||||
}
|
||||
*propval = '\0';
|
||||
propval++;
|
||||
if (nvlist_lookup_string(props, propname, &strval) == 0) {
|
||||
(void) fprintf(stderr, gettext("property '%s' "
|
||||
"specified multiple times\n"), propname);
|
||||
return (-1);
|
||||
}
|
||||
if (nvlist_add_string(props, propname, propval) != 0) {
|
||||
(void) fprintf(stderr, gettext("internal "
|
||||
"error: out of memory\n"));
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* zfs clone [-p] <snap> <fs | vol>
|
||||
* zfs clone [-p] [-o prop=value] ... <snap> <fs | vol>
|
||||
*
|
||||
* Given an existing dataset, create a writable copy whose initial contents
|
||||
* are the same as the source. The newly created dataset maintains a
|
||||
@@ -410,21 +435,32 @@ usage(boolean_t requested)
|
||||
static int
|
||||
zfs_do_clone(int argc, char **argv)
|
||||
{
|
||||
zfs_handle_t *zhp;
|
||||
zfs_handle_t *zhp = NULL;
|
||||
boolean_t parents = B_FALSE;
|
||||
nvlist_t *props;
|
||||
int ret;
|
||||
int c;
|
||||
|
||||
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) {
|
||||
(void) fprintf(stderr, gettext("internal error: "
|
||||
"out of memory\n"));
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, "p")) != -1) {
|
||||
while ((c = getopt(argc, argv, "o:p")) != -1) {
|
||||
switch (c) {
|
||||
case 'o':
|
||||
if (parseprop(props))
|
||||
return (1);
|
||||
break;
|
||||
case 'p':
|
||||
parents = B_TRUE;
|
||||
break;
|
||||
case '?':
|
||||
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
|
||||
optopt);
|
||||
usage(B_FALSE);
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,16 +471,16 @@ zfs_do_clone(int argc, char **argv)
|
||||
if (argc < 1) {
|
||||
(void) fprintf(stderr, gettext("missing source dataset "
|
||||
"argument\n"));
|
||||
usage(B_FALSE);
|
||||
goto usage;
|
||||
}
|
||||
if (argc < 2) {
|
||||
(void) fprintf(stderr, gettext("missing target dataset "
|
||||
"argument\n"));
|
||||
usage(B_FALSE);
|
||||
goto usage;
|
||||
}
|
||||
if (argc > 2) {
|
||||
(void) fprintf(stderr, gettext("too many arguments\n"));
|
||||
usage(B_FALSE);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
/* open the source dataset */
|
||||
@@ -466,7 +502,7 @@ zfs_do_clone(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* pass to libzfs */
|
||||
ret = zfs_clone(zhp, argv[1], NULL);
|
||||
ret = zfs_clone(zhp, argv[1], props);
|
||||
|
||||
/* create the mountpoint if necessary */
|
||||
if (ret == 0) {
|
||||
@@ -481,8 +517,16 @@ zfs_do_clone(int argc, char **argv)
|
||||
}
|
||||
|
||||
zfs_close(zhp);
|
||||
nvlist_free(props);
|
||||
|
||||
return (ret == 0 ? 0 : 1);
|
||||
return (!!ret);
|
||||
|
||||
usage:
|
||||
if (zhp)
|
||||
zfs_close(zhp);
|
||||
nvlist_free(props);
|
||||
usage(B_FALSE);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -511,11 +555,8 @@ zfs_do_create(int argc, char **argv)
|
||||
boolean_t bflag = B_FALSE;
|
||||
boolean_t parents = B_FALSE;
|
||||
int ret = 1;
|
||||
nvlist_t *props = NULL;
|
||||
nvlist_t *props;
|
||||
uint64_t intval;
|
||||
char *propname;
|
||||
char *propval = NULL;
|
||||
char *strval;
|
||||
int canmount;
|
||||
|
||||
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) {
|
||||
@@ -566,25 +607,8 @@ zfs_do_create(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
propname = optarg;
|
||||
if ((propval = strchr(propname, '=')) == NULL) {
|
||||
(void) fprintf(stderr, gettext("missing "
|
||||
"'=' for -o option\n"));
|
||||
if (parseprop(props))
|
||||
goto error;
|
||||
}
|
||||
*propval = '\0';
|
||||
propval++;
|
||||
if (nvlist_lookup_string(props, propname,
|
||||
&strval) == 0) {
|
||||
(void) fprintf(stderr, gettext("property '%s' "
|
||||
"specified multiple times\n"), propname);
|
||||
goto error;
|
||||
}
|
||||
if (nvlist_add_string(props, propname, propval) != 0) {
|
||||
(void) fprintf(stderr, gettext("internal "
|
||||
"error: out of memory\n"));
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
noreserve = B_TRUE;
|
||||
@@ -626,6 +650,7 @@ zfs_do_create(int argc, char **argv)
|
||||
uint64_t spa_version;
|
||||
char *p;
|
||||
zfs_prop_t resv_prop;
|
||||
char *strval;
|
||||
|
||||
if (p = strchr(argv[0], '/'))
|
||||
*p = '\0';
|
||||
@@ -1081,8 +1106,7 @@ static int
|
||||
zfs_do_get(int argc, char **argv)
|
||||
{
|
||||
zprop_get_cbdata_t cb = { 0 };
|
||||
boolean_t recurse = B_FALSE;
|
||||
int i, c;
|
||||
int i, c, flags = 0;
|
||||
char *value, *fields;
|
||||
int ret;
|
||||
zprop_list_t fake_name = { 0 };
|
||||
@@ -1104,7 +1128,7 @@ zfs_do_get(int argc, char **argv)
|
||||
cb.cb_literal = B_TRUE;
|
||||
break;
|
||||
case 'r':
|
||||
recurse = B_TRUE;
|
||||
flags |= ZFS_ITER_RECURSE;
|
||||
break;
|
||||
case 'H':
|
||||
cb.cb_scripted = B_TRUE;
|
||||
@@ -1232,8 +1256,8 @@ zfs_do_get(int argc, char **argv)
|
||||
cb.cb_first = B_TRUE;
|
||||
|
||||
/* run for each object */
|
||||
ret = zfs_for_each(argc, argv, recurse, ZFS_TYPE_DATASET, NULL,
|
||||
&cb.cb_proplist, get_callback, &cb, B_FALSE);
|
||||
ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET, NULL,
|
||||
&cb.cb_proplist, get_callback, &cb);
|
||||
|
||||
if (cb.cb_proplist == &fake_name)
|
||||
zprop_free_list(fake_name.pl_next);
|
||||
@@ -1256,29 +1280,44 @@ zfs_do_get(int argc, char **argv)
|
||||
*/
|
||||
|
||||
static int
|
||||
inherit_callback(zfs_handle_t *zhp, void *data)
|
||||
inherit_recurse_cb(zfs_handle_t *zhp, void *data)
|
||||
{
|
||||
char *propname = data;
|
||||
int ret;
|
||||
zfs_prop_t prop = zfs_name_to_prop(propname);
|
||||
|
||||
ret = zfs_prop_inherit(zhp, propname);
|
||||
return (ret != 0);
|
||||
/*
|
||||
* If we're doing it recursively, then ignore properties that
|
||||
* are not valid for this type of dataset.
|
||||
*/
|
||||
if (prop != ZPROP_INVAL &&
|
||||
!zfs_prop_valid_for_type(prop, zfs_get_type(zhp)))
|
||||
return (0);
|
||||
|
||||
return (zfs_prop_inherit(zhp, propname) != 0);
|
||||
}
|
||||
|
||||
static int
|
||||
inherit_cb(zfs_handle_t *zhp, void *data)
|
||||
{
|
||||
char *propname = data;
|
||||
|
||||
return (zfs_prop_inherit(zhp, propname) != 0);
|
||||
}
|
||||
|
||||
static int
|
||||
zfs_do_inherit(int argc, char **argv)
|
||||
{
|
||||
boolean_t recurse = B_FALSE;
|
||||
int c;
|
||||
zfs_prop_t prop;
|
||||
char *propname;
|
||||
int ret;
|
||||
int flags = 0;
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, "r")) != -1) {
|
||||
switch (c) {
|
||||
case 'r':
|
||||
recurse = B_TRUE;
|
||||
flags |= ZFS_ITER_RECURSE;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
@@ -1329,9 +1368,13 @@ zfs_do_inherit(int argc, char **argv)
|
||||
usage(B_FALSE);
|
||||
}
|
||||
|
||||
ret = zfs_for_each(argc, argv, recurse,
|
||||
ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, NULL, NULL,
|
||||
inherit_callback, propname, B_FALSE);
|
||||
if (flags & ZFS_ITER_RECURSE) {
|
||||
ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET,
|
||||
NULL, NULL, inherit_recurse_cb, propname);
|
||||
} else {
|
||||
ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET,
|
||||
NULL, NULL, inherit_cb, propname);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
@@ -1455,18 +1498,18 @@ upgrade_set_callback(zfs_handle_t *zhp, void *data)
|
||||
static int
|
||||
zfs_do_upgrade(int argc, char **argv)
|
||||
{
|
||||
boolean_t recurse = B_FALSE;
|
||||
boolean_t all = B_FALSE;
|
||||
boolean_t showversions = B_FALSE;
|
||||
int ret;
|
||||
upgrade_cbdata_t cb = { 0 };
|
||||
char c;
|
||||
int flags = ZFS_ITER_ARGS_CAN_BE_PATHS;
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, "rvV:a")) != -1) {
|
||||
switch (c) {
|
||||
case 'r':
|
||||
recurse = B_TRUE;
|
||||
flags |= ZFS_ITER_RECURSE;
|
||||
break;
|
||||
case 'v':
|
||||
showversions = B_TRUE;
|
||||
@@ -1493,9 +1536,10 @@ zfs_do_upgrade(int argc, char **argv)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if ((!all && !argc) && (recurse | cb.cb_version))
|
||||
if ((!all && !argc) && ((flags & ZFS_ITER_RECURSE) | cb.cb_version))
|
||||
usage(B_FALSE);
|
||||
if (showversions && (recurse || all || cb.cb_version || argc))
|
||||
if (showversions && (flags & ZFS_ITER_RECURSE || all ||
|
||||
cb.cb_version || argc))
|
||||
usage(B_FALSE);
|
||||
if ((all || argc) && (showversions))
|
||||
usage(B_FALSE);
|
||||
@@ -1523,8 +1567,8 @@ zfs_do_upgrade(int argc, char **argv)
|
||||
/* Upgrade filesystems */
|
||||
if (cb.cb_version == 0)
|
||||
cb.cb_version = ZPL_VERSION;
|
||||
ret = zfs_for_each(argc, argv, recurse, ZFS_TYPE_FILESYSTEM,
|
||||
NULL, NULL, upgrade_set_callback, &cb, B_TRUE);
|
||||
ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_FILESYSTEM,
|
||||
NULL, NULL, upgrade_set_callback, &cb);
|
||||
(void) printf(gettext("%llu filesystems upgraded\n"),
|
||||
cb.cb_numupgraded);
|
||||
if (cb.cb_numsamegraded) {
|
||||
@@ -1540,15 +1584,16 @@ zfs_do_upgrade(int argc, char **argv)
|
||||
(void) printf(gettext("This system is currently running "
|
||||
"ZFS filesystem version %llu.\n\n"), ZPL_VERSION);
|
||||
|
||||
ret = zfs_for_each(0, NULL, B_TRUE, ZFS_TYPE_FILESYSTEM,
|
||||
NULL, NULL, upgrade_list_callback, &cb, B_TRUE);
|
||||
flags |= ZFS_ITER_RECURSE;
|
||||
ret = zfs_for_each(0, NULL, flags, ZFS_TYPE_FILESYSTEM,
|
||||
NULL, NULL, upgrade_list_callback, &cb);
|
||||
|
||||
found = cb.cb_foundone;
|
||||
cb.cb_foundone = B_FALSE;
|
||||
cb.cb_newer = B_TRUE;
|
||||
|
||||
ret = zfs_for_each(0, NULL, B_TRUE, ZFS_TYPE_FILESYSTEM,
|
||||
NULL, NULL, upgrade_list_callback, &cb, B_TRUE);
|
||||
ret = zfs_for_each(0, NULL, flags, ZFS_TYPE_FILESYSTEM,
|
||||
NULL, NULL, upgrade_list_callback, &cb);
|
||||
|
||||
if (!cb.cb_foundone && !found) {
|
||||
(void) printf(gettext("All filesystems are "
|
||||
@@ -1706,18 +1751,17 @@ static int
|
||||
zfs_do_list(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
boolean_t recurse = B_FALSE;
|
||||
boolean_t scripted = B_FALSE;
|
||||
static char default_fields[] =
|
||||
"name,used,available,referenced,mountpoint";
|
||||
int types = ZFS_TYPE_DATASET;
|
||||
int types = ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME;
|
||||
boolean_t types_specified = B_FALSE;
|
||||
char *fields = NULL;
|
||||
char *basic_fields = default_fields;
|
||||
list_cbdata_t cb = { 0 };
|
||||
char *value;
|
||||
int ret;
|
||||
char *type_subopts[] = { "filesystem", "volume", "snapshot", NULL };
|
||||
zfs_sort_column_t *sortcol = NULL;
|
||||
int flags = ZFS_ITER_PROP_LISTSNAPS | ZFS_ITER_ARGS_CAN_BE_PATHS;
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, ":o:rt:Hs:S:")) != -1) {
|
||||
@@ -1726,7 +1770,7 @@ zfs_do_list(int argc, char **argv)
|
||||
fields = optarg;
|
||||
break;
|
||||
case 'r':
|
||||
recurse = B_TRUE;
|
||||
flags |= ZFS_ITER_RECURSE;
|
||||
break;
|
||||
case 'H':
|
||||
scripted = B_TRUE;
|
||||
@@ -1749,7 +1793,12 @@ zfs_do_list(int argc, char **argv)
|
||||
break;
|
||||
case 't':
|
||||
types = 0;
|
||||
types_specified = B_TRUE;
|
||||
flags &= ~ZFS_ITER_PROP_LISTSNAPS;
|
||||
while (*optarg != '\0') {
|
||||
static char *type_subopts[] = { "filesystem",
|
||||
"volume", "snapshot", "all", NULL };
|
||||
|
||||
switch (getsubopt(&optarg, type_subopts,
|
||||
&value)) {
|
||||
case 0:
|
||||
@@ -1761,6 +1810,10 @@ zfs_do_list(int argc, char **argv)
|
||||
case 2:
|
||||
types |= ZFS_TYPE_SNAPSHOT;
|
||||
break;
|
||||
case 3:
|
||||
types = ZFS_TYPE_DATASET;
|
||||
break;
|
||||
|
||||
default:
|
||||
(void) fprintf(stderr,
|
||||
gettext("invalid type '%s'\n"),
|
||||
@@ -1785,7 +1838,13 @@ zfs_do_list(int argc, char **argv)
|
||||
argv += optind;
|
||||
|
||||
if (fields == NULL)
|
||||
fields = basic_fields;
|
||||
fields = default_fields;
|
||||
|
||||
/*
|
||||
* If "-o space" and no types were specified, don't display snapshots.
|
||||
*/
|
||||
if (strcmp(fields, "space") == 0 && types_specified == B_FALSE)
|
||||
types &= ~ZFS_TYPE_SNAPSHOT;
|
||||
|
||||
/*
|
||||
* If the user specifies '-o all', the zprop_get_list() doesn't
|
||||
@@ -1799,8 +1858,8 @@ zfs_do_list(int argc, char **argv)
|
||||
cb.cb_scripted = scripted;
|
||||
cb.cb_first = B_TRUE;
|
||||
|
||||
ret = zfs_for_each(argc, argv, recurse, types, sortcol, &cb.cb_proplist,
|
||||
list_callback, &cb, B_TRUE);
|
||||
ret = zfs_for_each(argc, argv, flags, types, sortcol, &cb.cb_proplist,
|
||||
list_callback, &cb);
|
||||
|
||||
zprop_free_list(cb.cb_proplist);
|
||||
zfs_free_sort_columns(sortcol);
|
||||
@@ -2166,7 +2225,8 @@ zfs_do_set(int argc, char **argv)
|
||||
|
||||
/* validate property=value argument */
|
||||
cb.cb_propname = argv[1];
|
||||
if ((cb.cb_value = strchr(cb.cb_propname, '=')) == NULL) {
|
||||
if (((cb.cb_value = strchr(cb.cb_propname, '=')) == NULL) ||
|
||||
(cb.cb_value[1] == '\0')) {
|
||||
(void) fprintf(stderr, gettext("missing value in "
|
||||
"property=value argument\n"));
|
||||
usage(B_FALSE);
|
||||
@@ -2181,15 +2241,14 @@ zfs_do_set(int argc, char **argv)
|
||||
usage(B_FALSE);
|
||||
}
|
||||
|
||||
|
||||
ret = zfs_for_each(argc - 2, argv + 2, B_FALSE,
|
||||
ZFS_TYPE_DATASET, NULL, NULL, set_callback, &cb, B_FALSE);
|
||||
ret = zfs_for_each(argc - 2, argv + 2, NULL,
|
||||
ZFS_TYPE_DATASET, NULL, NULL, set_callback, &cb);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* zfs snapshot [-r] <fs@snap>
|
||||
* zfs snapshot [-r] [-o prop=value] ... <fs@snap>
|
||||
*
|
||||
* Creates a snapshot with the given name. While functionally equivalent to
|
||||
* 'zfs create', it is a separate command to differentiate intent.
|
||||
@@ -2200,17 +2259,28 @@ zfs_do_snapshot(int argc, char **argv)
|
||||
boolean_t recursive = B_FALSE;
|
||||
int ret;
|
||||
char c;
|
||||
nvlist_t *props;
|
||||
|
||||
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) {
|
||||
(void) fprintf(stderr, gettext("internal error: "
|
||||
"out of memory\n"));
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, ":r")) != -1) {
|
||||
while ((c = getopt(argc, argv, "ro:")) != -1) {
|
||||
switch (c) {
|
||||
case 'o':
|
||||
if (parseprop(props))
|
||||
return (1);
|
||||
break;
|
||||
case 'r':
|
||||
recursive = B_TRUE;
|
||||
break;
|
||||
case '?':
|
||||
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
|
||||
optopt);
|
||||
usage(B_FALSE);
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2220,17 +2290,23 @@ zfs_do_snapshot(int argc, char **argv)
|
||||
/* check number of arguments */
|
||||
if (argc < 1) {
|
||||
(void) fprintf(stderr, gettext("missing snapshot argument\n"));
|
||||
usage(B_FALSE);
|
||||
goto usage;
|
||||
}
|
||||
if (argc > 1) {
|
||||
(void) fprintf(stderr, gettext("too many arguments\n"));
|
||||
usage(B_FALSE);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
ret = zfs_snapshot(g_zfs, argv[0], recursive);
|
||||
ret = zfs_snapshot(g_zfs, argv[0], recursive, props);
|
||||
nvlist_free(props);
|
||||
if (ret && recursive)
|
||||
(void) fprintf(stderr, gettext("no snapshots were created\n"));
|
||||
return (ret != 0);
|
||||
|
||||
usage:
|
||||
nvlist_free(props);
|
||||
usage(B_FALSE);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2787,14 +2863,17 @@ zfs_do_unallow(int argc, char **argv)
|
||||
char *ds;
|
||||
int error;
|
||||
nvlist_t *zperms = NULL;
|
||||
int flags = 0;
|
||||
|
||||
if (parse_allow_args(&argc, &argv, B_TRUE,
|
||||
&ds, &recurse, &zperms) == -1)
|
||||
return (1);
|
||||
|
||||
error = zfs_for_each(argc, argv, recurse,
|
||||
if (recurse)
|
||||
flags |= ZFS_ITER_RECURSE;
|
||||
error = zfs_for_each(argc, argv, flags,
|
||||
ZFS_TYPE_FILESYSTEM|ZFS_TYPE_VOLUME, NULL,
|
||||
NULL, unallow_callback, (void *)zperms, B_FALSE);
|
||||
NULL, unallow_callback, (void *)zperms);
|
||||
|
||||
if (zperms)
|
||||
nvlist_free(zperms);
|
||||
@@ -3466,8 +3545,17 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
|
||||
ZFS_TYPE_FILESYSTEM)) == NULL)
|
||||
return (1);
|
||||
|
||||
|
||||
ret = 1;
|
||||
if (stat64(entry.mnt_mountp, &statbuf) != 0) {
|
||||
(void) fprintf(stderr, gettext("cannot %s '%s': %s\n"),
|
||||
cmdname, path, strerror(errno));
|
||||
goto out;
|
||||
} else if (statbuf.st_ino != path_inode) {
|
||||
(void) fprintf(stderr, gettext("cannot "
|
||||
"%s '%s': not a mountpoint\n"), cmdname, path);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (op == OP_SHARE) {
|
||||
char nfs_mnt_prop[ZFS_MAXPROPLEN];
|
||||
char smbshare_prop[ZFS_MAXPROPLEN];
|
||||
@@ -3495,13 +3583,7 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
|
||||
verify(zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mtpt_prop,
|
||||
sizeof (mtpt_prop), NULL, NULL, 0, B_FALSE) == 0);
|
||||
|
||||
if (stat64(entry.mnt_mountp, &statbuf) != 0) {
|
||||
(void) fprintf(stderr, gettext("cannot %s '%s': %s\n"),
|
||||
cmdname, path, strerror(errno));
|
||||
} else if (statbuf.st_ino != path_inode) {
|
||||
(void) fprintf(stderr, gettext("cannot "
|
||||
"unmount '%s': not a mountpoint\n"), path);
|
||||
} else if (is_manual) {
|
||||
if (is_manual) {
|
||||
ret = zfs_unmount(zhp, NULL, flags);
|
||||
} else if (strcmp(mtpt_prop, "legacy") == 0) {
|
||||
(void) fprintf(stderr, gettext("cannot unmount "
|
||||
@@ -3514,6 +3596,7 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
zfs_close(zhp);
|
||||
|
||||
return (ret != 0);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#ifndef _ZFS_UTIL_H
|
||||
#define _ZFS_UTIL_H
|
||||
|
||||
#pragma ident "@(#)zfs_util.h 1.2 06/05/24 SMI"
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#include <libzfs.h>
|
||||
|
||||
|
||||
@@ -19,12 +19,10 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)translate.c 1.3 07/11/09 SMI"
|
||||
|
||||
#include <libzfs.h>
|
||||
|
||||
#undef verify /* both libzfs.h and zfs_context.h want to define this */
|
||||
@@ -47,6 +45,7 @@
|
||||
#include <sys/dmu.h>
|
||||
#include <sys/dmu_objset.h>
|
||||
#include <sys/dnode.h>
|
||||
#include <sys/vdev_impl.h>
|
||||
|
||||
#include <sys/mkdev.h>
|
||||
|
||||
@@ -164,7 +163,7 @@ object_from_path(const char *dataset, const char *path, struct stat64 *statbuf,
|
||||
sync();
|
||||
|
||||
if ((err = dmu_objset_open(dataset, DMU_OST_ZFS,
|
||||
DS_MODE_STANDARD | DS_MODE_READONLY, &os)) != 0) {
|
||||
DS_MODE_USER | DS_MODE_READONLY, &os)) != 0) {
|
||||
(void) fprintf(stderr, "cannot open dataset '%s': %s\n",
|
||||
dataset, strerror(err));
|
||||
return (-1);
|
||||
@@ -249,7 +248,7 @@ calculate_range(const char *dataset, err_type_t type, int level, char *range,
|
||||
* size.
|
||||
*/
|
||||
if ((err = dmu_objset_open(dataset, DMU_OST_ANY,
|
||||
DS_MODE_STANDARD | DS_MODE_READONLY, &os)) != 0) {
|
||||
DS_MODE_USER | DS_MODE_READONLY, &os)) != 0) {
|
||||
(void) fprintf(stderr, "cannot open dataset '%s': %s\n",
|
||||
dataset, strerror(err));
|
||||
goto out;
|
||||
@@ -432,7 +431,8 @@ translate_raw(const char *str, zinject_record_t *record)
|
||||
}
|
||||
|
||||
int
|
||||
translate_device(const char *pool, const char *device, zinject_record_t *record)
|
||||
translate_device(const char *pool, const char *device, err_type_t label_type,
|
||||
zinject_record_t *record)
|
||||
{
|
||||
char *end;
|
||||
zpool_handle_t *zhp;
|
||||
@@ -448,7 +448,7 @@ translate_device(const char *pool, const char *device, zinject_record_t *record)
|
||||
|
||||
record->zi_guid = strtoull(device, &end, 16);
|
||||
if (record->zi_guid == 0 || *end != '\0') {
|
||||
tgt = zpool_find_vdev(zhp, device, &isspare, &iscache);
|
||||
tgt = zpool_find_vdev(zhp, device, &isspare, &iscache, NULL);
|
||||
|
||||
if (tgt == NULL) {
|
||||
(void) fprintf(stderr, "cannot find device '%s' in "
|
||||
@@ -460,5 +460,15 @@ translate_device(const char *pool, const char *device, zinject_record_t *record)
|
||||
&record->zi_guid) == 0);
|
||||
}
|
||||
|
||||
switch (label_type) {
|
||||
case TYPE_LABEL_UBERBLOCK:
|
||||
record->zi_start = offsetof(vdev_label_t, vl_uberblock[0]);
|
||||
record->zi_end = record->zi_start + VDEV_UBERBLOCK_RING - 1;
|
||||
break;
|
||||
case TYPE_LABEL_NVLIST:
|
||||
record->zi_start = offsetof(vdev_label_t, vl_vdev_phys);
|
||||
record->zi_end = record->zi_start + VDEV_PHYS_SIZE - 1;
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
+28
-11
@@ -19,11 +19,11 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zinject.c 1.4 07/09/17 SMI"
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
/*
|
||||
* ZFS Fault Injector
|
||||
@@ -38,15 +38,18 @@
|
||||
* Errors can be injected into a particular vdev using the '-d' option. This
|
||||
* option takes a path or vdev GUID to uniquely identify the device within a
|
||||
* pool. There are two types of errors that can be injected, EIO and ENXIO,
|
||||
* that can be controlled through the '-t' option. The default is ENXIO. For
|
||||
* that can be controlled through the '-e' option. The default is ENXIO. For
|
||||
* EIO failures, any attempt to read data from the device will return EIO, but
|
||||
* subsequent attempt to reopen the device will succeed. For ENXIO failures,
|
||||
* any attempt to read from the device will return EIO, but any attempt to
|
||||
* reopen the device will also return ENXIO.
|
||||
* For label faults, the -L option must be specified. This allows faults
|
||||
* to be injected into either the nvlist or uberblock region of all the labels
|
||||
* for the specified device.
|
||||
*
|
||||
* This form of the command looks like:
|
||||
*
|
||||
* zinject -d device [-t type] pool
|
||||
* zinject -d device [-e errno] [-L <uber | nvlist>] pool
|
||||
*
|
||||
*
|
||||
* DATA FAULTS
|
||||
@@ -165,7 +168,9 @@ static const char *errtable[TYPE_INVAL] = {
|
||||
"config",
|
||||
"bplist",
|
||||
"spacemap",
|
||||
"errlog"
|
||||
"errlog",
|
||||
"uber",
|
||||
"nvlist"
|
||||
};
|
||||
|
||||
static err_type_t
|
||||
@@ -219,9 +224,10 @@ usage(void)
|
||||
"\t\tClear the particular record (if given a numeric ID), or\n"
|
||||
"\t\tall records if 'all' is specificed.\n"
|
||||
"\n"
|
||||
"\tzinject -d device [-e errno] pool\n"
|
||||
"\t\tInject a fault into a particular device. 'errno' can either\n"
|
||||
"\t\tbe 'nxio' (the default) or 'io'.\n"
|
||||
"\tzinject -d device [-e errno] [-L <nvlist|uber>] pool\n"
|
||||
"\t\tInject a fault into a particular device or the device's\n"
|
||||
"\t\tlabel. Label injection can either be 'nvlist' or 'uber'.\n"
|
||||
"\t\t'errno' can either be 'nxio' (the default) or 'io'.\n"
|
||||
"\n"
|
||||
"\tzinject -b objset:object:level:blkid pool\n"
|
||||
"\n"
|
||||
@@ -474,6 +480,7 @@ main(int argc, char **argv)
|
||||
int error = 0;
|
||||
int domount = 0;
|
||||
err_type_t type = TYPE_INVAL;
|
||||
err_type_t label = TYPE_INVAL;
|
||||
zinject_record_t record = { 0 };
|
||||
char pool[MAXNAMELEN];
|
||||
char dataset[MAXNAMELEN];
|
||||
@@ -509,7 +516,7 @@ main(int argc, char **argv)
|
||||
return (0);
|
||||
}
|
||||
|
||||
while ((c = getopt(argc, argv, ":ab:d:f:qhc:t:l:mr:e:u")) != -1) {
|
||||
while ((c = getopt(argc, argv, ":ab:d:f:qhc:t:l:mr:e:uL:")) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
flags |= ZINJECT_FLUSH_ARC;
|
||||
@@ -568,7 +575,8 @@ main(int argc, char **argv)
|
||||
range = optarg;
|
||||
break;
|
||||
case 't':
|
||||
if ((type = name_to_type(optarg)) == TYPE_INVAL) {
|
||||
if ((type = name_to_type(optarg)) == TYPE_INVAL &&
|
||||
!MOS_TYPE(type)) {
|
||||
(void) fprintf(stderr, "invalid type '%s'\n",
|
||||
optarg);
|
||||
usage();
|
||||
@@ -578,6 +586,15 @@ main(int argc, char **argv)
|
||||
case 'u':
|
||||
flags |= ZINJECT_UNLOAD_SPA;
|
||||
break;
|
||||
case 'L':
|
||||
if ((label = name_to_type(optarg)) == TYPE_INVAL &&
|
||||
!LABEL_TYPE(type)) {
|
||||
(void) fprintf(stderr, "invalid label type "
|
||||
"'%s'\n", optarg);
|
||||
usage();
|
||||
return (1);
|
||||
}
|
||||
break;
|
||||
case ':':
|
||||
(void) fprintf(stderr, "option -%c requires an "
|
||||
"operand\n", optopt);
|
||||
@@ -654,7 +671,7 @@ main(int argc, char **argv)
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (translate_device(pool, device, &record) != 0)
|
||||
if (translate_device(pool, device, label, &record) != 0)
|
||||
return (1);
|
||||
if (!error)
|
||||
error = ENXIO;
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _ZINJECT_H
|
||||
#define _ZINJECT_H
|
||||
|
||||
#pragma ident "@(#)zinject.h 1.2 06/05/24 SMI"
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#include <sys/zfs_ioctl.h>
|
||||
|
||||
@@ -44,17 +44,22 @@ typedef enum {
|
||||
TYPE_BPLIST, /* block pointer list */
|
||||
TYPE_SPACEMAP, /* space map objects */
|
||||
TYPE_ERRLOG, /* persistent error log */
|
||||
TYPE_LABEL_UBERBLOCK, /* label specific uberblock */
|
||||
TYPE_LABEL_NVLIST, /* label specific nvlist */
|
||||
TYPE_INVAL
|
||||
} err_type_t;
|
||||
|
||||
#define MOS_TYPE(t) \
|
||||
((t) >= TYPE_MOS && (t) < TYPE_INVAL)
|
||||
((t) >= TYPE_MOS && (t) < TYPE_LABEL_UBERBLOCK)
|
||||
|
||||
#define LABEL_TYPE(t) \
|
||||
((t) >= TYPE_LABEL_UBERBLOCK && (t) < TYPE_INVAL)
|
||||
|
||||
int translate_record(err_type_t type, const char *object, const char *range,
|
||||
int level, zinject_record_t *record, char *poolname, char *dataset);
|
||||
int translate_raw(const char *raw, zinject_record_t *record);
|
||||
int translate_device(const char *pool, const char *device,
|
||||
zinject_record_t *record);
|
||||
err_type_t label_type, zinject_record_t *record);
|
||||
void usage(void);
|
||||
|
||||
extern libzfs_handle_t *g_zfs;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zpool_iter.c 1.5 07/09/17 SMI"
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#include <libintl.h>
|
||||
#include <libuutil.h>
|
||||
|
||||
+153
-53
@@ -24,8 +24,6 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zpool_main.c 1.54 08/02/13 SMI"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
@@ -86,6 +84,8 @@ static int zpool_do_set(int, char **);
|
||||
* These libumem hooks provide a reasonable set of defaults for the allocator's
|
||||
* debugging facilities.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
const char *
|
||||
_umem_debug_init(void)
|
||||
{
|
||||
@@ -97,6 +97,7 @@ _umem_logging_init(void)
|
||||
{
|
||||
return ("fail,contents"); /* $UMEM_LOGGING setting */
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
HELP_ADD,
|
||||
@@ -184,6 +185,7 @@ get_usage(zpool_help_t idx) {
|
||||
return (gettext("\tclear <pool> [device]\n"));
|
||||
case HELP_CREATE:
|
||||
return (gettext("\tcreate [-fn] [-o property=value] ... \n"
|
||||
"\t [-O file-system-property=value] ... \n"
|
||||
"\t [-m mountpoint] [-R root] <pool> <vdev> ...\n"));
|
||||
case HELP_DESTROY:
|
||||
return (gettext("\tdestroy [-f] <pool>\n"));
|
||||
@@ -348,11 +350,14 @@ print_vdev_tree(zpool_handle_t *zhp, const char *name, nvlist_t *nv, int indent,
|
||||
* Add a property pair (name, string-value) into a property nvlist.
|
||||
*/
|
||||
static int
|
||||
add_prop_list(const char *propname, char *propval, nvlist_t **props)
|
||||
add_prop_list(const char *propname, char *propval, nvlist_t **props,
|
||||
boolean_t poolprop)
|
||||
{
|
||||
char *strval;
|
||||
zpool_prop_t prop = ZPROP_INVAL;
|
||||
zfs_prop_t fprop;
|
||||
nvlist_t *proplist;
|
||||
zpool_prop_t prop;
|
||||
const char *normnm;
|
||||
char *strval;
|
||||
|
||||
if (*props == NULL &&
|
||||
nvlist_alloc(props, NV_UNIQUE_NAME, 0) != 0) {
|
||||
@@ -363,22 +368,30 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props)
|
||||
|
||||
proplist = *props;
|
||||
|
||||
if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL) {
|
||||
(void) fprintf(stderr, gettext("property '%s' is "
|
||||
"not a valid pool property\n"), propname);
|
||||
return (2);
|
||||
if (poolprop) {
|
||||
if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL) {
|
||||
(void) fprintf(stderr, gettext("property '%s' is "
|
||||
"not a valid pool property\n"), propname);
|
||||
return (2);
|
||||
}
|
||||
normnm = zpool_prop_to_name(prop);
|
||||
} else {
|
||||
if ((fprop = zfs_name_to_prop(propname)) == ZPROP_INVAL) {
|
||||
(void) fprintf(stderr, gettext("property '%s' is "
|
||||
"not a valid file system property\n"), propname);
|
||||
return (2);
|
||||
}
|
||||
normnm = zfs_prop_to_name(fprop);
|
||||
}
|
||||
|
||||
/* Use normalized property name for nvlist operations */
|
||||
if (nvlist_lookup_string(proplist, zpool_prop_to_name(prop),
|
||||
&strval) == 0 && prop != ZPOOL_PROP_CACHEFILE) {
|
||||
if (nvlist_lookup_string(proplist, normnm, &strval) == 0 &&
|
||||
prop != ZPOOL_PROP_CACHEFILE) {
|
||||
(void) fprintf(stderr, gettext("property '%s' "
|
||||
"specified multiple times\n"), propname);
|
||||
return (2);
|
||||
}
|
||||
|
||||
if (nvlist_add_string(proplist, zpool_prop_to_name(prop),
|
||||
propval) != 0) {
|
||||
if (nvlist_add_string(proplist, normnm, propval) != 0) {
|
||||
(void) fprintf(stderr, gettext("internal "
|
||||
"error: out of memory\n"));
|
||||
return (1);
|
||||
@@ -455,7 +468,8 @@ zpool_do_add(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* pass off to get_vdev_spec for processing */
|
||||
nvroot = make_root_vdev(zhp, force, !force, B_FALSE, argc, argv);
|
||||
nvroot = make_root_vdev(zhp, force, !force, B_FALSE, dryrun,
|
||||
argc, argv);
|
||||
if (nvroot == NULL) {
|
||||
zpool_close(zhp);
|
||||
return (1);
|
||||
@@ -534,8 +548,9 @@ zpool_do_remove(int argc, char **argv)
|
||||
}
|
||||
|
||||
/*
|
||||
* zpool create [-fn] [-o property=value] ... [-R root] [-m mountpoint]
|
||||
* <pool> <dev> ...
|
||||
* zpool create [-fn] [-o property=value] ...
|
||||
* [-O file-system-property=value] ...
|
||||
* [-R root] [-m mountpoint] <pool> <dev> ...
|
||||
*
|
||||
* -f Force creation, even if devices appear in use
|
||||
* -n Do not create the pool, but display the resulting layout if it
|
||||
@@ -544,6 +559,7 @@ zpool_do_remove(int argc, char **argv)
|
||||
* -m Set default mountpoint for the root dataset. By default it's
|
||||
* '/<pool>'
|
||||
* -o Set property=value.
|
||||
* -O Set fsproperty=value in the pool's root file system
|
||||
*
|
||||
* Creates the named pool according to the given vdev specification. The
|
||||
* bulk of the vdev processing is done in get_vdev_spec() in zpool_vdev.c. Once
|
||||
@@ -561,11 +577,12 @@ zpool_do_create(int argc, char **argv)
|
||||
int ret = 1;
|
||||
char *altroot = NULL;
|
||||
char *mountpoint = NULL;
|
||||
nvlist_t *fsprops = NULL;
|
||||
nvlist_t *props = NULL;
|
||||
char *propval;
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, ":fnR:m:o:")) != -1) {
|
||||
while ((c = getopt(argc, argv, ":fnR:m:o:O:")) != -1) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
force = B_TRUE;
|
||||
@@ -576,14 +593,14 @@ zpool_do_create(int argc, char **argv)
|
||||
case 'R':
|
||||
altroot = optarg;
|
||||
if (add_prop_list(zpool_prop_to_name(
|
||||
ZPOOL_PROP_ALTROOT), optarg, &props))
|
||||
ZPOOL_PROP_ALTROOT), optarg, &props, B_TRUE))
|
||||
goto errout;
|
||||
if (nvlist_lookup_string(props,
|
||||
zpool_prop_to_name(ZPOOL_PROP_CACHEFILE),
|
||||
&propval) == 0)
|
||||
break;
|
||||
if (add_prop_list(zpool_prop_to_name(
|
||||
ZPOOL_PROP_CACHEFILE), "none", &props))
|
||||
ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE))
|
||||
goto errout;
|
||||
break;
|
||||
case 'm':
|
||||
@@ -598,7 +615,19 @@ zpool_do_create(int argc, char **argv)
|
||||
*propval = '\0';
|
||||
propval++;
|
||||
|
||||
if (add_prop_list(optarg, propval, &props))
|
||||
if (add_prop_list(optarg, propval, &props, B_TRUE))
|
||||
goto errout;
|
||||
break;
|
||||
case 'O':
|
||||
if ((propval = strchr(optarg, '=')) == NULL) {
|
||||
(void) fprintf(stderr, gettext("missing "
|
||||
"'=' for -O option\n"));
|
||||
goto errout;
|
||||
}
|
||||
*propval = '\0';
|
||||
propval++;
|
||||
|
||||
if (add_prop_list(optarg, propval, &fsprops, B_FALSE))
|
||||
goto errout;
|
||||
break;
|
||||
case ':':
|
||||
@@ -640,10 +669,10 @@ zpool_do_create(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* pass off to get_vdev_spec for bulk processing */
|
||||
nvroot = make_root_vdev(NULL, force, !force, B_FALSE, argc - 1,
|
||||
argv + 1);
|
||||
nvroot = make_root_vdev(NULL, force, !force, B_FALSE, dryrun,
|
||||
argc - 1, argv + 1);
|
||||
if (nvroot == NULL)
|
||||
return (1);
|
||||
goto errout;
|
||||
|
||||
/* make_root_vdev() allows 0 toplevel children if there are spares */
|
||||
if (!zfs_allocatable_devs(nvroot)) {
|
||||
@@ -735,7 +764,8 @@ zpool_do_create(int argc, char **argv)
|
||||
/*
|
||||
* Hand off to libzfs.
|
||||
*/
|
||||
if (zpool_create(g_zfs, poolname, nvroot, props) == 0) {
|
||||
if (zpool_create(g_zfs, poolname,
|
||||
nvroot, props, fsprops) == 0) {
|
||||
zfs_handle_t *pool = zfs_open(g_zfs, poolname,
|
||||
ZFS_TYPE_FILESYSTEM);
|
||||
if (pool != NULL) {
|
||||
@@ -756,9 +786,11 @@ zpool_do_create(int argc, char **argv)
|
||||
|
||||
errout:
|
||||
nvlist_free(nvroot);
|
||||
nvlist_free(fsprops);
|
||||
nvlist_free(props);
|
||||
return (ret);
|
||||
badusage:
|
||||
nvlist_free(fsprops);
|
||||
nvlist_free(props);
|
||||
usage(B_FALSE);
|
||||
return (2);
|
||||
@@ -885,7 +917,7 @@ zpool_do_export(int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (zpool_export(zhp) != 0)
|
||||
if (zpool_export(zhp, force) != 0)
|
||||
ret = 1;
|
||||
|
||||
zpool_close(zhp);
|
||||
@@ -1109,16 +1141,23 @@ show_import(nvlist_t *config)
|
||||
(void) printf(gettext("status: The pool is formatted using an "
|
||||
"incompatible version.\n"));
|
||||
break;
|
||||
|
||||
case ZPOOL_STATUS_HOSTID_MISMATCH:
|
||||
(void) printf(gettext("status: The pool was last accessed by "
|
||||
"another system.\n"));
|
||||
break;
|
||||
|
||||
case ZPOOL_STATUS_FAULTED_DEV_R:
|
||||
case ZPOOL_STATUS_FAULTED_DEV_NR:
|
||||
(void) printf(gettext("status: One or more devices are "
|
||||
"faulted.\n"));
|
||||
break;
|
||||
|
||||
case ZPOOL_STATUS_BAD_LOG:
|
||||
(void) printf(gettext("status: An intent log record cannot be "
|
||||
"read.\n"));
|
||||
break;
|
||||
|
||||
default:
|
||||
/*
|
||||
* No other status can be seen when importing pools.
|
||||
@@ -1214,7 +1253,7 @@ show_import(nvlist_t *config)
|
||||
*/
|
||||
static int
|
||||
do_import(nvlist_t *config, const char *newname, const char *mntopts,
|
||||
int force, nvlist_t *props)
|
||||
int force, nvlist_t *props, boolean_t allowfaulted)
|
||||
{
|
||||
zpool_handle_t *zhp;
|
||||
char *name;
|
||||
@@ -1267,13 +1306,14 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
|
||||
}
|
||||
}
|
||||
|
||||
if (zpool_import_props(g_zfs, config, newname, props) != 0)
|
||||
if (zpool_import_props(g_zfs, config, newname, props,
|
||||
allowfaulted) != 0)
|
||||
return (1);
|
||||
|
||||
if (newname != NULL)
|
||||
name = (char *)newname;
|
||||
|
||||
verify((zhp = zpool_open(g_zfs, name)) != NULL);
|
||||
verify((zhp = zpool_open_canfail(g_zfs, name)) != NULL);
|
||||
|
||||
if (zpool_enable_datasets(zhp, mntopts, 0) != 0) {
|
||||
zpool_close(zhp);
|
||||
@@ -1306,6 +1346,11 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
|
||||
*
|
||||
* -f Force import, even if it appears that the pool is active.
|
||||
*
|
||||
* -F Import even in the presence of faulted vdevs. This is an
|
||||
* intentionally undocumented option for testing purposes, and
|
||||
* treats the pool configuration as complete, leaving any bad
|
||||
* vdevs in the FAULTED state.
|
||||
*
|
||||
* -a Import all pools found.
|
||||
*
|
||||
* -o Set property=value and/or temporary mount options (without '=').
|
||||
@@ -1327,17 +1372,18 @@ zpool_do_import(int argc, char **argv)
|
||||
boolean_t do_force = B_FALSE;
|
||||
nvpair_t *elem;
|
||||
nvlist_t *config;
|
||||
uint64_t searchguid;
|
||||
char *searchname;
|
||||
uint64_t searchguid = 0;
|
||||
char *searchname = NULL;
|
||||
char *propval;
|
||||
nvlist_t *found_config;
|
||||
nvlist_t *props = NULL;
|
||||
boolean_t first;
|
||||
boolean_t allow_faulted = B_FALSE;
|
||||
uint64_t pool_state;
|
||||
char *cachefile = NULL;
|
||||
|
||||
/* check options */
|
||||
while ((c = getopt(argc, argv, ":afc:d:Do:p:R:")) != -1) {
|
||||
while ((c = getopt(argc, argv, ":ac:d:DfFo:p:R:")) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
do_all = B_TRUE;
|
||||
@@ -1364,11 +1410,15 @@ zpool_do_import(int argc, char **argv)
|
||||
case 'f':
|
||||
do_force = B_TRUE;
|
||||
break;
|
||||
case 'F':
|
||||
allow_faulted = B_TRUE;
|
||||
break;
|
||||
case 'o':
|
||||
if ((propval = strchr(optarg, '=')) != NULL) {
|
||||
*propval = '\0';
|
||||
propval++;
|
||||
if (add_prop_list(optarg, propval, &props))
|
||||
if (add_prop_list(optarg, propval,
|
||||
&props, B_TRUE))
|
||||
goto error;
|
||||
} else {
|
||||
mntopts = optarg;
|
||||
@@ -1376,14 +1426,14 @@ zpool_do_import(int argc, char **argv)
|
||||
break;
|
||||
case 'R':
|
||||
if (add_prop_list(zpool_prop_to_name(
|
||||
ZPOOL_PROP_ALTROOT), optarg, &props))
|
||||
ZPOOL_PROP_ALTROOT), optarg, &props, B_TRUE))
|
||||
goto error;
|
||||
if (nvlist_lookup_string(props,
|
||||
zpool_prop_to_name(ZPOOL_PROP_CACHEFILE),
|
||||
&propval) == 0)
|
||||
break;
|
||||
if (add_prop_list(zpool_prop_to_name(
|
||||
ZPOOL_PROP_CACHEFILE), "none", &props))
|
||||
ZPOOL_PROP_CACHEFILE), "none", &props, B_TRUE))
|
||||
goto error;
|
||||
break;
|
||||
case ':':
|
||||
@@ -1437,18 +1487,7 @@ zpool_do_import(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (cachefile)
|
||||
pools = zpool_find_import_cached(g_zfs, cachefile, B_FALSE);
|
||||
else
|
||||
pools = zpool_find_import(g_zfs, nsearch, searchdirs, B_FALSE);
|
||||
|
||||
if (pools == NULL) {
|
||||
free(searchdirs);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* We now have a list of all available pools in the given directories.
|
||||
* Depending on the arguments given, we do one of the following:
|
||||
*
|
||||
* <none> Iterate through all pools and display information about
|
||||
@@ -1468,11 +1507,38 @@ zpool_do_import(int argc, char **argv)
|
||||
searchguid = strtoull(argv[0], &endptr, 10);
|
||||
if (errno != 0 || *endptr != '\0')
|
||||
searchname = argv[0];
|
||||
else
|
||||
searchname = NULL;
|
||||
found_config = NULL;
|
||||
}
|
||||
|
||||
if (cachefile) {
|
||||
pools = zpool_find_import_cached(g_zfs, cachefile, searchname,
|
||||
searchguid);
|
||||
} else if (searchname != NULL) {
|
||||
pools = zpool_find_import_byname(g_zfs, nsearch, searchdirs,
|
||||
searchname);
|
||||
} else {
|
||||
/*
|
||||
* It's OK to search by guid even if searchguid is 0.
|
||||
*/
|
||||
pools = zpool_find_import_byguid(g_zfs, nsearch, searchdirs,
|
||||
searchguid);
|
||||
}
|
||||
|
||||
if (pools == NULL) {
|
||||
if (argc != 0) {
|
||||
(void) fprintf(stderr, gettext("cannot import '%s': "
|
||||
"no such pool available\n"), argv[0]);
|
||||
}
|
||||
free(searchdirs);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point we have a list of import candidate configs. Even if
|
||||
* we were searching by pool name or guid, we still need to
|
||||
* post-process the list to deal with pool state and possible
|
||||
* duplicate names.
|
||||
*/
|
||||
err = 0;
|
||||
elem = NULL;
|
||||
first = B_TRUE;
|
||||
@@ -1495,7 +1561,7 @@ zpool_do_import(int argc, char **argv)
|
||||
|
||||
if (do_all)
|
||||
err |= do_import(config, NULL, mntopts,
|
||||
do_force, props);
|
||||
do_force, props, allow_faulted);
|
||||
else
|
||||
show_import(config);
|
||||
} else if (searchname != NULL) {
|
||||
@@ -1543,7 +1609,7 @@ zpool_do_import(int argc, char **argv)
|
||||
err = B_TRUE;
|
||||
} else {
|
||||
err |= do_import(found_config, argc == 1 ? NULL :
|
||||
argv[1], mntopts, do_force, props);
|
||||
argv[1], mntopts, do_force, props, allow_faulted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2238,7 +2304,8 @@ zpool_do_attach_or_replace(int argc, char **argv, int replacing)
|
||||
return (1);
|
||||
}
|
||||
|
||||
nvroot = make_root_vdev(zhp, force, B_FALSE, replacing, argc, argv);
|
||||
nvroot = make_root_vdev(zhp, force, B_FALSE, replacing, B_FALSE,
|
||||
argc, argv);
|
||||
if (nvroot == NULL) {
|
||||
zpool_close(zhp);
|
||||
return (1);
|
||||
@@ -2493,7 +2560,7 @@ zpool_do_clear(int argc, char **argv)
|
||||
pool = argv[1];
|
||||
device = argc == 3 ? argv[2] : NULL;
|
||||
|
||||
if ((zhp = zpool_open(g_zfs, pool)) == NULL)
|
||||
if ((zhp = zpool_open_canfail(g_zfs, pool)) == NULL)
|
||||
return (1);
|
||||
|
||||
if (zpool_clear(zhp, device) != 0)
|
||||
@@ -2776,6 +2843,14 @@ print_status_config(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
||||
(void) printf(gettext("too many errors"));
|
||||
break;
|
||||
|
||||
case VDEV_AUX_IO_FAILURE:
|
||||
(void) printf(gettext("experienced I/O failures"));
|
||||
break;
|
||||
|
||||
case VDEV_AUX_BAD_LOG:
|
||||
(void) printf(gettext("bad intent log"));
|
||||
break;
|
||||
|
||||
default:
|
||||
(void) printf(gettext("corrupted data"));
|
||||
break;
|
||||
@@ -3058,6 +3133,25 @@ status_callback(zpool_handle_t *zhp, void *data)
|
||||
"to be recovered.\n"));
|
||||
break;
|
||||
|
||||
case ZPOOL_STATUS_IO_FAILURE_WAIT:
|
||||
case ZPOOL_STATUS_IO_FAILURE_CONTINUE:
|
||||
(void) printf(gettext("status: One or more devices are "
|
||||
"faulted in response to IO failures.\n"));
|
||||
(void) printf(gettext("action: Make sure the affected devices "
|
||||
"are connected, then run 'zpool clear'.\n"));
|
||||
break;
|
||||
|
||||
case ZPOOL_STATUS_BAD_LOG:
|
||||
(void) printf(gettext("status: An intent log record "
|
||||
"could not be read.\n"
|
||||
"\tWaiting for adminstrator intervention to fix the "
|
||||
"faulted pool.\n"));
|
||||
(void) printf(gettext("action: Either restore the affected "
|
||||
"device(s) and run 'zpool online',\n"
|
||||
"\tor ignore the intent log records by running "
|
||||
"'zpool clear'.\n"));
|
||||
break;
|
||||
|
||||
default:
|
||||
/*
|
||||
* The remaining errors can't actually be generated, yet.
|
||||
@@ -3389,6 +3483,11 @@ zpool_do_upgrade(int argc, char **argv)
|
||||
(void) printf(gettext(" 9 refquota and refreservation "
|
||||
"properties\n"));
|
||||
(void) printf(gettext(" 10 Cache devices\n"));
|
||||
(void) printf(gettext(" 11 Improved scrub performance\n"));
|
||||
(void) printf(gettext(" 12 Snapshot properties\n"));
|
||||
(void) printf(gettext(" 13 snapused property\n"));
|
||||
(void) printf(gettext(" 14 passthrough-x aclinherit "
|
||||
"support\n"));
|
||||
(void) printf(gettext("For more information on a particular "
|
||||
"version, including supported releases, see:\n\n"));
|
||||
(void) printf("http://www.opensolaris.org/os/community/zfs/"
|
||||
@@ -3473,6 +3572,7 @@ char *hist_event_table[LOG_END] = {
|
||||
"filesystem version upgrade",
|
||||
"refquota set",
|
||||
"refreservation set",
|
||||
"pool scrub done",
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -3527,7 +3627,7 @@ get_history_one(zpool_handle_t *zhp, void *data)
|
||||
ZPOOL_HIST_TXG, &txg) == 0);
|
||||
verify(nvlist_lookup_string(records[i],
|
||||
ZPOOL_HIST_INT_STR, &pathstr) == 0);
|
||||
if (ievent > LOG_END)
|
||||
if (ievent >= LOG_END)
|
||||
continue;
|
||||
(void) snprintf(internalstr,
|
||||
sizeof (internalstr),
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zpool_util.c 1.5 07/06/21 SMI"
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#include <errno.h>
|
||||
#include <libgen.h>
|
||||
|
||||
@@ -19,15 +19,13 @@
|
||||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef ZPOOL_UTIL_H
|
||||
#define ZPOOL_UTIL_H
|
||||
|
||||
#pragma ident "@(#)zpool_util.h 1.11 07/09/17 SMI"
|
||||
|
||||
#include <libnvpair.h>
|
||||
#include <libzfs.h>
|
||||
|
||||
@@ -48,7 +46,7 @@ uint_t num_logs(nvlist_t *nv);
|
||||
*/
|
||||
|
||||
nvlist_t *make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
|
||||
boolean_t isreplace, int argc, char **argv);
|
||||
boolean_t isreplace, boolean_t dryrun, int argc, char **argv);
|
||||
|
||||
/*
|
||||
* Pool list functions
|
||||
|
||||
@@ -20,12 +20,10 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#pragma ident "@(#)zpool_vdev.c 1.15 07/11/09 SMI"
|
||||
|
||||
/*
|
||||
* Functions to convert between a list of vdevs and an nvlist representing the
|
||||
* configuration. Each entry in the list can be one of:
|
||||
@@ -1352,7 +1350,7 @@ construct_spec(int argc, char **argv)
|
||||
*/
|
||||
nvlist_t *
|
||||
make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
|
||||
boolean_t isreplacing, int argc, char **argv)
|
||||
boolean_t isreplacing, boolean_t dryrun, int argc, char **argv)
|
||||
{
|
||||
nvlist_t *newroot;
|
||||
nvlist_t *poolconfig = NULL;
|
||||
@@ -1394,7 +1392,7 @@ make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
|
||||
/*
|
||||
* Run through the vdev specification and label any whole disks found.
|
||||
*/
|
||||
if (make_disks(zhp, newroot) != 0) {
|
||||
if (!dryrun && make_disks(zhp, newroot) != 0) {
|
||||
nvlist_free(newroot);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
+392
-479
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user