all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal
@ 2023-03-21 17:03 Friedrich Weber
  2023-06-06 15:28 ` [pve-devel] applied: " Thomas Lamprecht
  2023-06-07 10:01 ` [pve-devel] " Fiona Ebner
  0 siblings, 2 replies; 6+ messages in thread
From: Friedrich Weber @ 2023-03-21 17:03 UTC (permalink / raw)
  To: pve-devel

This prevents strange interactions in case the same content directory
is used for multiple content types.

Signed-off-by: Friedrich Weber <f.weber@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





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-07 10:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 17:03 [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal Friedrich Weber
2023-06-06 15:28 ` [pve-devel] applied: " Thomas Lamprecht
2023-06-07  7:46   ` Friedrich Weber
2023-06-07 10:01 ` [pve-devel] " Fiona Ebner
2023-06-07 10:18   ` Friedrich Weber
2023-06-07 10:35     ` Thomas Lamprecht

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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal