public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Markus Frank <m.frank@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 1/6] fix #3690: pbs_api_types: add regex, format & schema for partition names to pbs-api-types
Date: Tue, 28 Nov 2023 11:39:54 +0100	[thread overview]
Message-ID: <20231128103959.159650-2-m.frank@proxmox.com> (raw)
In-Reply-To: <20231128103959.159650-1-m.frank@proxmox.com>

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 pbs-api-types/src/lib.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
index 4306eca3..a771a6b2 100644
--- a/pbs-api-types/src/lib.rs
+++ b/pbs-api-types/src/lib.rs
@@ -191,6 +191,7 @@ const_regex! {
     );
 
     pub BLOCKDEVICE_NAME_REGEX = r"^(?:(?:h|s|x?v)d[a-z]+)|(?:nvme\d+n\d+)$";
+    pub BLOCKDEVICE_DISK_AND_PARTITION_NAME_REGEX = r"^(?:(?:h|s|x?v)d[a-z]+\d*)|(?:nvme\d+n\d+(p\d+)?)$";
     pub SUBSCRIPTION_KEY_REGEX = concat!(r"^pbs(?:[cbsp])-[0-9a-f]{10}$");
 }
 
@@ -205,6 +206,8 @@ pub const PASSWORD_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&PASSWORD_
 pub const UUID_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&UUID_REGEX);
 pub const BLOCKDEVICE_NAME_FORMAT: ApiStringFormat =
     ApiStringFormat::Pattern(&BLOCKDEVICE_NAME_REGEX);
+pub const BLOCKDEVICE_DISK_AND_PARTITION_NAME_FORMAT: ApiStringFormat =
+    ApiStringFormat::Pattern(&BLOCKDEVICE_DISK_AND_PARTITION_NAME_REGEX);
 pub const SUBSCRIPTION_KEY_FORMAT: ApiStringFormat =
     ApiStringFormat::Pattern(&SUBSCRIPTION_KEY_REGEX);
 pub const SYSTEMD_DATETIME_FORMAT: ApiStringFormat =
@@ -285,6 +288,13 @@ pub const BLOCKDEVICE_NAME_SCHEMA: Schema =
         .max_length(64)
         .schema();
 
+pub const BLOCKDEVICE_DISK_AND_PARTITION_NAME_SCHEMA: Schema =
+    StringSchema::new("(Partition) block device name (/sys/class/block/<name>).")
+        .format(&BLOCKDEVICE_DISK_AND_PARTITION_NAME_FORMAT)
+        .min_length(3)
+        .max_length(64)
+        .schema();
+
 pub const DISK_ARRAY_SCHEMA: Schema =
     ArraySchema::new("Disk name list.", &BLOCKDEVICE_NAME_SCHEMA).schema();
 
-- 
2.39.2





  reply	other threads:[~2023-11-28 10:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28 10:39 [pbs-devel] [PATCH proxmox-backup v2 0/6] fix #3690: wipe disk Markus Frank
2023-11-28 10:39 ` Markus Frank [this message]
2023-11-28 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 2/6] fix #3690: tools: add wipe_blockdev & change_parttype rust equivalent Markus Frank
2023-11-28 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 3/6] fix #3690: api: add function wipe_disk Markus Frank
2023-11-28 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 4/6] fix #3690: cli: " Markus Frank
2023-11-28 11:18   ` Philipp Hufnagl
2023-11-28 11:21     ` Max Carrara
2023-11-28 11:20   ` Max Carrara
2023-11-28 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 5/6] fix #3690: ui: enable wipe disk in StorageAndDisks Markus Frank
2023-11-28 10:39 ` [pbs-devel] [PATCH proxmox-backup v2 6/6] tools: prohibit disk wipe of EFI partition Markus Frank

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=20231128103959.159650-2-m.frank@proxmox.com \
    --to=m.frank@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal