1162 "one or more devices is less than the "
1163 "minimum size (%s)"), buf);
1164 }
1165 return (zfs_error(hdl, EZFS_BADDEV, msg));
1166
1167 case ENOSPC:
1168 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1169 "one or more devices is out of space"));
1170 return (zfs_error(hdl, EZFS_BADDEV, msg));
1171
1172 case ENOTBLK:
1173 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1174 "cache device must be a disk or disk slice"));
1175 return (zfs_error(hdl, EZFS_BADDEV, msg));
1176
1177 default:
1178 return (zpool_standard_error(hdl, errno, msg));
1179 }
1180 }
1181
1182 /*
1183 * If this is an alternate root pool, then we automatically set the
1184 * mountpoint of the root dataset to be '/'.
1185 */
1186 if (nvlist_lookup_string(props, zpool_prop_to_name(ZPOOL_PROP_ALTROOT),
1187 &altroot) == 0) {
1188 zfs_handle_t *zhp;
1189
1190 verify((zhp = zfs_open(hdl, pool, ZFS_TYPE_DATASET)) != NULL);
1191 verify(zfs_prop_set(zhp, zfs_prop_to_name(ZFS_PROP_MOUNTPOINT),
1192 "/") == 0);
1193
1194 zfs_close(zhp);
1195 }
1196
1197 create_failed:
1198 zcmd_free_nvlists(&zc);
1199 nvlist_free(zc_props);
1200 nvlist_free(zc_fsprops);
1201 return (ret);
1202 }
1203
1204 /*
1205 * Destroy the given pool. It is up to the caller to ensure that there are no
1206 * datasets left in the pool.
1207 */
1208 int
1209 zpool_destroy(zpool_handle_t *zhp, const char *log_str)
1210 {
1211 zfs_cmd_t zc = { 0 };
1212 zfs_handle_t *zfp = NULL;
1213 libzfs_handle_t *hdl = zhp->zpool_hdl;
1214 char msg[1024];
1215
1216 if (zhp->zpool_state == POOL_STATE_ACTIVE &&
|
1162 "one or more devices is less than the "
1163 "minimum size (%s)"), buf);
1164 }
1165 return (zfs_error(hdl, EZFS_BADDEV, msg));
1166
1167 case ENOSPC:
1168 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1169 "one or more devices is out of space"));
1170 return (zfs_error(hdl, EZFS_BADDEV, msg));
1171
1172 case ENOTBLK:
1173 zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
1174 "cache device must be a disk or disk slice"));
1175 return (zfs_error(hdl, EZFS_BADDEV, msg));
1176
1177 default:
1178 return (zpool_standard_error(hdl, errno, msg));
1179 }
1180 }
1181
1182 create_failed:
1183 zcmd_free_nvlists(&zc);
1184 nvlist_free(zc_props);
1185 nvlist_free(zc_fsprops);
1186 return (ret);
1187 }
1188
1189 /*
1190 * Destroy the given pool. It is up to the caller to ensure that there are no
1191 * datasets left in the pool.
1192 */
1193 int
1194 zpool_destroy(zpool_handle_t *zhp, const char *log_str)
1195 {
1196 zfs_cmd_t zc = { 0 };
1197 zfs_handle_t *zfp = NULL;
1198 libzfs_handle_t *hdl = zhp->zpool_hdl;
1199 char msg[1024];
1200
1201 if (zhp->zpool_state == POOL_STATE_ACTIVE &&
|