bug-gnulib
[Top][All Lists]
Advanced

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

Re: mkfifoat, renameat


From: Jim Meyering
Subject: Re: mkfifoat, renameat
Date: Tue, 08 Sep 2009 10:43:47 +0200

Eric Blake wrote:
> Two more *at functions.  mkfifoat is rather simple; the hardest part was
> ensuring the test still compiles on mingw.  renameat is more complex,
> although I intentionally made it call into a helper function, at_func2, so
> that I can reuse that function when I do linkat.  The renameat testsuite
> intentionally exercises as many successful control paths of the helper
> function as I could manage, prior to doing semantic checks of various
> error conditions.  There are still some pending questions to the Austin
> Group on what POSIX says rename _should_ do, so for now, I'm okay with
> commented out portions in the test suite.  I verified that the unit test
> passed on Linux, Solaris 10, cygwin 1.5, and cygwin 1.7, although it
> failed miserably on mingw.
>
> Part of the problem on mingw is that the fchdir module relies on
> canonicalize doing the right thing, but mingw's paths (with drive letters
> and \, rather than leading / for absolute) throws canonicalize for a loop;
> and cross-compilation tries to replace getcwd, even though mingw's getcwd
> always works.  At that point, the populated dirs[fd].name mapping have
> invalid entries, which hurt attempts to do fstat(dfd).  It doesn't help
> that mingw stat() reports st_ino == 0 for every directory, rendering
> SAME_INODE useless.  Oh well, I'll have to spend more time porting those
> pieces to mingw.  But for now, I think renameat is far enough along to at
> least post for review.
>
> I suppose there might still be some pathological cases where renameat
> currently fails but could be made to succeed.  For example,
> renameat(super_deep,a,root,b) will probably fail with ENAMETOOLONG when

Speaking of pathological, ;-)

For some cases, in which a renamat emulator would fail to form *any*
usable absolute name, it may succeed with relative names, e.g.,

  renameat(deep1,a,deep2,b)

when the deep1-relative name for deep2
or the deep2-relative name for deep1 is short enough.
Of course, calculating those relative names may be rather expensive.

> changing to super_deep and converting a to an absolute name, while
> changing to root and converting b to absolute would avoid that issue.  But
> I'm not too worried about those unless someone actually reports that they
> encountered it in practice.
...
>>From 625504c335cdbded06262bf5607d07c1fb7675d0 Mon Sep 17 00:00:00 2001
> From: Eric Blake <address@hidden>
> Date: Mon, 7 Sep 2009 05:38:18 -0600
> Subject: [PATCH 1/2] mkfifoat: new module
> * modules/mkfifoat: New file.
> * lib/mkfifoat.c: Likewise.
> * m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Likewise.
> * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Add witnesses.
> * modules/sys_stat (Makefile.am): Use them.
> * lib/sys_stat.in.h (mkfifoat, mknodat): Declare them.
> * MODULES.html.sh (File system functions): Mention module.
> * doc/posix-functions/mkfifoat.texi (mkfifoat): Likewise.
> * doc/posix-functions/mknodat.texi (mknodat): Likewise.
> * modules/mkfifoat-tests: New test.
> * tests/test-mkfifoat.c: Likewise.
...
> Subject: [PATCH 2/2] renameat: new module
> * modules/renameat: New file.
> * lib/at-func2.c (at_func2): Likewise.
> * lib/renameat.c (renameat): Likewise.
> * m4/renameat.m4 (gl_FUNC_RENAMEAT): Likewise.
> * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Add witnesses.
> * modules/stdio (Makefile.am): Substitute them.
> * lib/stdio.in.h (renameat): Declare it.
> * MODULES.html.sh (systems lacking POSIX:2008): Mention module.
> * doc/posix-functions/renameat.texi (renameat): Likewise.
> * doc/posix-functions/rename.texi (rename): Tweak wording.
> * modules/renameat-tests: New test.
> * tests/test-renameat.c: Likewise.

Very nice.  Thanks especially for the thorough unit tests.

Have you looked at coverage data?
It'd be nice to to ensure that each of those many cases is
exercised on some platform.

With the full suite of portable *at functions, it should now be
feasible to rewrite coreutils' copy.c to do its job via fts, and
directory file descriptors, rather than via full relative names.

It and ls.c are the only two hold-outs that still use hand-rolled
(and hence inferior) hierarchy-traversal code in the coreutils.




reply via email to

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