[pve-devel] [RFC PATCH storage] fix 1012: dir: add mkdir option

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Jun 6 15:44:45 CEST 2016


By default a directory storage creates its path. In some
cases this can be undesired, mostly when storages have
nested paths (eg. a dir storage on a ZFS path or in an NFS
share, or inside custom mount points).
As a simple fix to this the 'mkdir' option (default ON)
can now be used to disable this behavior.
---
 PVE/Storage/DirPlugin.pm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/PVE/Storage/DirPlugin.pm b/PVE/Storage/DirPlugin.pm
index bc3c61f..23cb6bb 100644
--- a/PVE/Storage/DirPlugin.pm
+++ b/PVE/Storage/DirPlugin.pm
@@ -28,6 +28,11 @@ sub properties {
 	    description => "File system path.",
 	    type => 'string', format => 'pve-storage-path',
 	},
+	mkdir => {
+	    description => "Create the directory if it doesn't exist.",
+	    type => 'boolean',
+	    default => 'yes',
+	},
     };
 }
 
@@ -40,6 +45,7 @@ sub options {
         maxfiles => { optional => 1 },
 	content => { optional => 1 },
 	format => { optional => 1 },
+	mkdir => { optional => 1 },
    };
 }
 
@@ -48,8 +54,10 @@ sub options {
 sub activate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    my $path = $scfg->{path};
-    mkpath $path;
+    if (!defined($scfg->{mkdir}) || $scfg->{mkdir}) {
+	my $path = $scfg->{path};
+	mkpath $path;
+    }
 
     $class->SUPER::activate_storage($storeid, $scfg, $cache);    
 }
-- 
2.1.4





More information about the pve-devel mailing list