Commit f13da48d authored by Nils Goroll's avatar Nils Goroll

our() macros don't work for our internal _openat, fix readlink type and struct...

our() macros don't work for our internal _openat, fix readlink type and struct stat, more interpose prep
parent 589394f0
...@@ -49,7 +49,7 @@ FUNCTION(int, utimensat, int, const char *, const struct timespec *, int) ...@@ -49,7 +49,7 @@ FUNCTION(int, utimensat, int, const char *, const struct timespec *, int)
/* lstat */ /* lstat */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__) #if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
FUNCTION(int, symlink, const char *, const char *) FUNCTION(int, symlink, const char *, const char *)
FUNCTION(size_t, readlink, const char *, char *, size_t) FUNCTION(ssize_t, readlink, const char *, char *, size_t)
FUNCTION(int, lchown, const char *, uid_t, gid_t) FUNCTION(int, lchown, const char *, uid_t, gid_t)
#endif #endif
......
...@@ -64,11 +64,6 @@ ...@@ -64,11 +64,6 @@
#else #else
#define _FILE_OFFSET_BITS 32 #define _FILE_OFFSET_BITS 32
#endif #endif
//// no use to undef these - solaris sys/feature_tests.h sets to 1
//#undef _LARGEFILE_SOURCE
//#undef _LARGEFILE64_SOURCE
#include <longpath/longpath.h>
#ifdef HAVE_ASSERT_H #ifdef HAVE_ASSERT_H
#include <assert.h> #include <assert.h>
...@@ -76,8 +71,6 @@ ...@@ -76,8 +71,6 @@
#define assert(EX) ((void)0) #define assert(EX) ((void)0)
#endif #endif
// XXX conditional includes incomplete
// string functions // string functions
#if defined(HAVE_STRING_H) #if defined(HAVE_STRING_H)
#include <string.h> #include <string.h>
...@@ -100,7 +93,6 @@ ...@@ -100,7 +93,6 @@
#include <stdarg.h> #include <stdarg.h>
#endif #endif
// opendir // opendir
#ifdef HAVE_DIRENT_H #ifdef HAVE_DIRENT_H
#include <dirent.h> #include <dirent.h>
...@@ -116,7 +108,8 @@ ...@@ -116,7 +108,8 @@
# define real64(x) real_ ## x ## 64 # define real64(x) real_ ## x ## 64
# define our(x) x # define our(x) x
# define our64(x) x ## 64 # define our64(x) x ## 64
#else #else /* ! INTERPOSE */
#include <longpath/longpath.h>
# define real(x) x # define real(x) x
# if defined(_LP64) # if defined(_LP64)
# define real64(x) x # define real64(x) x
...@@ -129,11 +122,13 @@ ...@@ -129,11 +122,13 @@
# else # else
# define our64(x) x ## l ## 64 # define our64(x) x ## l ## 64
# endif # endif
#endif #endif /* INTERPOSE */
static int our(_openat)(int, const char *, int, mode_t mode); static int _openat(int, const char *, int, mode_t mode);
#if !defined(_LP64) #if !defined(_LP64)
static int our64(_openat)(int, const char *, int, mode_t mode); static int _openat64(int, const char *, int, mode_t mode);
#else
#define _openat64(fd, p, f, m) _openat(fd, p, f, m)
#endif #endif
/* /*
...@@ -318,7 +313,7 @@ oatl_im(int filedes, const char *path, const char **remaining) { ...@@ -318,7 +313,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 = our64(_openat)(AT_FDCWD, (path), \ __ifd = _openat64(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) \
...@@ -330,13 +325,13 @@ oatl_im(int filedes, const char *path, const char **remaining) { ...@@ -330,13 +325,13 @@ oatl_im(int filedes, const char *path, const char **remaining) {
/* OPEN */ /* OPEN */
static int static int
our(_openat)(int filedes, const char *path, int oflag, mode_t mode) { _openat(int filedes, const char *path, int oflag, mode_t mode) {
Xatl(real(openat), filedes, path, oflag, mode); Xatl(real(openat), filedes, path, oflag, mode);
} }
#if !defined(_LP64) #if !defined(_LP64)
static int static int
our64(_openat)(int filedes, const char *path, int oflag, mode_t mode) { _openat64(int filedes, const char *path, int oflag, mode_t mode) {
Xatl(real64(openat), filedes, path, oflag, mode); Xatl(real64(openat), filedes, path, oflag, mode);
} }
#endif #endif
...@@ -350,7 +345,7 @@ our64(_openat)(int filedes, const char *path, int oflag, mode_t mode) { ...@@ -350,7 +345,7 @@ our64(_openat)(int filedes, const char *path, int oflag, mode_t mode) {
va_end(arg); \ va_end(arg); \
} \ } \
\ \
return _openatl ## bits (filedes, path, oflag, mode) return _openat ## bits (filedes, path, oflag, mode)
int int
our(openat)(int filedes, const char *path, int oflag, ...) { our(openat)(int filedes, const char *path, int oflag, ...) {
...@@ -373,7 +368,7 @@ our64(openat)(int filedes, const char *path, int oflag, ...) { ...@@ -373,7 +368,7 @@ our64(openat)(int filedes, const char *path, int oflag, ...) {
va_end(arg); \ va_end(arg); \
} \ } \
\ \
return _openatl ## bits (AT_FDCWD, path, oflag, mode) return _openat ## bits (AT_FDCWD, path, oflag, mode)
int int
...@@ -391,18 +386,16 @@ our64(open)(const char *path, int oflag, ...) { ...@@ -391,18 +386,16 @@ our64(open)(const char *path, int oflag, ...) {
int int
our(creat)(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 _openat(AT_FDCWD, path, O_WRONLY|O_CREAT|O_TRUNC, mode);
} }
#if !defined(_LP64) #if !defined(_LP64)
int int
our64(creat)(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 _openat64(AT_FDCWD, path, O_WRONLY|O_CREAT|O_TRUNC, mode);
} }
#endif #endif
/* ATTROPEN */ /* ATTROPEN */
/* Solaris specific ? */
#ifdef HAVE_ATTROPEN #ifdef HAVE_ATTROPEN
#define Attropenl(bits) \ #define Attropenl(bits) \
int fd, afd; \ int fd, afd; \
...@@ -413,7 +406,7 @@ our64(creat)(const char *path, mode_t mode) { ...@@ -413,7 +406,7 @@ our64(creat)(const char *path, mode_t mode) {
return -1; \ return -1; \
\ \
va_start(ap, oflag); \ va_start(ap, oflag); \
afd = _openatl ## bits (fd, apath, oflag|O_XATTR, \ afd = _openat ## bits (fd, apath, oflag|O_XATTR, \
va_arg(ap, mode_t)); \ va_arg(ap, mode_t)); \
va_end(ap); \ va_end(ap); \
\ \
...@@ -614,21 +607,21 @@ our(readlinkat)(int fd, const char *name, char *buf, size_t count) { ...@@ -614,21 +607,21 @@ our(readlinkat)(int fd, const char *name, char *buf, size_t count) {
Xatl(real(readlinkat), fd, name, buf, count); Xatl(real(readlinkat), fd, name, buf, count);
} }
int ssize_t
our(readlink)(const char *name, char *buf, size_t count) { our(readlink)(const char *name, char *buf, size_t count) {
return our(readlinkat)(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 ssize_t
our(readlink)(const char *name, char *buf, size_t count) { our(readlink)(const char *name, char *buf, size_t count) {
return real(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 ssize_t
our(readlink)(const char *name, char *buf, size_t count) { our(readlink)(const char *name, char *buf, size_t count) {
Xl(real(readlink), name, buf, count); Xl(real(readlink), name, buf, count);
} }
...@@ -1167,7 +1160,7 @@ DIR * ...@@ -1167,7 +1160,7 @@ DIR *
our(opendir)(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 = _openat(AT_FDCWD, dirname, O_RDONLY|O_NDELAY|O_LARGEFILE, 0);
if (fd == -1) if (fd == -1)
return NULL; return NULL;
......
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