From b468a217b67dc26ce21da5d5a2ca09bb6249e4fa Mon Sep 17 00:00:00 2001 From: eschrock Date: Sat, 8 Apr 2006 23:33:38 -0700 Subject: 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 --- usr/src/lib/libzfs/common/libzfs_pool.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'usr/src/lib/libzfs/common/libzfs_pool.c') 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); -- cgit v1.2.3