Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [patch] Avoid race in zf_mkdir
- X-seq: zsh-workers 47440
- From: Matthew Martin <phy1729@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [patch] Avoid race in zf_mkdir
- Date: Fri, 9 Oct 2020 15:53:57 -0500
- Archived-at: <https://zsh.org/workers/47440>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-10/20201009205357.GA6449%40CptOrmolo.darkstar>
- Authentication-results: zsh.org; iprev=pass (mail-oo1-f50.google.com) smtp.remote-ip=209.85.161.50; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=OK/DT0OZdXQTZKGoEFxRW3m1TjcOITk1THne4RinEeM=; b=TM6xVnhczV+MkbG/zh5ALxeFjbuiQlN+E05TIVu9qKQv8+UomE2oG3ETKnESVefYLB 9dA9QbahmIT6D3pNRcdwe3+P2ORBR5ZMiQEfl7gRAfqquCWiyjammJZHYzG1RwJcru6E QTYisKGrKvjxDt1ok97V7NI8JjGzc1o6e7q7Eol19uCAziGqELut1JU9KH5zHbQUBpEf BnyasxJc+MZQR9q7S5JAuL58031pUhwQIKAw1aScHEfCdfgAXv88U5Pwf2qWSlhpUzBY 13nFn4ErNuxrLrhj+kPVnno/E+THIpgX8jZNU+ep9U3wVtq+beQI3ETdVeVE5wJHVDa/ QodA==
- In-reply-to: <CAH+w=7ZRvW3Yq3XO6TwbK1hgSDNE8ynX0eQOU2dTuLcAELNUDg@mail.gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- Mail-followup-to: zsh-workers@xxxxxxx
- References: <20201009200737.GA78914@CptOrmolo.darkstar> <CAH+w=7anY9r+-MYki4cycVuaP2+d9L3W5u8k3sHyZx4R5kvafg@mail.gmail.com> <CAN=4vMoJrD+g4Go37yT6gF-Lx61vHm45GvmG1Fx6-+3yyb1hAQ@mail.gmail.com> <CAH+w=7ZRvW3Yq3XO6TwbK1hgSDNE8ynX0eQOU2dTuLcAELNUDg@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
On Fri, Oct 09, 2020 at 01:47:49PM -0700, Bart Schaefer wrote:
> On Fri, Oct 9, 2020 at 1:35 PM Roman Perepelitsa <
> roman.perepelitsa@xxxxxxxxx> wrote:
>
> > On Fri, Oct 9, 2020 at 10:25 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
> > wrote:
> > >
> > > Er, sorry, this doesn't actually avoid the race, it just prevents the
> > error message from being shown by whichever shell loses the race.
> >
> > I think this is the expected behavior. It's prescribed by POSIX for mkdir.
> >
> [...]
>
> >
> > The patch is incorrect for a different reason. If `zf_mkdir -p foo` is
> > racing with another process that's doing `mkdir foo && rmdir foo`, the
> > zf_mkdir call must never fail but with this patch it can fail.
> >
>
> Hm ... in that case the code shouldn't call stat() unless the mkdir() gives
> EEXIST? And then ignore ENOENT from stat()?
>
> What if another process is doing "touch foo && rm foo"? How is it possible
> to distinguish that from mkdir+rmdir ?
>
> Or are we confusing the requirements for mkdir(2) from those for mkdir(1)
> ? I don't have the spec handy.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/mkdir.html
I suppose we could stat before and after if after mkdir errno = EEXIST.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author