Commit b69beab7 authored by Nils Goroll's avatar Nils Goroll

use our*() and real*() macros to prepare for iterceptor library use

this commit does _not_ change cpp (ggc -E) output compared to cdb63038
(tested with the commands given in src/Makefile.am for Solaris and Linux)
parent 6036f5d6
...@@ -61,10 +61,8 @@ ...@@ -61,10 +61,8 @@
#if defined(_LP64) #if defined(_LP64)
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#define six4(x) x
#else #else
#define _FILE_OFFSET_BITS 32 #define _FILE_OFFSET_BITS 32
#define six4(x) x ## 64
#endif #endif
//// no use to undef these - solaris sys/feature_tests.h sets to 1 //// no use to undef these - solaris sys/feature_tests.h sets to 1
//#undef _LARGEFILE_SOURCE //#undef _LARGEFILE_SOURCE
...@@ -113,11 +111,30 @@ ...@@ -113,11 +111,30 @@
#include <sys/xattr.h> #include <sys/xattr.h>
#endif #endif
static int _openatl(int, const char *, int, mode_t mode); #ifdef INTERPOSE
#if !defined(_LP64) # define real(x) real_ ## x
static int _openatl64(int, const char *, int, mode_t mode); # define real64(x) real_ ## x ## 64
# define our(x) x
# define our64(x) x ## 64
#else
# define real(x) x
# if defined(_LP64)
# define real64(x) x
# else
# define real64(x) x ## 64
# endif
# define our(x) x ## l
# if defined(_LP64)
# define our64(x) x ## l
# else
# define our64(x) x ## l ## 64
# endif
#endif #endif
static int our(_openat)(int, const char *, int, mode_t mode);
#if !defined(_LP64)
static int our64(_openat)(int, const char *, int, mode_t mode);
#endif
/* /*
* close an intermediate file descriptor, restoring errno if necessary * close an intermediate file descriptor, restoring errno if necessary
...@@ -143,7 +160,7 @@ static int chdir_im(const char *path, const char **remaining, int limit); ...@@ -143,7 +160,7 @@ static int chdir_im(const char *path, const char **remaining, int limit);
#define Xl(funcn, path, ...) \ #define Xl(funcn, path, ...) \
int r; \ int r; \
int ocwd = open(".", O_RDONLY|O_NDELAY|O_LARGEFILE); \ int ocwd = real(open)(".", O_RDONLY|O_NDELAY|O_LARGEFILE); \
const char *remaining; \ const char *remaining; \
\ \
if (ocwd == -1) \ if (ocwd == -1) \
...@@ -229,7 +246,7 @@ oatl_im(int filedes, const char *path, const char **remaining) { ...@@ -229,7 +246,7 @@ oatl_im(int filedes, const char *path, const char **remaining) {
strncpy(interm, p, (sl - p)); strncpy(interm, p, (sl - p));
interm[sl - p] = '\0'; interm[sl - p] = '\0';
nfd = six4(openat)(fd, interm, nfd = real64(openat)(fd, interm,
O_RDONLY|O_NDELAY|O_LARGEFILE, 0); O_RDONLY|O_NDELAY|O_LARGEFILE, 0);
if (nfd == -1) if (nfd == -1)
...@@ -301,7 +318,7 @@ oatl_im(int filedes, const char *path, const char **remaining) { ...@@ -301,7 +318,7 @@ oatl_im(int filedes, const char *path, const char **remaining) {
#define Xfl(path, flags, err, r, funcn, ...) \ #define Xfl(path, flags, err, r, funcn, ...) \
int __ifd; \ int __ifd; \
\ \
__ifd = six4(_openatl)(AT_FDCWD, (path), \ __ifd = our64(_openat)(AT_FDCWD, (path), \
O_RDONLY|O_NDELAY|O_LARGEFILE|(flags), 0); \ O_RDONLY|O_NDELAY|O_LARGEFILE|(flags), 0); \
\ \
if (__ifd == -1) \ if (__ifd == -1) \
...@@ -313,14 +330,14 @@ oatl_im(int filedes, const char *path, const char **remaining) { ...@@ -313,14 +330,14 @@ oatl_im(int filedes, const char *path, const char **remaining) {
/* OPEN */ /* OPEN */
static int static int
_openatl(int filedes, const char *path, int oflag, mode_t mode) { our(_openat)(int filedes, const char *path, int oflag, mode_t mode) {
Xatl(openat, filedes, path, oflag, mode); Xatl(real(openat), filedes, path, oflag, mode);
} }
#if !defined(_LP64) #if !defined(_LP64)
static int static int
_openatl64(int filedes, const char *path, int oflag, mode_t mode) { our64(_openat)(int filedes, const char *path, int oflag, mode_t mode) {
Xatl(openat64, filedes, path, oflag, mode); Xatl(real64(openat), filedes, path, oflag, mode);
} }
#endif #endif
...@@ -336,13 +353,13 @@ _openatl64(int filedes, const char *path, int oflag, mode_t mode) { ...@@ -336,13 +353,13 @@ _openatl64(int filedes, const char *path, int oflag, mode_t mode) {
return _openatl ## bits (filedes, path, oflag, mode) return _openatl ## bits (filedes, path, oflag, mode)
int int
openatl(int filedes, const char *path, int oflag, ...) { our(openat)(int filedes, const char *path, int oflag, ...) {
Openatl(/*32*/); Openatl(/*32*/);
} }
#if !defined(_LP64) #if !defined(_LP64)
int int
openatl64(int filedes, const char *path, int oflag, ...) { our64(openat)(int filedes, const char *path, int oflag, ...) {
Openatl(64); Openatl(64);
} }
#endif #endif
...@@ -360,12 +377,12 @@ openatl64(int filedes, const char *path, int oflag, ...) { ...@@ -360,12 +377,12 @@ openatl64(int filedes, const char *path, int oflag, ...) {
int int
openl(const char *path, int oflag, ...) { our(open)(const char *path, int oflag, ...) {
Openl(/*32*/); Openl(/*32*/);
} }
#if !defined(_LP64) #if !defined(_LP64)
int int
openl64(const char *path, int oflag, ...) { our64(open)(const char *path, int oflag, ...) {
Openl(64); Openl(64);
} }
#endif #endif
...@@ -373,12 +390,12 @@ openl64(const char *path, int oflag, ...) { ...@@ -373,12 +390,12 @@ openl64(const char *path, int oflag, ...) {
/* CREAT */ /* CREAT */
int int
creatl(const char *path, mode_t mode) { our(creat)(const char *path, mode_t mode) {
return _openatl(AT_FDCWD, path, O_WRONLY|O_CREAT|O_TRUNC, mode); return _openatl(AT_FDCWD, path, O_WRONLY|O_CREAT|O_TRUNC, mode);
} }
#if !defined(_LP64) #if !defined(_LP64)
int int
creatl64(const char *path, mode_t mode) { our64(creat)(const char *path, mode_t mode) {
return _openatl64(AT_FDCWD, path, O_WRONLY|O_CREAT|O_TRUNC, mode); return _openatl64(AT_FDCWD, path, O_WRONLY|O_CREAT|O_TRUNC, mode);
} }
#endif #endif
...@@ -391,7 +408,7 @@ creatl64(const char *path, mode_t mode) { ...@@ -391,7 +408,7 @@ creatl64(const char *path, mode_t mode) {
int fd, afd; \ int fd, afd; \
va_list ap; \ va_list ap; \
\ \
fd = six4(openl) (path, O_RDONLY|O_NONBLOCK); \ fd = our64(open) (path, O_RDONLY|O_NONBLOCK); \
if (fd == -1) \ if (fd == -1) \
return -1; \ return -1; \
\ \
...@@ -404,12 +421,12 @@ creatl64(const char *path, mode_t mode) { ...@@ -404,12 +421,12 @@ creatl64(const char *path, mode_t mode) {
return afd return afd
int int
attropenl(const char *path, const char *apath, int oflag, ...) { our(attropen)(const char *path, const char *apath, int oflag, ...) {
Attropenl(/*32*/); Attropenl(/*32*/);
} }
#if !defined(_LP64) #if !defined(_LP64)
int int
attropenl64(const char *path, const char *apath, int oflag, ...) { our64(attropen)(const char *path, const char *apath, int oflag, ...) {
Attropenl(64); Attropenl(64);
} }
#endif #endif
...@@ -424,31 +441,31 @@ attropenl64(const char *path, const char *apath, int oflag, ...) { ...@@ -424,31 +441,31 @@ attropenl64(const char *path, const char *apath, int oflag, ...) {
#endif #endif
ssize_t ssize_t
getxattrl(const char *path, const char *name, void *value, size_t size) { our(getxattr)(const char *path, const char *name, void *value, size_t size) {
ssize_t r; ssize_t r;
Xfl(path, 0, -1, Xfl(path, 0, -1,
r, fgetxattr, name, value, size); r, real(fgetxattr), name, value, size);
return r; return r;
} }
ssize_t ssize_t
lgetxattrl(const char *path, const char *name, void *value, size_t size) { our(lgetxattr)(const char *path, const char *name, void *value, size_t size) {
ssize_t r; ssize_t r;
Xfl(path, AT_SYMLINK_NOFOLLOW, -1, Xfl(path, AT_SYMLINK_NOFOLLOW, -1,
r, fgetxattr, name, value, size); r, real(fgetxattr), name, value, size);
return r; return r;
} }
int int
setxattrl(const char *path, const char *name, const void *value, size_t size, int flags) { our(setxattr)(const char *path, const char *name, const void *value, size_t size, int flags) {
int r; int r;
Xfl(path, 0, -1, Xfl(path, 0, -1,
r, fsetxattr, name, value, size, flags); r, real(fsetxattr), name, value, size, flags);
return r; return r;
} }
int int
lsetxattrl(const char *path, const char *name, const void *value, size_t size, int flags) { our(lsetxattr)(const char *path, const char *name, const void *value, size_t size, int flags) {
int r; int r;
Xfl(path, AT_SYMLINK_NOFOLLOW, -1, Xfl(path, AT_SYMLINK_NOFOLLOW, -1,
r, fsetxattr, name, value, size, flags); r, real(fsetxattr), name, value, size, flags);
return r; return r;
} }
#endif /* HAVE_FGETXATTR */ #endif /* HAVE_FGETXATTR */
...@@ -458,20 +475,20 @@ lsetxattrl(const char *path, const char *name, const void *value, size_t size, i ...@@ -458,20 +475,20 @@ lsetxattrl(const char *path, const char *name, const void *value, size_t size, i
#ifdef HAVE_LINKAT #ifdef HAVE_LINKAT
int int
linkatl(int fd1, const char *p1, int fd2, const char *p2, int flags) { our(linkat)(int fd1, const char *p1, int fd2, const char *p2, int flags) {
Xatl2(linkat, fd1, p1, fd2, p2, flags); Xatl2(real(linkat), fd1, p1, fd2, p2, flags);
} }
int int
linkl(const char *p1, const char *p2) { our(link)(const char *p1, const char *p2) {
return linkatl(AT_FDCWD, p1, AT_FDCWD, p2, 0); return our(linkat)(AT_FDCWD, p1, AT_FDCWD, p2, 0);
} }
#else /* HAVE_LINKAT */ #else /* HAVE_LINKAT */
#ifndef USE_CHDIR_FALLBACK #ifndef USE_CHDIR_FALLBACK
#warning linkat missing - link* calls on long paths may fail #warning linkat missing - link* calls on long paths may fail
int int
linkl(const char *p1, const char *p2) { our(link)(const char *p1, const char *p2) {
return link(p1, p2); return real(link)(p1, p2);
} }
#else /* USE_CHDIR_FALLBACK */ #else /* USE_CHDIR_FALLBACK */
...@@ -487,12 +504,12 @@ strprefixlen(const char *s1, const char *s2) { ...@@ -487,12 +504,12 @@ strprefixlen(const char *s1, const char *s2) {
} }
int int
linkl(const char *p1, const char *p2) { our(link)(const char *p1, const char *p2) {
int l = strprefixlen(p1, p2); int l = strprefixlen(p1, p2);
if (l > 0) { if (l > 0) {
int r; int r;
int ocwd = open(".", O_RDONLY|O_NDELAY|O_LARGEFILE); int ocwd = real(open)(".", O_RDONLY|O_NDELAY|O_LARGEFILE);
const char *remaining; const char *remaining;
if (ocwd == -1) if (ocwd == -1)
...@@ -508,13 +525,13 @@ linkl(const char *p1, const char *p2) { ...@@ -508,13 +525,13 @@ linkl(const char *p1, const char *p2) {
p1 += l; p1 += l;
p2 += l; p2 += l;
r = link(p1, p2); r = real(link)(p1, p2);
restore_cwd(&ocwd); restore_cwd(&ocwd);
return r; return r;
} }
return link(p1, p2); return real(link)(p1, p2);
} }
#endif /* USE_CHDIR_FALLBACK */ #endif /* USE_CHDIR_FALLBACK */
#endif /* HAVE_LINKAT */ #endif /* HAVE_LINKAT */
...@@ -522,20 +539,20 @@ linkl(const char *p1, const char *p2) { ...@@ -522,20 +539,20 @@ linkl(const char *p1, const char *p2) {
/** UNLINK **/ /** UNLINK **/
int int
unlinkatl(int fd, const char *p, int flags) { our(unlinkat)(int fd, const char *p, int flags) {
Xatl(unlinkat, fd, p, flags); Xatl(real(unlinkat), fd, p, flags);
} }
int int
unlinkl(const char *p) { our(unlink)(const char *p) {
return unlinkatl(AT_FDCWD, p, 0); return our(unlinkat)(AT_FDCWD, p, 0);
} }
/** SYMLINK **/ /** SYMLINK **/
#ifdef HAVE_SYMLINKAT #ifdef HAVE_SYMLINKAT
/* slightly differnt signature - damn */ /* slightly differnt signature - damn */
int int
symlinkatl(const char *dest, int filedes, const char *path) { our(symlinkat)(const char *dest, int filedes, const char *path) {
int ifd, r; int ifd, r;
const char *rest; const char *rest;
...@@ -544,7 +561,7 @@ symlinkatl(const char *dest, int filedes, const char *path) { ...@@ -544,7 +561,7 @@ symlinkatl(const char *dest, int filedes, const char *path) {
if (ifd == -1) if (ifd == -1)
return -1; return -1;
r = symlinkat(dest, ifd, rest); r = real(symlinkat)(dest, ifd, rest);
if (ifd != filedes) if (ifd != filedes)
close_ifd(ifd); close_ifd(ifd);
...@@ -552,21 +569,21 @@ symlinkatl(const char *dest, int filedes, const char *path) { ...@@ -552,21 +569,21 @@ symlinkatl(const char *dest, int filedes, const char *path) {
return r; return r;
} }
int int
symlinkl(const char *dest, const char *path) { our(symlink)(const char *dest, const char *path) {
return symlinkatl(dest, AT_FDCWD, path); return our(symlinkat)(dest, AT_FDCWD, path);
} }
#else /* HAVE_SYMLINKAT */ #else /* HAVE_SYMLINKAT */
#ifndef USE_CHDIR_FALLBACK #ifndef USE_CHDIR_FALLBACK
#warning symlinkat missing - symlink* calls on long paths may fail #warning symlinkat missing - symlink* calls on long paths may fail
int int
symlinkl(const char *dest, const char *path) { our(symlink)(const char *dest, const char *path) {
return symlink(dest, path); return real(symlink)(dest, path);
} }
#else /* USE_CHDIR_FALLBACK */ #else /* USE_CHDIR_FALLBACK */
int int
symlinkl(const char *dest, const char *path) { our(symlink)(const char *dest, const char *path) {
int r; int r;
int ocwd = open(".", O_RDONLY|O_NDELAY|O_LARGEFILE); int ocwd = real(open)(".", O_RDONLY|O_NDELAY|O_LARGEFILE);
const char *remaining; const char *remaining;
if (ocwd == -1) if (ocwd == -1)
...@@ -579,7 +596,7 @@ symlinkl(const char *dest, const char *path) { ...@@ -579,7 +596,7 @@ symlinkl(const char *dest, const char *path) {
path += (remaining - path); path += (remaining - path);
r = symlink(dest, path); r = real(symlink)(dest, path);
restore_cwd(&ocwd); restore_cwd(&ocwd);
return r; return r;
...@@ -593,27 +610,27 @@ symlinkl(const char *dest, const char *path) { ...@@ -593,27 +610,27 @@ symlinkl(const char *dest, const char *path) {
#ifdef HAVE_READLINKAT #ifdef HAVE_READLINKAT
int int
readlinkatl(int fd, const char *name, char *buf, size_t count) { our(readlinkat)(int fd, const char *name, char *buf, size_t count) {
Xatl(readlinkat, fd, name, buf, count); Xatl(real(readlinkat), fd, name, buf, count);
} }
int int
readlinkl(const char *name, char *buf, size_t count) { our(readlink)(const char *name, char *buf, size_t count) {
return readlinkatl(AT_FDCWD, name, buf, count); return our(readlinkat)(AT_FDCWD, name, buf, count);
} }
#else /* HAVE_READLINKAT */ #else /* HAVE_READLINKAT */
#ifndef USE_CHDIR_FALLBACK #ifndef USE_CHDIR_FALLBACK
#warning readlinkat missing - link* calls on long paths may fail #warning readlinkat missing - link* calls on long paths may fail
int int
readlinkl(const char *name, char *buf, size_t count) { our(readlink)(const char *name, char *buf, size_t count) {
return readlink(name, buf, count); return real(readlink)(name, buf, count);
} }
#else /* USE_CHDIR_FALLBACK */ #else /* USE_CHDIR_FALLBACK */
#undef NEED_CHDIR #undef NEED_CHDIR
#define NEED_CHDIR #define NEED_CHDIR
int int
readlinkl(const char *name, char *buf, size_t count) { our(readlink)(const char *name, char *buf, size_t count) {
Xl(readlink, name, buf, count); Xl(real(readlink), name, buf, count);
} }
#endif /* USE_CHDIR_FALLBACK */ #endif /* USE_CHDIR_FALLBACK */
#endif /* HAVE_READLINKAT */ #endif /* HAVE_READLINKAT */
...@@ -622,25 +639,25 @@ readlinkl(const char *name, char *buf, size_t count) { ...@@ -622,25 +639,25 @@ readlinkl(const char *name, char *buf, size_t count) {
/** CHOWN **/ /** CHOWN **/
int int
fchownatl(int fd, const char *name, uid_t uid, gid_t gid, int flags) { our(fchownat)(int fd, const char *name, uid_t uid, gid_t gid, int flags) {
Xatl(fchownat, fd, name, uid, gid, flags); Xatl(real(fchownat), fd, name, uid, gid, flags);
} }
int int
chownl(const char *name, uid_t uid, gid_t gid) { our(chown)(const char *name, uid_t uid, gid_t gid) {
return fchownatl(AT_FDCWD, name, uid, gid, 0); return our(fchownat)(AT_FDCWD, name, uid, gid, 0);
} }
int int
lchownl(const char *name, uid_t uid, gid_t gid) { our(lchown)(const char *name, uid_t uid, gid_t gid) {
return fchownatl(AT_FDCWD, name, uid, gid, AT_SYMLINK_NOFOLLOW); return our(fchownat)(AT_FDCWD, name, uid, gid, AT_SYMLINK_NOFOLLOW);
} }
/** CHMOD **/ /** CHMOD **/
int int
chmodl(const char *path, mode_t mode) { our(chmod)(const char *path, mode_t mode) {
int fd; int fd;
Xfl(path, 0, -1, Xfl(path, 0, -1,
fd, fchmod, mode); fd, real(fchmod), mode);
return fd; return fd;
} }
...@@ -648,26 +665,26 @@ chmodl(const char *path, mode_t mode) { ...@@ -648,26 +665,26 @@ chmodl(const char *path, mode_t mode) {
#ifdef HAVE_MKNODAT #ifdef HAVE_MKNODAT
int int
mknodatl(int fd, const char *name, mode_t mode, dev_t dev) { our(mknodat)(int fd, const char *name, mode_t mode, dev_t dev) {
Xatl(mknodat, fd, name, mode, dev); Xatl(real(mknodat), fd, name, mode, dev);
} }
int int
mknodl(const char *name, mode_t mode, dev_t dev) { our(mknod)(const char *name, mode_t mode, dev_t dev) {
return mknodatl(AT_FDCWD, name, mode, dev); return our(mknodat)(AT_FDCWD, name, mode, dev);
} }
#else /* HAVE_MKNODAT */ #else /* HAVE_MKNODAT */
#ifndef USE_CHDIR_FALLBACK #ifndef USE_CHDIR_FALLBACK
#warning mknodat missing - link* calls on long paths may fail #warning mknodat missing - link* calls on long paths may fail
int int
mknodl(const char *name, mode_t mode, dev_t dev) { our(mknod)(const char *name, mode_t mode, dev_t dev) {
return mknod(name, mode, dev); return real(mknod)(name, mode, dev);
} }
#else /* USE_CHDIR_FALLBACK */ #else /* USE_CHDIR_FALLBACK */
#undef NEED_CHDIR #undef NEED_CHDIR
#define NEED_CHDIR #define NEED_CHDIR
int int
mknodl(const char *name, mode_t mode, dev_t dev) { our(mknod)(const char *name, mode_t mode, dev_t dev) {
Xl(mknod, name, mode, dev); Xl(real(mknod), name, mode, dev);
} }
#endif /* USE_CHDIR_FALLBACK */ #endif /* USE_CHDIR_FALLBACK */
#endif /* HAVE_MKNODAT */ #endif /* HAVE_MKNODAT */
...@@ -676,26 +693,26 @@ mknodl(const char *name, mode_t mode, dev_t dev) { ...@@ -676,26 +693,26 @@ mknodl(const char *name, mode_t mode, dev_t dev) {
#ifdef HAVE_MKFIFOAT #ifdef HAVE_MKFIFOAT
int int
mkfifoatl(int fd, const char *name, mode_t mode) { our(mkfifoat)(int fd, const char *name, mode_t mode) {
Xatl(mkfifoat, fd, name, mode); Xatl(real(mkfifoat), fd, name, mode);
} }
int int
mkfifol(const char *name, mode_t mode) { our(mkfifo)(const char *name, mode_t mode) {
return mkfifoatl(AT_FDCWD, name, mode); return our(mkfifoat)(AT_FDCWD, name, mode);
} }
#else /* HAVE_MKFIFOAT */ #else /* HAVE_MKFIFOAT */
#ifndef USE_CHDIR_FALLBACK #ifndef USE_CHDIR_FALLBACK
#warning mkfifoat missing - link* calls on long paths may fail #warning mkfifoat missing - link* calls on long paths may fail
int int
mkfifol(const char *name, mode_t mode) { our(mkfifo)(const char *name, mode_t mode) {
return mkfifo(name, mode); return real(mkfifo)(name, mode);
} }
#else /* USE_CHDIR_FALLBACK */ #else /* USE_CHDIR_FALLBACK */
#undef NEED_CHDIR #undef NEED_CHDIR
#define NEED_CHDIR #define NEED_CHDIR
int int
mkfifol(const char *name, mode_t mode) { our(mkfifo)(const char *name, mode_t mode) {
Xl(mkfifo, name, mode); Xl(real(mkfifo), name, mode);
} }
#endif /* USE_CHDIR_FALLBACK */ #endif /* USE_CHDIR_FALLBACK */
#endif /* HAVE_MKFIFOAT */ #endif /* HAVE_MKFIFOAT */
...@@ -703,74 +720,74 @@ mkfifol(const char *name, mode_t mode) { ...@@ -703,74 +720,74 @@ mkfifol(const char *name, mode_t mode) {
/* STAT */ /* STAT */
int int
fstatatl(int fd, const char *name, struct stat *sb, int flags) { our(fstatat)(int fd, const char *name, struct stat *sb, int flags) {
Xatl(fstatat, fd, name, sb, flags); Xatl(real(fstatat), fd, name, sb, flags);
} }
int int
statl(const char *name, struct stat *sb) { our(stat)(const char *name, struct stat *sb) {
return fstatatl(AT_FDCWD, name, sb, 0); return our(fstatat)(AT_FDCWD, name, sb, 0);
} }
int int
lstatl(const char *name, struct stat *sb) { our(lstat)(const char *name, struct stat *sb) {
return fstatatl(AT_FDCWD, name, sb, AT_SYMLINK_NOFOLLOW); return our(fstatat)(AT_FDCWD, name, sb, AT_SYMLINK_NOFOLLOW);
} }
#if !defined(_LP64) #if !defined(_LP64)
int int
fstatatl64(int fd, const char *name, struct stat64 *sb, int flags) { our64(fstatat)(int fd, const char *name, struct stat64 *sb, int flags) {
Xatl(fstatat64, fd, name, sb, flags); Xatl(real64(fstatat), fd, name, sb, flags);
} }
int int
statl64(const char *name, struct stat64 *sb) { our64(stat)(const char *name, struct stat64 *sb) {
return fstatatl64(AT_FDCWD, name, sb, 0); return our64(fstatat)(AT_FDCWD, name, sb, 0);
} }
int int
lstatl64(const char *name, struct stat64 *sb) { our64(lstat)(const char *name, struct stat64 *sb) {
return fstatatl64(AT_FDCWD, name, sb, AT_SYMLINK_NOFOLLOW); return our64(fstatat)(AT_FDCWD, name, sb, AT_SYMLINK_NOFOLLOW);
} }
#endif #endif
/* RMDIR */ /* RMDIR */
int int
rmdiratl(int fd, const char *name) { our(rmdirat)(int fd, const char *name) {
return unlinkatl(fd, name, AT_REMOVEDIR); return our(unlinkat)(fd, name, AT_REMOVEDIR);
} }
int int
rmdirl(const char *name) { our(rmdir)(const char *name) {
return rmdiratl(AT_FDCWD, name); return our(rmdirat)(AT_FDCWD, name);
} }
/* MKDIR */ /* MKDIR */
#ifdef HAVE_MKDIRAT #ifdef HAVE_MKDIRAT
int int
mkdiratl(int fd, const char *name, mode_t mode) { our(mkdirat)(int fd, const char *name, mode_t mode) {
Xatl(mkdirat, fd, name, mode); Xatl(real(mkdirat), fd, name, mode);
} }
int int
mkdirl(const char *name, mode_t mode) { our(mkdir)(const char *name, mode_t mode) {
return mkdiratl(AT_FDCWD, name, mode); return our(mkdirat)(AT_FDCWD, name, mode);
} }
#else /* HAVE_MKDIRAT */ #else /* HAVE_MKDIRAT */
#ifndef USE_CHDIR_FALLBACK #ifndef USE_CHDIR_FALLBACK
#warning mkdirat missing - link* calls on long paths may fail #warning mkdirat missing - link* calls on long paths may fail
int int
mkdirl(const char *name, mode_t mode) { our(mkdir)(const char *name, mode_t mode) {
return mkdir(name, mode); return real(mkdir)(name, mode);
} }
#else /* USE_CHDIR_FALLBACK */ #else /* USE_CHDIR_FALLBACK */
#undef NEED_CHDIR #undef NEED_CHDIR
#define NEED_CHDIR #define NEED_CHDIR
int int
mkdirl(const char *name, mode_t mode) { our(mkdir)(const char *name, mode_t mode) {
Xl(mkdir, name, mode); Xl(real(mkdir), name, mode);
} }
#endif /* USE_CHDIR_FALLBACK */ #endif /* USE_CHDIR_FALLBACK */
#endif /* HAVE_MKDIRAT */ #endif /* HAVE_MKDIRAT */
...@@ -778,13 +795,13 @@ mkdirl(const char *name, mode_t mode) { ...@@ -778,13 +795,13 @@ mkdirl(const char *name, mode_t mode) {
/* RENAME */ /* RENAME */
int int
renameatl(int fd1, const char *p1, int fd2, const char *p2) { our(renameat)(int fd1, const char *p1, int fd2, const char *p2) {
Xatl2(renameat, fd1, p1, fd2, p2); Xatl2(real(renameat), fd1, p1, fd2, p2);
} }
int int
renamel(const char *p1, const char *p2) { our(rename)(const char *p1, const char *p2) {
return renameatl(AT_FDCWD, p1, AT_FDCWD, p2); return our(renameat)(AT_FDCWD, p1, AT_FDCWD, p2);
} }
...@@ -821,7 +838,11 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) { ...@@ -821,7 +838,11 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) {
int ifd, fd; int ifd, fd;
char *rest; char *rest;
char *save, *r, *spos; char *save, *r, *spos;
struct six4(stat) tstat; #if defined(_LP64)
struct stat tstat;
#else
struct stat64 tstat;
#endif
if (slen < 0 || template == NULL || *template == '\0') { if (slen < 0 || template == NULL || *template == '\0') {
errno = EINVAL; errno = EINVAL;
...@@ -895,32 +916,32 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) { ...@@ -895,32 +916,32 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) {
case T_DIR: case T_DIR:
{ {
#ifdef HAVE_MKDIRAT #ifdef HAVE_MKDIRAT
if (mkdirat(ifd, rest, 0700) == 0) { if (real(mkdirat)(ifd, rest, 0700) == 0) {
fd = AT_FDCWD; fd = AT_FDCWD;
goto out; goto out;
} }
#else /* HAVE_MKDIRAT */ #else /* HAVE_MKDIRAT */
#ifndef USE_CHDIR_FALLBACK #ifndef USE_CHDIR_FALLBACK
#warning mkdirat missing - mkdtemp* calls on long paths may fail #warning mkdirat missing - mkdtemp* calls on long paths may fail
if (mkdtemp(template)) { if (real(mkdtemp)(template)) {
fd = AT_FDCWD; fd = AT_FDCWD;
goto out; goto out;
} }
goto err; goto err;
#else /* USE_CHDIR_FALLBACK */ #else /* USE_CHDIR_FALLBACK */
if (ifd == AT_FDCWD) { if (ifd == AT_FDCWD) {
if (mkdir(rest, 0700) == 0) { if (real(mkdir)(rest, 0700) == 0) {
fd = AT_FDCWD; fd = AT_FDCWD;
goto out; goto out;
} }
} else { } else {
int ocwd; int ocwd;
ocwd = open(".", O_RDONLY|O_NDELAY|O_LARGEFILE); ocwd = real(open)(".", O_RDONLY|O_NDELAY|O_LARGEFILE);
if (ocwd == -1) if (ocwd == -1)
goto err; goto err;
if (fchdir(ifd) == -1) if (fchdir(ifd) == -1)
goto err; goto err;
if (mkdir(rest, 0700) == 0) { if (real(mkdir)(rest, 0700) == 0) {
restore_cwd(&ocwd); restore_cwd(&ocwd);
fd = AT_FDCWD; fd = AT_FDCWD;
goto out; goto out;
...@@ -933,7 +954,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) { ...@@ -933,7 +954,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) {
break; /* retry */ break; /* retry */
} }
case T_FILE: case T_FILE:
fd = openat(ifd, rest, O_CREAT|O_EXCL|O_RDWR|flags, 0600); fd = real(openat)(ifd, rest, O_CREAT|O_EXCL|O_RDWR|flags, 0600);
if (fd != -1) if (fd != -1)
goto out; goto out;
...@@ -941,7 +962,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) { ...@@ -941,7 +962,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) {
break; /* retry */ break; /* retry */
#if !defined(_LP64) #if !defined(_LP64)
case T_FILE64: case T_FILE64:
fd = openat64(ifd, rest, O_CREAT|O_EXCL|O_RDWR|flags, 0600); fd = real64(openat)(ifd, rest, O_CREAT|O_EXCL|O_RDWR|flags, 0600);
if (fd != -1) if (fd != -1)
goto out; goto out;
...@@ -951,7 +972,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) { ...@@ -951,7 +972,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) {
case T_NOCREATE: case T_NOCREATE:
{ {
int serrno = errno; int serrno = errno;
if (six4(fstatatl)(ifd, rest, &tstat, AT_SYMLINK_NOFOLLOW) == -1) { if (our64(fstatat)(ifd, rest, &tstat, AT_SYMLINK_NOFOLLOW) == -1) {
if (errno != ENOENT) if (errno != ENOENT)
goto err; goto err;
...@@ -991,7 +1012,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) { ...@@ -991,7 +1012,7 @@ _mkxtempl(char *template, int slen, int flags, enum temp_kind kind) {
*/ */
char * char *
mktempl(char *template) { our(mktemp)(char *template) {
int serrno = errno; int serrno = errno;
if (_mkxtempl(template, 0, 0, T_NOCREATE) == -1) if (_mkxtempl(template, 0, 0, T_NOCREATE) == -1)
return NULL; return NULL;
...@@ -1000,50 +1021,50 @@ mktempl(char *template) { ...@@ -1000,50 +1021,50 @@ mktempl(char *template) {
} }
char * char *
mkdtempl(char *template) { our(mkdtemp)(char *template) {
if (_mkxtempl(template, 0, 0, T_DIR) == -1) if (_mkxtempl(template, 0, 0, T_DIR) == -1)
return NULL; return NULL;
return template; return template;
} }
int int
mkstempl(char *template) { our(mkstemp)(char *template) {
return _mkxtempl(template, 0, 0, T_FILE); return _mkxtempl(template, 0, 0, T_FILE);
} }
int int
mkstempsl(char *template, int slen) { our(mkstemps)(char *template, int slen) {
return _mkxtempl(template, slen, 0, T_FILE); return _mkxtempl(template, slen, 0, T_FILE);
} }
int int
mkostempl(char *template, int flags) { our(mkostemp)(char *template, int flags) {
return _mkxtempl(template, 0, flags, T_FILE); return _mkxtempl(template, 0, flags, T_FILE);
} }
int int
mkostempsl(char *template, int slen, int flags) { our(mkostemps)(char *template, int slen, int flags) {
return _mkxtempl(template, slen, flags, T_FILE); return _mkxtempl(template, slen, flags, T_FILE);
} }
#if !defined(_LP64) #if !defined(_LP64)
int int
mkstempl64(char *template) { our64(mkstemp)(char *template) {
return _mkxtempl(template, 0, 0, T_FILE64); return _mkxtempl(template, 0, 0, T_FILE64);
} }
int int
mkstempsl64(char *template, int slen) { our64(mkstemps)(char *template, int slen) {
return _mkxtempl(template, slen, 0, T_FILE64); return _mkxtempl(template, slen, 0, T_FILE64);
} }
int int
mkostempl64(char *template, int flags) { our64(mkostemp)(char *template, int flags) {
return _mkxtempl(template, 0, flags, T_FILE64); return _mkxtempl(template, 0, flags, T_FILE64);
} }
int int
mkostempsl64(char *template, int slen, int flags) { our64(mkostemps)(char *template, int slen, int flags) {
return _mkxtempl(template, slen, flags, T_FILE64); return _mkxtempl(template, slen, flags, T_FILE64);
} }
#endif #endif
...@@ -1063,8 +1084,8 @@ mkostempsl64(char *template, int slen, int flags) { ...@@ -1063,8 +1084,8 @@ mkostempsl64(char *template, int slen, int flags) {
*/ */
int int
utimensatl(int fd, const char *path, const struct timespec times[2], int flag) { our(utimensat)(int fd, const char *path, const struct timespec times[2], int flag) {
Xatl(utimensat, fd, path, times, flag); Xatl(real(utimensat), fd, path, times, flag);
} }
...@@ -1092,40 +1113,40 @@ tv2ts(struct timespec **tsp, const struct timeval tv[2]) { ...@@ -1092,40 +1113,40 @@ tv2ts(struct timespec **tsp, const struct timeval tv[2]) {
* *
*/ */
int int
futimesatl(int filedes, const char *path, const struct timeval tv[2]) { our(futimesat)(int filedes, const char *path, const struct timeval tv[2]) {
struct timespec ts[2]; struct timespec ts[2];
struct timespec *tsp = ts; struct timespec *tsp = ts;
tv2ts(&tsp, tv); tv2ts(&tsp, tv);
if (path == NULL) if (path == NULL)
return futimens(filedes, tsp); return real(futimens)(filedes, tsp);
return utimensatl(filedes, path, tsp, 0); return our(utimensat)(filedes, path, tsp, 0);
} }
int int
utimesl(const char *path, const struct timeval tv[2]) { our(utimes)(const char *path, const struct timeval tv[2]) {
struct timespec ts[2]; struct timespec ts[2];
struct timespec *tsp = ts; struct timespec *tsp = ts;
tv2ts(&tsp, tv); tv2ts(&tsp, tv);
return utimensatl(AT_FDCWD, path, tsp, 0); return our(utimensat)(AT_FDCWD, path, tsp, 0);
} }
int int
lutimesl(const char *path, const struct timeval tv[2]) { our(lutimes)(const char *path, const struct timeval tv[2]) {
struct timespec ts[2]; struct timespec ts[2];
struct timespec *tsp = ts; struct timespec *tsp = ts;
tv2ts(&tsp, tv); tv2ts(&tsp, tv);
return utimensatl(AT_FDCWD, path, tsp, AT_SYMLINK_NOFOLLOW); return our(utimensat)(AT_FDCWD, path, tsp, AT_SYMLINK_NOFOLLOW);
} }
int int
utimel(const char *path, const struct utimbuf *times) { our(utime)(const char *path, const struct utimbuf *times) {
if (times) { if (times) {
struct timespec ts[2]; struct timespec ts[2];
...@@ -1135,15 +1156,15 @@ utimel(const char *path, const struct utimbuf *times) { ...@@ -1135,15 +1156,15 @@ utimel(const char *path, const struct utimbuf *times) {
ts[1].tv_sec = times->modtime; ts[1].tv_sec = times->modtime;
ts[1].tv_nsec = 0; ts[1].tv_nsec = 0;
return utimensatl(AT_FDCWD, path, ts, 0); return our(utimensat)(AT_FDCWD, path, ts, 0);
} }
return utimensatl(AT_FDCWD, path, NULL, 0); return our(utimensat)(AT_FDCWD, path, NULL, 0);
} }
/* OPENDIR */ /* OPENDIR */
DIR * DIR *
opendirl(const char *dirname) { our(opendir)(const char *dirname) {
int fd; int fd;
/* almost identical to Xfl, but we must not close the fd */ /* almost identical to Xfl, but we must not close the fd */
fd = _openatl(AT_FDCWD, dirname, O_RDONLY|O_NDELAY|O_LARGEFILE, 0); fd = _openatl(AT_FDCWD, dirname, O_RDONLY|O_NDELAY|O_LARGEFILE, 0);
...@@ -1151,7 +1172,7 @@ opendirl(const char *dirname) { ...@@ -1151,7 +1172,7 @@ opendirl(const char *dirname) {
if (fd == -1) if (fd == -1)
return NULL; return NULL;
return fdopendir(fd); return real(fdopendir)(fd);
} }
#ifdef NEED_CHDIR #ifdef NEED_CHDIR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment