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)
/* lstat */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG_2) || defined(__EXTENSIONS__)
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)
#endif
......
......@@ -64,11 +64,6 @@
#else
#define _FILE_OFFSET_BITS 32
#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
#include <assert.h>
......@@ -76,8 +71,6 @@
#define assert(EX) ((void)0)
#endif
// XXX conditional includes incomplete
// string functions
#if defined(HAVE_STRING_H)
#include <string.h>
......@@ -100,7 +93,6 @@
#include <stdarg.h>
#endif
// opendir
#ifdef HAVE_DIRENT_H
#include <dirent.h>
......@@ -116,7 +108,8 @@
# define real64(x) real_ ## x ## 64
# define our(x) x
# define our64(x) x ## 64
#else
#else /* ! INTERPOSE */
#include <longpath/longpath.h>
# define real(x) x
# if defined(_LP64)
# define real64(x) x
......@@ -129,11 +122,13 @@
# else
# define our64(x) x ## l ## 64
# 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)
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
/*
......@@ -318,7 +313,7 @@ oatl_im(int filedes, const char *path, const char **remaining) {
#define Xfl(path, flags, err, r, funcn, ...) \
int __ifd; \
\
__ifd = our64(_openat)(AT_FDCWD, (path), \
__ifd = _openat64(AT_FDCWD, (path), \
O_RDONLY|O_NDELAY|O_LARGEFILE|(flags), 0); \
\
if (__ifd == -1) \
......@@ -330,13 +325,13 @@ oatl_im(int filedes, const char *path, const char **remaining) {
/* OPEN */
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);
}
#if !defined(_LP64)
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);
}
#endif
......@@ -350,7 +345,7 @@ our64(_openat)(int filedes, const char *path, int oflag, mode_t mode) {
va_end(arg); \
} \
\
return _openatl ## bits (filedes, path, oflag, mode)
return _openat ## bits (filedes, path, oflag, mode)
int
our(openat)(int filedes, const char *path, int oflag, ...) {
......@@ -373,7 +368,7 @@ our64(openat)(int filedes, const char *path, int oflag, ...) {
va_end(arg); \
} \
\
return _openatl ## bits (AT_FDCWD, path, oflag, mode)
return _openat ## bits (AT_FDCWD, path, oflag, mode)
int
......@@ -391,18 +386,16 @@ our64(open)(const char *path, int oflag, ...) {
int
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)
int
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
/* ATTROPEN */
/* Solaris specific ? */
#ifdef HAVE_ATTROPEN
#define Attropenl(bits) \
int fd, afd; \
......@@ -413,7 +406,7 @@ our64(creat)(const char *path, mode_t mode) {
return -1; \
\
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_end(ap); \
\
......@@ -614,21 +607,21 @@ our(readlinkat)(int fd, const char *name, char *buf, size_t count) {
Xatl(real(readlinkat), fd, name, buf, count);
}
int
ssize_t
our(readlink)(const char *name, char *buf, size_t count) {
return our(readlinkat)(AT_FDCWD, name, buf, count);
}
#else /* HAVE_READLINKAT */
#ifndef USE_CHDIR_FALLBACK
#warning readlinkat missing - link* calls on long paths may fail
int
ssize_t
our(readlink)(const char *name, char *buf, size_t count) {
return real(readlink)(name, buf, count);
}
#else /* USE_CHDIR_FALLBACK */
#undef NEED_CHDIR
#define NEED_CHDIR
int
ssize_t
our(readlink)(const char *name, char *buf, size_t count) {
Xl(real(readlink), name, buf, count);
}
......@@ -1167,7 +1160,7 @@ DIR *
our(opendir)(const char *dirname) {
int 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)
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