]> git.proxmox.com Git - mirror_zfs.git/blobdiff - cmd/zfs/zfs_main.c
Illumos #1948: zpool list should show more detailed pool info
[mirror_zfs.git] / cmd / zfs / zfs_main.c
index f5a43c145444ee4de76bfbcf379934e0776a2bf9..1cb2ac9587e95cdeba56179aa95c86e161939af7 100644 (file)
@@ -22,7 +22,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #include <assert.h>
@@ -218,7 +218,8 @@ get_usage(zfs_help_t idx)
                    "<filesystem|volume>@<snap>[%<snap>][,...]\n"));
        case HELP_GET:
                return (gettext("\tget [-rHp] [-d max] "
-                   "[-o \"all\" | field[,...]] [-s source[,...]]\n"
+                   "[-o \"all\" | field[,...]] [-t type[,...]] "
+                   "[-s source[,...]]\n"
                    "\t    <\"all\" | property[,...]> "
                    "[filesystem|volume|snapshot] ...\n"));
        case HELP_INHERIT:
@@ -242,9 +243,9 @@ get_usage(zfs_help_t idx)
                "snapshot>\n"
                "\treceive [-vnFu] [-d | -e] <filesystem>\n"));
        case HELP_RENAME:
-               return (gettext("\trename <filesystem|volume|snapshot> "
+               return (gettext("\trename [-f] <filesystem|volume|snapshot> "
                    "<filesystem|volume|snapshot>\n"
-                   "\trename -p <filesystem|volume> <filesystem|volume>\n"
+                   "\trename [-f] -p <filesystem|volume> <filesystem|volume>\n"
                    "\trename -r <snapshot> <snapshot>"));
        case HELP_ROLLBACK:
                return (gettext("\trollback [-rRf] <snapshot>\n"));
@@ -1065,7 +1066,7 @@ snapshot_to_nvl_cb(zfs_handle_t *zhp, void *arg)
        int err = 0;
 
        /* Check for clones. */
-       if (!cb->cb_doclones) {
+       if (!cb->cb_doclones && !cb->cb_defer_destroy) {
                cb->cb_target = zhp;
                cb->cb_first = B_TRUE;
                err = zfs_iter_dependents(zhp, B_TRUE,
@@ -1460,6 +1461,7 @@ zfs_do_get(int argc, char **argv)
 {
        zprop_get_cbdata_t cb = { 0 };
        int i, c, flags = ZFS_ITER_ARGS_CAN_BE_PATHS;
+       int types = ZFS_TYPE_DATASET;
        char *value, *fields;
        int ret = 0;
        int limit = 0;
@@ -1476,7 +1478,7 @@ zfs_do_get(int argc, char **argv)
        cb.cb_type = ZFS_TYPE_DATASET;
 
        /* check options */
-       while ((c = getopt(argc, argv, ":d:o:s:rHp")) != -1) {
+       while ((c = getopt(argc, argv, ":d:o:s:rt:Hp")) != -1) {
                switch (c) {
                case 'p':
                        cb.cb_literal = B_TRUE;
@@ -1594,6 +1596,37 @@ zfs_do_get(int argc, char **argv)
                        }
                        break;
 
+               case 't':
+                       types = 0;
+                       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:
+                                       types |= ZFS_TYPE_FILESYSTEM;
+                                       break;
+                               case 1:
+                                       types |= ZFS_TYPE_VOLUME;
+                                       break;
+                               case 2:
+                                       types |= ZFS_TYPE_SNAPSHOT;
+                                       break;
+                               case 3:
+                                       types = ZFS_TYPE_DATASET;
+                                       break;
+
+                               default:
+                                       (void) fprintf(stderr,
+                                           gettext("invalid type '%s'\n"),
+                                           value);
+                                       usage(B_FALSE);
+                               }
+                       }
+                       break;
+
                case '?':
                        (void) fprintf(stderr, gettext("invalid option '%c'\n"),
                            optopt);
@@ -1637,7 +1670,7 @@ zfs_do_get(int argc, char **argv)
        cb.cb_first = B_TRUE;
 
        /* run for each object */
-       ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET, NULL,
+       ret = zfs_for_each(argc, argv, flags, types, NULL,
            &cb.cb_proplist, limit, get_callback, &cb);
 
        if (cb.cb_proplist == &fake_name)
@@ -3036,8 +3069,8 @@ zfs_do_list(int argc, char **argv)
 }
 
 /*
- * zfs rename <fs | snap | vol> <fs | snap | vol>
- * zfs rename -p <fs | vol> <fs | vol>
+ * zfs rename [-f] <fs | snap | vol> <fs | snap | vol>
+ * zfs rename [-f] -p <fs | vol> <fs | vol>
  * zfs rename -r <snap> <snap>
  *
  * Renames the given dataset to another of the same type.
@@ -3053,9 +3086,10 @@ zfs_do_rename(int argc, char **argv)
        int ret = 0;
        boolean_t recurse = B_FALSE;
        boolean_t parents = B_FALSE;
+       boolean_t force_unmount = B_FALSE;
 
        /* check options */
-       while ((c = getopt(argc, argv, "pr")) != -1) {
+       while ((c = getopt(argc, argv, "prf")) != -1) {
                switch (c) {
                case 'p':
                        parents = B_TRUE;
@@ -3063,6 +3097,9 @@ zfs_do_rename(int argc, char **argv)
                case 'r':
                        recurse = B_TRUE;
                        break;
+               case 'f':
+                       force_unmount = B_TRUE;
+                       break;
                case '?':
                default:
                        (void) fprintf(stderr, gettext("invalid option '%c'\n"),
@@ -3113,7 +3150,7 @@ zfs_do_rename(int argc, char **argv)
                return (1);
        }
 
-       ret = (zfs_rename(zhp, argv[1], recurse) != 0);
+       ret = (zfs_rename(zhp, argv[1], recurse, force_unmount) != 0);
 
        zfs_close(zhp);
        return (ret);
@@ -4972,9 +5009,9 @@ zfs_do_allow_unallow_impl(int argc, char **argv, boolean_t un)
        parse_allow_args(argc, argv, un, &opts);
 
        /* try to open the dataset */
-       if ((zhp = zfs_open(g_zfs, opts.dataset, ZFS_TYPE_FILESYSTEM))
-           == NULL) {
-               (void) fprintf(stderr, "Failed to open Dataset *%s*\n",
+       if ((zhp = zfs_open(g_zfs, opts.dataset, ZFS_TYPE_FILESYSTEM |
+           ZFS_TYPE_VOLUME)) == NULL) {
+               (void) fprintf(stderr, "Failed to open dataset: %s\n",
                    opts.dataset);
                return (-1);
        }
@@ -4984,7 +5021,7 @@ zfs_do_allow_unallow_impl(int argc, char **argv, boolean_t un)
 
        fs_perm_set_init(&fs_perm_set);
        if (parse_fs_perm_set(&fs_perm_set, perm_nvl) != 0) {
-               (void) fprintf(stderr, "Failed to parse fsacl permissionsn");
+               (void) fprintf(stderr, "Failed to parse fsacl permissions\n");
                goto cleanup1;
        }