]> granicus.if.org Git - zfs/commitdiff
OpenZFS 9193 - bootcfg -C doesn't work
authorPaul Dagnelie <pcd@delphix.com>
Thu, 23 Mar 2017 22:28:22 +0000 (15:28 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 22 Mar 2018 23:16:55 +0000 (16:16 -0700)
When given an empty string as a rootds value, bootcfg -C fails with
the error message 'could not set nextboot: '' is an invalid name'.
This should be allowed because it represents clearing the nextboot
configuration.

Authored by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Chris Williamson <chris.williamson@delphix.com>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Robert Mustacchi <rm@joyent.com>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/9193
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/504645d227
Closes #7230

lib/libzfs/libzfs_pool.c

index cd14f2836262c11e8e2afc0d5ffe2266bda65852..8a0931f90150fd766ed477523dae6c7a0dfbc1e0 100644 (file)
@@ -410,6 +410,8 @@ static boolean_t
 bootfs_name_valid(const char *pool, char *bootfs)
 {
        int len = strlen(pool);
+       if (bootfs[0] == '\0')
+               return (B_TRUE);
 
        if (!zfs_name_valid(bootfs, ZFS_TYPE_FILESYSTEM|ZFS_TYPE_SNAPSHOT))
                return (B_FALSE);
@@ -567,8 +569,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
                         * bootfs property value has to be a dataset name and
                         * the dataset has to be in the same pool as it sets to.
                         */
-                       if (strval[0] != '\0' && !bootfs_name_valid(poolname,
-                           strval)) {
+                       if (!bootfs_name_valid(poolname, strval)) {
                                zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "'%s' "
                                    "is an invalid name"), strval);
                                (void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf);