X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Funistd.in.h;h=f191412e23ec3e0da1f49e090baf793d31ecc8be;hb=6c9f1e88ada406b65f6b10098b8c9e60c973e614;hp=a86935ba1eb5d70f210ce72038a97629d6aa6be1;hpb=a7b40bdb82e8d3448d8007b061077ecfb3b6bfdc;p=gnulib.git diff --git a/lib/unistd.in.h b/lib/unistd.in.h index a86935ba1..f191412e2 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -106,6 +106,15 @@ # define STDERR_FILENO 2 #endif +/* Ensure *_OK functions exist. */ +#ifndef F_OK +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 +#endif + + /* Declare overridden functions. */ #ifdef __cplusplus @@ -138,6 +147,72 @@ extern int chown (const char *file, uid_t uid, gid_t gid); #endif +#if @GNULIB_FCHOWNAT@ +# if @REPLACE_FCHOWNAT@ +# undef fchownat +# define fchownat rpl_fchownat +# endif +# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@ +extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fchownat +# define fchownat(d,n,o,g,f) \ + (GL_LINK_WARNING ("fchownat is not portable - " \ + "use gnulib module openat for portability"), \ + fchownat (d, n, o, g, f)) +#endif + + +#if @GNULIB_UNLINKAT@ +# if !@HAVE_UNLINKAT@ +extern int unlinkat (int fd, char const *file, int flag); +# endif +#elif defined GNULIB_POSIXCHECK +# undef unlinkat +# define unlinkat(d,n,f) \ + (GL_LINK_WARNING ("unlinkat is not portable - " \ + "use gnulib module openat for portability"), \ + unlinkat (d, n, f)) +#endif + + +#if @GNULIB_FACCESSAT@ +# if !@HAVE_FACCESSAT@ +int faccessat (int fd, char const *file, int mode, int flag); +# endif +#elif defined GNULIB_POSIXCHECK +# undef faccessat +# define faccessat(d,n,m,f) \ + (GL_LINK_WARNING ("faccessat is not portable - " \ + "use gnulib module faccessat for portability"), \ + faccessat (d, n, m, f)) +#endif + +#if @GNULIB_SYMLINKAT@ +# if !@HAVE_SYMLINKAT@ +int symlinkat (char const *contents, int fd, char const *file); +# endif +#elif defined GNULIB_POSIXCHECK +# undef symlinkat +# define symlinkat(c,d,n) \ + (GL_LINK_WARNING ("symlinkat is not portable - " \ + "use gnulib module symlinkat for portability"), \ + symlinkat (c, d, n)) +#endif + +#if @GNULIB_READLINKAT@ +# if !@HAVE_READLINKAT@ +ssize_t readlinkat (int fd, char const *file, char *buf, size_t len); +# endif +#elif defined GNULIB_POSIXCHECK +# undef readlinkat +# define readlinkat(d,n,b,l) \ + (GL_LINK_WARNING ("readlinkat is not portable - " \ + "use gnulib module symlinkat for portability"), \ + readlinkat (d, n, b, l)) +#endif + #if @GNULIB_CLOSE@ # if @REPLACE_CLOSE@ /* Automatically included by modules that need a replacement for close. */ @@ -178,6 +253,28 @@ extern int dup2 (int oldfd, int newfd); #endif +#if @GNULIB_DUP3@ +/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the + specified flags. + The flags are a bitmask, possibly including O_CLOEXEC (defined in ) + and O_TEXT, O_BINARY (defined in "binary-io.h"). + Close NEWFD first if it is open. + Return newfd if successful, otherwise -1 and errno set. + See the Linux man page at + . */ +# if @HAVE_DUP3@ +# define dup3 rpl_dup3 +# endif +extern int dup3 (int oldfd, int newfd, int flags); +#elif defined GNULIB_POSIXCHECK +# undef dup3 +# define dup3(o,n,f) \ + (GL_LINK_WARNING ("dup3 is unportable - " \ + "use gnulib module dup3 for portability"), \ + dup3 (o, n, f)) +#endif + + #if @GNULIB_ENVIRON@ # if !@HAVE_DECL_ENVIRON@ /* Set of environment variables and values. An array of strings of the form @@ -226,11 +323,11 @@ extern int fchdir (int /*fd*/); # define dup rpl_dup extern int dup (int); -# if @REPLACE_DUP2@ -# undef dup2 -# endif -# define dup2 rpl_dup2_fchdir -extern int dup2 (int, int); +/* Gnulib internal hooks needed to maintain the fchdir metadata. */ +extern int _gl_register_fd (int fd, const char *filename); +extern void _gl_unregister_fd (int fd); +extern int _gl_register_dup (int oldfd, int newfd); +extern const char *_gl_directory_name (int fd); # endif #elif defined GNULIB_POSIXCHECK @@ -498,11 +595,14 @@ extern int lchown (char const *file, uid_t owner, gid_t group); #if @GNULIB_LINK@ +# if @REPLACE_LINK@ +# define link rpl_link +# endif /* Create a new hard link for an existing file. Return 0 if successful, otherwise -1 and errno set. See POSIX:2001 specification . */ -# if !@HAVE_LINK@ +# if !@HAVE_LINK@ || @REPLACE_LINK@ extern int link (const char *path1, const char *path2); # endif #elif defined GNULIB_POSIXCHECK @@ -541,9 +641,10 @@ extern int link (const char *path1, const char *path2); Return 0 upon success, or -1 with errno set upon failure. See also the Linux man page at . */ -# if !@HAVE_PIPE2@ -extern int pipe2 (int fd[2], int flags); +# if @HAVE_PIPE2@ +# define pipe2 rpl_pipe2 # endif +extern int pipe2 (int fd[2], int flags); #elif defined GNULIB_POSIXCHECK # undef pipe2 # define pipe2(f,o) \ @@ -598,12 +699,6 @@ extern ssize_t write (int fd, const void *buf, size_t count); #endif -#ifdef FCHDIR_REPLACEMENT -/* gnulib internal function. */ -extern void _gl_unregister_fd (int fd); -#endif - - #ifdef __cplusplus } #endif