This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: FYI: new openat-like function: mkdirat
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jim Meyering <jim at meyering dot net>
- Cc: Roland McGrath <roland at redhat dot com>, bug-gnulib at gnu dot org, libc-alpha at sources dot redhat dot com, Ulrich Drepper <drepper at redhat dot com>
- Date: Thu, 1 Dec 2005 07:25:17 +0100
- Subject: Re: FYI: new openat-like function: mkdirat
- References: <20051130195500.606D01809B9@magilla.sf.frob.com> <87br01oo0u.fsf@rho.meyering.net>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Nov 30, 2005 at 09:53:53PM +0100, Jim Meyering wrote:
> Roland McGrath <roland@redhat.com> wrote:
> > I think that the Solaris *at functions were really primarily intended for
> > use with O_XATTR to get at "file attribute" magic pseudo-directories rather
> > than to optimize use of normal directories and files. Probably mkdirat
> > doesn't make sense in Solaris attribute pseudo-directories. But mkdirat is
> > as useful in general as any of those *at additions, so I'd say we might as
> > well have it.
>
> Good! Thanks.
>
> cp, cpio, mv, and tar currently use mkfifo and mknod,
> so you might want to add mkfifoat and mknodat to the list, too.
Also, an extended version of renameat that provides the 2 dir fd's
(resp. AT_FDCWD), 2 filenames and 2 opened fd's for the old and new
files that would rename only if the 2 files haven't been moved
would be useful for programs like prelink, rpm, dpkg, ...
That can't be implemented without kernel control, but without it
although you can't do a race-free read-modify-rename_over_the_old
file cycle, as the file you are overwritten could have been changed
by some other program (or the source file).
Like:
renameatfd (int olddirfd, const char *oldname, int oldfd,
int newdirfd, const char *newname, int newfd);
perhaps with some magic constant for {old,new}fd argument, so that:
renameatfd (olddirfd, oldname, AT_NOFD, newdirfd, newname, AT_NOFD);
would be the same as
renameat (olddirfd, oldname, newdirfd, newname);
and
renameatfd (AT_NOCWD, oldname, AT_NOFD, AT_NOCWD, newname, AT_NOFD);
would be the same as
rename (oldname, newname).
Jakub