diff options
author | Eric Blake <ebb9@byu.net> | 2009-09-19 05:50:30 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2009-09-19 13:49:59 -0600 |
commit | 82bf7d1b42dc970e704f9347862594445f4a22dd (patch) | |
tree | 5a5abebd391ce672dbc0b4c5861907ec6e4ecd69 /lib/unlinkat.c | |
parent | 22d7496bac7d391faff10755b17889ecd2f604d4 (diff) | |
download | gnulib-82bf7d1b42dc970e704f9347862594445f4a22dd.tar.gz |
openat: move fstatat and unlinkat into correct files
Code motion, should be no semantic changes.
* m4/openat.m4 (gl_FUNC_OPENAT): Adjust which files will be
compiled.
* lib/openat.c (fstatat, unlinkat): Move...
* lib/fstatat.c (fstatat): ...into correct files.
* lib/unlinkat.c (unlinkat): Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'lib/unlinkat.c')
-rw-r--r-- | lib/unlinkat.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/unlinkat.c b/lib/unlinkat.c index bf5d5b8963..73022529e4 100644 --- a/lib/unlinkat.c +++ b/lib/unlinkat.c @@ -28,7 +28,9 @@ #include "openat.h" -#undef unlinkat +#if HAVE_UNLINKAT + +# undef unlinkat /* unlinkat without AT_REMOVEDIR does not honor trailing / on Solaris 9. Solve it in a similar manner to unlink. */ @@ -75,3 +77,29 @@ rpl_unlinkat (int fd, char const *name, int flag) result = unlinkat (fd, name, flag); return result; } + +#else /* !HAVE_UNLINKAT */ + +/* Replacement for Solaris' function by the same name. + <http://www.google.com/search?q=unlinkat+site:docs.sun.com> + First, try to simulate it via (unlink|rmdir) ("/proc/self/fd/FD/FILE"). + Failing that, simulate it via save_cwd/fchdir/(unlink|rmdir)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, this function works just like Solaris' unlinkat. */ + +# define AT_FUNC_NAME unlinkat +# define AT_FUNC_F1 rmdir +# define AT_FUNC_F2 unlink +# define AT_FUNC_USE_F1_COND AT_REMOVEDIR +# define AT_FUNC_POST_FILE_PARAM_DECLS , int flag +# define AT_FUNC_POST_FILE_ARGS /* empty */ +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#endif /* !HAVE_UNLINKAT */ |