[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180409103554.64flwtm5xamhrkkp@pali>
Date: Mon, 9 Apr 2018 12:35:54 +0200
From: Pali Rohár <pali.rohar@...il.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Jan Kara <jack@...e.cz>
Subject: Re: Race-free unlinking of directory entries
On Monday 09 April 2018 03:24:14 Christoph Hellwig wrote:
> On Mon, Apr 09, 2018 at 12:10:09PM +0200, Pali Rohár wrote:
> > Another example:
> >
> > fd = open("/a")
> > link("/a", "/b")
> > unlink("/a")
> >
> > Calling funlink for fd should unlink "/b" or it should fail?
>
> It should fail, as '/a' doesn't refer to name that is visible in the
> namespace.
>
> > And another example:
> >
> > fd = open("/a")
> > rename("/a", "/b")
> >
> > What should funlink do for fd now?
>
> remove the directory entry refering to '/b' as that is what fd refers
> to.
Why it should differ in these two cases? Calling /bin/ln /a /b followed by
/bin/rm /a results in the same state as calling /bin/mv /a /b. This is
something which works in POSIX systems.
I think it is strange that new possible funlink call would work only if
external applications uses /bin/mv and would fail if /bin/ln and /bin/rm
are used.
This is reason why I suggested two parameters funlink, it takes fd for
unlinking and pathname which must contain same inode as fd. So when you
call it with fd+"/b" it unlink "/b" without failing.
--
Pali Rohár
pali.rohar@...il.com
Powered by blists - more mailing lists