From: Oguz Bektas <o.bektas@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup] zfs: check if given pool name is reserved
Date: Tue, 23 Nov 2021 13:21:02 +0100 [thread overview]
Message-ID: <20211123122102.577014-1-o.bektas@proxmox.com> (raw)
man zpool-create:
The pool names mirror, raidz, draid, spare and log are reserved, as
are names _beginning_ with mirror, raidz, draid, and spare. The vdev
specification is described in the Virtual Devices section of
zpoolconcepts(7).
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---
src/api2/node/disks/zfs.rs | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index c9a6ac72..58e5a83e 100644
--- a/src/api2/node/disks/zfs.rs
+++ b/src/api2/node/disks/zfs.rs
@@ -201,6 +201,15 @@ pub fn create_zpool(
};
// Sanity checks
+
+ lazy_static::lazy_static! {
+ // pool names starting with these are reserved
+ static ref RESERVED_POOL_NAMES: regex::Regex = regex::Regex::new(r"^(mirror|raidz|draid|spare).*$").unwrap();
+ }
+ if RESERVED_POOL_NAMES.is_match(&name) || &name == "log" {
+ bail!("Pool name {:?} is reserved.", &name);
+ }
+
if raidlevel == ZfsRaidLevel::Raid10 && devices.len() % 2 != 0 {
bail!("Raid10 needs an even number of disks.");
}
--
2.30.2
next reply other threads:[~2021-11-23 12:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-23 12:21 Oguz Bektas [this message]
2021-11-23 12:52 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211123122102.577014-1-o.bektas@proxmox.com \
--to=o.bektas@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.