bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FYI: new openat-like function: mkdirat


From: Jakub Jelinek
Subject: Re: FYI: new openat-like function: mkdirat
Date: Thu, 1 Dec 2005 07:25:17 +0100
User-agent: Mutt/1.4.1i

On Wed, Nov 30, 2005 at 09:53:53PM +0100, Jim Meyering wrote:
> Roland McGrath <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]