public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC storage] content-dirs: check that all content dirs are pairwise inequal
Date: Tue, 21 Mar 2023 18:03:25 +0100	[thread overview]
Message-ID: <20230321170325.2401819-1-f.weber@proxmox.com> (raw)

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





             reply	other threads:[~2023-03-21 17:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 17:03 Friedrich Weber [this message]
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

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=20230321170325.2401819-1-f.weber@proxmox.com \
    --to=f.weber@proxmox.com \
    --cc=pve-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