[pbs-devel] [PATCH proxmox-backup v14 07/25] api: add check for nested datastores on creation
Hannes Laimer
h.laimer at proxmox.com
Fri Nov 22 15:46:54 CET 2024
Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
* new in v14, and not removable datastore specific
src/api2/config/datastore.rs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index 420f8ddd0..75e1a1a56 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -81,6 +81,20 @@ pub(crate) fn do_create_datastore(
bail!("cannot create datastore in root path");
}
+ for store in config.convert_to_typed_array::<DataStoreConfig>("datastore")? {
+ if store.backing_device != datastore.backing_device {
+ continue;
+ }
+ if store.path.starts_with(&datastore.path) || datastore.path.starts_with(&store.path) {
+ param_bail!(
+ "path",
+ "nested datastores not allowed: '{}' already in '{}'",
+ store.name,
+ store.path
+ );
+ }
+ }
+
let need_unmount = datastore.backing_device.is_some();
if need_unmount {
do_mount_device(datastore.clone())?;
--
2.39.5
More information about the pbs-devel
mailing list