public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Aaron Lauterer <a.lauterer@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH storage] fix 3214: storage dir structure creation with mkdir 0
Date: Tue, 22 Dec 2020 14:25:54 +0100	[thread overview]
Message-ID: <20201222132554.ix5t53v7nldlmjhf@wobu-vie.proxmox.com> (raw)
In-Reply-To: <20201222125725.ecdspkp44334w7et@wobu-vie.proxmox.com>

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 :|




      reply	other threads:[~2020-12-22 13:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 10:53 Aaron Lauterer
2020-12-22 12:57 ` Wolfgang Bumiller
2020-12-22 13:25   ` Wolfgang Bumiller [this message]

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=20201222132554.ix5t53v7nldlmjhf@wobu-vie.proxmox.com \
    --to=w.bumiller@proxmox.com \
    --cc=a.lauterer@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