From 5f4b5bd11cb4143852fc2d20ed0a01b26b1c6eba Mon Sep 17 00:00:00 2001 From: Friedrich Weber Date: Tue, 21 Mar 2023 18:03:25 +0100 Subject: [PATCH] content-dirs: check that all content dirs are pairwise inequal This prevents strange interactions in case the same content directory is used for multiple content types. Signed-off-by: Friedrich Weber --- src/PVE/Storage/Plugin.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index 1f0382d..f6295ed 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/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; @@ -1365,6 +1366,17 @@ sub activate_storage { warn "${storeid}: 'mkdir' option is deprecated. Use 'create-base-path' or 'create-subdirs' instead.\n" if defined($scfg->{mkdir}); + # 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->{'create-subdirs'}) && !$scfg->{'create-subdirs'}; # FIXME The mkdir option is deprecated. Remove with PVE 9? -- 2.39.2