Rebase master to b108
[zfs.git] / lib / libzfs / libzfs_pool.c
index 9cb5d76..75ecc54 100644 (file)
@@ -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));