On Tue, Sep 30, 2008 at 11:09:05PM -0700, Eric Schrock wrote:
> A better solution (one that wouldn't break backwards compatability)
> would be to add the '-p' option (parseable output) from 'zfs get' to the
> 'zfs list' command as well.

yes, that makes sense to me.

thanks for pointing the -p out in zfs get, it means i get get the
numbers i need on s10 without having to do crazy stuff to get a
custom zfs binary.

here's an updated diff that implements -p on zfs list. thanks to
james mcpherson for both fixing and testing this for me.

diff -r 4fa3bfcd83d7 -r dbe864e2cc70 usr/src/cmd/zfs/zfs_main.c
--- a/usr/src/cmd/zfs/zfs_main.c        Wed Oct 01 00:06:47 2008 -0700
+++ b/usr/src/cmd/zfs/zfs_main.c        Thu Oct 02 07:26:16 2008 +1000
@@ -1623,6 +1623,7 @@
  typedef struct list_cbdata {
        boolean_t       cb_first;
        boolean_t       cb_scripted;
+       boolean_t       cb_literal;
        zprop_list_t    *cb_proplist;
  } list_cbdata_t;

@@ -1672,7 +1673,8 @@
   * to the described layout.
   */
  static void
-print_dataset(zfs_handle_t *zhp, zprop_list_t *pl, boolean_t scripted)
+print_dataset(zfs_handle_t *zhp, zprop_list_t *pl, boolean_t scripted,
+    boolean_t literal)
  {
        boolean_t first = B_TRUE;
        char property[ZFS_MAXPROPLEN];
@@ -1695,7 +1697,7 @@
                right_justify = B_FALSE;
                if (pl->pl_prop != ZPROP_INVAL) {
                        if (zfs_prop_get(zhp, pl->pl_prop, property,
-                           sizeof (property), NULL, NULL, 0, B_FALSE) != 0)
+                           sizeof (property), NULL, NULL, 0, literal) != 0)
                                propstr = "-";
                        else
                                propstr = property;
@@ -1742,7 +1744,7 @@
                cbp->cb_first = B_FALSE;
        }

-       print_dataset(zhp, cbp->cb_proplist, cbp->cb_scripted);
+       print_dataset(zhp, cbp->cb_proplist, cbp->cb_scripted, cbp->cb_literal);

        return (0);
  }
@@ -1752,6 +1754,7 @@
  {
        int c;
        boolean_t scripted = B_FALSE;
+       boolean_t literal = B_FALSE;
        static char default_fields[] =
            "name,used,available,referenced,mountpoint";
        int types = ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME;
@@ -1764,10 +1767,13 @@
        int flags = ZFS_ITER_PROP_LISTSNAPS | ZFS_ITER_ARGS_CAN_BE_PATHS;

        /* check options */
-       while ((c = getopt(argc, argv, ":o:rt:Hs:S:")) != -1) {
+       while ((c = getopt(argc, argv, ":o:prt:Hs:S:")) != -1) {
                switch (c) {
                case 'o':
                        fields = optarg;
+                       break;
+               case 'p':
+                       literal = B_TRUE;
                        break;
                case 'r':
                        flags |= ZFS_ITER_RECURSE;
@@ -1855,6 +1861,7 @@
            != 0)
                usage(B_FALSE);

+       cb.cb_literal = literal;
        cb.cb_scripted = scripted;
        cb.cb_first = B_TRUE;

_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to