[pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal
Friedrich Weber
f.weber at proxmox.com
Tue Mar 21 18:03:25 CET 2023
This prevents strange interactions in case the same content directory
is used for multiple content types.
Signed-off-by: Friedrich Weber <f.weber at proxmox.com>
---
I guess technically this is a breaking change, as users may have an
iso+vztmpl storage that symlinks 'templates/iso' to 'templates/cache',
which would now throw an error.
PVE/Storage/Plugin.pm | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index c323085..3c9a179 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -3,6 +3,7 @@ package PVE::Storage::Plugin;
use strict;
use warnings;
+use Cwd qw(abs_path);
use Encode qw(decode);
use Fcntl ':mode';
use File::chdir;
@@ -1362,6 +1363,16 @@ sub activate_storage {
"directory '$path' does not exist or is unreachable\n";
}
+ # check that content dirs are pairwise inequal
+ my $resolved_subdirs = {};
+ if (defined($scfg->{content})) {
+ foreach my $vtype (keys $scfg->{content}->%*) {
+ my $abs_subdir = abs_path($class->get_subdir($scfg, $vtype));
+ die "storage '$storeid' uses directory $abs_subdir for multiple content types\n"
+ if defined($resolved_subdirs->{$abs_subdir});
+ $resolved_subdirs->{$abs_subdir} = 1;
+ }
+ }
return if defined($scfg->{mkdir}) && !$scfg->{mkdir};
--
2.30.2
More information about the pve-devel
mailing list