summaryrefslogtreecommitdiff
path: root/usr/src/lib/libzfs/common/libzfs_pool.c
diff options
context:
space:
mode:
authoreschrock <none@none>2006-04-08 23:33:38 -0700
committereschrock <none@none>2006-04-08 23:33:38 -0700
commitb468a217b67dc26ce21da5d5a2ca09bb6249e4fa (patch)
tree71b6bb81b469d8127e12b97549cb177aa5deac3e /usr/src/lib/libzfs/common/libzfs_pool.c
parent25cf1a301a396c38e8adf52c15f537b80d2483f7 (diff)
downloadillumos-gate-b468a217b67dc26ce21da5d5a2ca09bb6249e4fa.tar.gz
6407791 bringover into ZFS results in s. files newer than extracted source
6409927 failed DKIOCFLUSHWRITECACHE ioctls should not generate ereports 6410371 need to reserve more pool names
Diffstat (limited to 'usr/src/lib/libzfs/common/libzfs_pool.c')
-rw-r--r--usr/src/lib/libzfs/common/libzfs_pool.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c
index 2889725027..1fe6fa2d27 100644
--- a/usr/src/lib/libzfs/common/libzfs_pool.c
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c
@@ -46,12 +46,30 @@
* 'buf'.
*/
static int
-zpool_name_valid(const char *pool, char *buf, size_t buflen)
+zpool_name_valid(const char *pool, boolean_t isopen, char *buf, size_t buflen)
{
namecheck_err_t why;
char what;
+ int ret;
+
+ ret = pool_namecheck(pool, &why, &what);
+
+ /*
+ * The rules for reserved pool names were extended at a later point.
+ * But we need to support users with existing pools that may now be
+ * invalid. So we only check for this expanded set of names during a
+ * create (or import), and only in userland.
+ */
+ if (ret == 0 && !isopen &&
+ (strncmp(pool, "mirror", 6) == 0 ||
+ strncmp(pool, "raidz", 5) == 0 ||
+ strncmp(pool, "spare", 5) == 0)) {
+ ret = -1;
+ why = NAME_ERR_RESERVED;
+ }
+
- if (pool_namecheck(pool, &why, &what) != 0) {
+ if (ret != 0) {
if (buf != NULL) {
switch (why) {
case NAME_ERR_TOOLONG:
@@ -142,7 +160,7 @@ zpool_open_canfail(const char *pool)
/*
* Make sure the pool name is valid.
*/
- if (!zpool_name_valid(pool, NULL, 0)) {
+ if (!zpool_name_valid(pool, B_TRUE, NULL, 0)) {
zfs_error(dgettext(TEXT_DOMAIN, "cannot open '%s': invalid "
"pool name"), pool);
return (NULL);
@@ -338,7 +356,7 @@ zpool_create(const char *pool, nvlist_t *nvroot, const char *altroot)
int err;
char reason[64];
- if (!zpool_name_valid(pool, reason, sizeof (reason))) {
+ if (!zpool_name_valid(pool, B_FALSE, reason, sizeof (reason))) {
zfs_error(dgettext(TEXT_DOMAIN, "cannot create '%s': %s"),
pool, reason);
return (-1);
@@ -688,7 +706,7 @@ zpool_import(nvlist_t *config, const char *newname, const char *altroot)
&origname) == 0);
if (newname != NULL) {
- if (!zpool_name_valid(newname, NULL, 0)) {
+ if (!zpool_name_valid(newname, B_FALSE, NULL, 0)) {
zfs_error(dgettext(TEXT_DOMAIN, "cannot import '%s': "
"invalid pool name"), newname);
return (-1);