Print this page
1693 persistent 'comment' field for a zpool
        
@@ -233,10 +233,11 @@
                         (void) snprintf(buf, len, "%llu", intval);
                         break;
 
                 case ZPOOL_PROP_ALTROOT:
                 case ZPOOL_PROP_CACHEFILE:
+                case ZPOOL_PROP_COMMENT:
                         if (zhp->zpool_props != NULL ||
                             zpool_get_all_props(zhp) == 0) {
                                 (void) strlcpy(buf,
                                     zpool_get_prop_string(zhp, prop, &src),
                                     len);
@@ -382,11 +383,11 @@
         nvpair_t *elem;
         nvlist_t *retprops;
         zpool_prop_t prop;
         char *strval;
         uint64_t intval;
-        char *slash;
+        char *slash, *check;
         struct stat64 statbuf;
         zpool_handle_t *zhp;
         nvlist_t *nvroot;
 
         if (nvlist_alloc(&retprops, NV_UNIQUE_NAME, 0) != 0) {
@@ -541,10 +542,30 @@
                         }
 
                         *slash = '/';
                         break;
 
+                case ZPOOL_PROP_COMMENT:
+                        for (check = strval; *check != '\0'; check++) {
+                                if (!isprint(*check)) {
+                                        zfs_error_aux(hdl,
+                                            dgettext(TEXT_DOMAIN,
+                                            "comment may only have printable "
+                                            "characters"));
+                                        (void) zfs_error(hdl, EZFS_BADPROP,
+                                            errbuf);
+                                        goto error;
+                                }
+                        }
+                        if (strlen(strval) > ZPROP_MAX_COMMENT) {
+                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+                                    "comment must not exceed %d characters"),
+                                    ZPROP_MAX_COMMENT);
+                                (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
+                                goto error;
+                        }
+                        break;
                 case ZPOOL_PROP_READONLY:
                         if (!flags.import) {
                                 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
                                     "property '%s' can only be set at "
                                     "import time"), propname);