This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FYI: new openat-like function: mkdirat


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]