* [pve-devel] [PATCH storage] fix 3214: storage dir structure creation with mkdir 0
@ 2020-12-22 10:53 Aaron Lauterer
2020-12-22 12:57 ` Wolfgang Bumiller
0 siblings, 1 reply; 3+ messages in thread
From: Aaron Lauterer @ 2020-12-22 10:53 UTC (permalink / raw)
To: pve-devel
We fail early when `mkdir 0` is set for the storage to avoid creating
the directories in the storage path.
This means that once `mkdir 0` is set, the code to create the needed
directory structure (e.g. dump, image, ...) at the storage location will
never run.
Adding an additional check to only return early if the storage path
currently does not exist solves the problem.
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---
PVE/Storage/Plugin.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 57c58a9..bda1beb 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -1158,8 +1158,8 @@ sub activate_storage {
"directory '$path' does not exist or is unreachable\n";
}
-
- return if defined($scfg->{mkdir}) && !$scfg->{mkdir};
+ my $st = File::stat::stat($path);
+ return if defined($scfg->{mkdir}) && !$scfg->{mkdir} && !defined($st);
if (defined($scfg->{content})) {
foreach my $vtype (keys %$vtype_subdirs) {
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH storage] fix 3214: storage dir structure creation with mkdir 0
2020-12-22 10:53 [pve-devel] [PATCH storage] fix 3214: storage dir structure creation with mkdir 0 Aaron Lauterer
@ 2020-12-22 12:57 ` Wolfgang Bumiller
2020-12-22 13:25 ` Wolfgang Bumiller
0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Bumiller @ 2020-12-22 12:57 UTC (permalink / raw)
To: Aaron Lauterer; +Cc: pve-devel
On Tue, Dec 22, 2020 at 11:53:40AM +0100, Aaron Lauterer wrote:
> We fail early when `mkdir 0` is set for the storage to avoid creating
> the directories in the storage path.
>
> This means that once `mkdir 0` is set, the code to create the needed
> directory structure (e.g. dump, image, ...) at the storage location will
> never run.
>
> Adding an additional check to only return early if the storage path
> currently does not exist solves the problem.
>
> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
> ---
> PVE/Storage/Plugin.pm | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
> index 57c58a9..bda1beb 100644
> --- a/PVE/Storage/Plugin.pm
> +++ b/PVE/Storage/Plugin.pm
> @@ -1158,8 +1158,8 @@ sub activate_storage {
> "directory '$path' does not exist or is unreachable\n";
> }
>
> -
> - return if defined($scfg->{mkdir}) && !$scfg->{mkdir};
> + my $st = File::stat::stat($path);
> + return if defined($scfg->{mkdir}) && !$scfg->{mkdir} && !defined($st);
Instead of calling stat you can just use the `-d` prefix operator.
>
> if (defined($scfg->{content})) {
> foreach my $vtype (keys %$vtype_subdirs) {
> --
> 2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH storage] fix 3214: storage dir structure creation with mkdir 0
2020-12-22 12:57 ` Wolfgang Bumiller
@ 2020-12-22 13:25 ` Wolfgang Bumiller
0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Bumiller @ 2020-12-22 13:25 UTC (permalink / raw)
To: Aaron Lauterer; +Cc: pve-devel
On Tue, Dec 22, 2020 at 01:57:25PM +0100, Wolfgang Bumiller wrote:
> On Tue, Dec 22, 2020 at 11:53:40AM +0100, Aaron Lauterer wrote:
> > We fail early when `mkdir 0` is set for the storage to avoid creating
> > the directories in the storage path.
> >
> > This means that once `mkdir 0` is set, the code to create the needed
> > directory structure (e.g. dump, image, ...) at the storage location will
> > never run.
> >
> > Adding an additional check to only return early if the storage path
> > currently does not exist solves the problem.
> >
> > Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
> > ---
> > PVE/Storage/Plugin.pm | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
> > index 57c58a9..bda1beb 100644
> > --- a/PVE/Storage/Plugin.pm
> > +++ b/PVE/Storage/Plugin.pm
> > @@ -1158,8 +1158,8 @@ sub activate_storage {
> > "directory '$path' does not exist or is unreachable\n";
> > }
> >
> > -
> > - return if defined($scfg->{mkdir}) && !$scfg->{mkdir};
> > + my $st = File::stat::stat($path);
> > + return if defined($scfg->{mkdir}) && !$scfg->{mkdir} && !defined($st);
>
> Instead of calling stat you can just use the `-d` prefix operator.
scratch that, we already perform that check right above this code...
and `mkdir` here changes meaning from "create the path to the storage"
to "create the directries *inside* the storage"... this is bad :|
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-22 13:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 10:53 [pve-devel] [PATCH storage] fix 3214: storage dir structure creation with mkdir 0 Aaron Lauterer
2020-12-22 12:57 ` Wolfgang Bumiller
2020-12-22 13:25 ` Wolfgang Bumiller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox