Wrap POSIX FD functions in libroot_build
This makes opening symlinks work universally in the build system tools. Two mechanisms have been implemented, both of which don't always work. The first is remapping via preprocessor macros. This fails where equally named methods are used (e.g. STL fstream::open()). The other is using hidden functions in the new libroot_build_function_remapper.a that is linked into everything that is linked against libroot_build.so. This one fails for functions that are defined inline in headers (Linux/glibc does that). Together they seem to cover our build system needs ATM.
This commit is contained in:
@@ -32,9 +32,12 @@ typedef unsigned long haiku_build_addr_t;
|
||||
#include <Errors.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -91,6 +94,90 @@ extern char* _haiku_build_strerror(int errnum);
|
||||
|
||||
#endif // BUILDING_HAIKU_ERROR_MAPPER
|
||||
|
||||
|
||||
// remap file descriptor functions
|
||||
int _haiku_build_fchmod(int fd, mode_t mode);
|
||||
int _haiku_build_fchmodat(int fd, const char* path, mode_t mode, int flag);
|
||||
int _haiku_build_fstat(int fd, struct stat* st);
|
||||
int _haiku_build_fstatat(int fd, const char* path, struct stat* st,
|
||||
int flag);
|
||||
int _haiku_build_mkdirat(int fd, const char* path, mode_t mode);
|
||||
int _haiku_build_mkfifoat(int fd, const char* path, mode_t mode);
|
||||
int _haiku_build_utimensat(int fd, const char* path,
|
||||
const struct timespec times[2], int flag);
|
||||
int _haiku_build_futimens(int fd, const struct timespec times[2]);
|
||||
int _haiku_build_faccessat(int fd, const char* path, int accessMode,
|
||||
int flag);
|
||||
int _haiku_build_fchdir(int fd);
|
||||
int _haiku_build_close(int fd);
|
||||
int _haiku_build_dup(int fd);
|
||||
int _haiku_build_dup2(int fd1, int fd2);
|
||||
int _haiku_build_linkat(int toFD, const char* toPath, int pathFD,
|
||||
const char* path, int flag);
|
||||
int _haiku_build_unlinkat(int fd, const char* path, int flag);
|
||||
ssize_t _haiku_build_readlinkat(int fd, const char* path, char* buffer,
|
||||
size_t bufferSize);
|
||||
int _haiku_build_symlinkat(const char* toPath, int fd,
|
||||
const char* symlinkPath);
|
||||
int _haiku_build_ftruncate(int fd, off_t newSize);
|
||||
int _haiku_build_fchown(int fd, uid_t owner, gid_t group);
|
||||
int _haiku_build_fchownat(int fd, const char* path, uid_t owner,
|
||||
gid_t group, int flag);
|
||||
int _haiku_build_mknodat(int fd, const char* name, mode_t mode, dev_t dev);
|
||||
int _haiku_build_creat(const char* path, mode_t mode);
|
||||
#ifndef _HAIKU_BUILD_DONT_REMAP_FD_FUNCTIONS
|
||||
int _haiku_build_open(const char* path, int openMode, ...);
|
||||
int _haiku_build_openat(int fd, const char* path, int openMode, ...);
|
||||
int _haiku_build_fcntl(int fd, int op, ...);
|
||||
#else
|
||||
int _haiku_build_open(const char* path, int openMode, mode_t permissions);
|
||||
int _haiku_build_openat(int fd, const char* path, int openMode,
|
||||
mode_t permissions);
|
||||
int _haiku_build_fcntl(int fd, int op, int argument);
|
||||
#endif
|
||||
int _haiku_build_renameat(int fromFD, const char* from, int toFD,
|
||||
const char* to);
|
||||
|
||||
#ifndef _HAIKU_BUILD_DONT_REMAP_FD_FUNCTIONS
|
||||
# define fchmod(fd, mode) _haiku_build_fchmod(fd, mode)
|
||||
# define fchmodat(fd, path, mode, flag) \
|
||||
_haiku_build_fchmodat(fd, path, mode, flag)
|
||||
# define fstat(fd, st) _haiku_build_fstat(fd, st)
|
||||
# define fstatat(fd, path, st, flag) _haiku_build_fstatat(fd, path, st, flag)
|
||||
# define mkdirat(fd, path, mode) _haiku_build_mkdirat(fd, path, mode)
|
||||
# define mkfifoat(fd, path, mode) _haiku_build_mkfifoat(fd, path, mode)
|
||||
# define utimensat(fd, path, times, flag) \
|
||||
_haiku_build_utimensat(fd, path, times, flag)
|
||||
# define futimens(fd, times) _haiku_build_futimens(fd, times)
|
||||
# define faccessat(fd, path, accessMode, flag) \
|
||||
_haiku_build_faccessat(fd, path, accessMode, flag)
|
||||
# define fchdir(fd) _haiku_build_fchdir(fd)
|
||||
# define close(fd) _haiku_build_close(fd)
|
||||
# define dup(fd) _haiku_build_dup(fd)
|
||||
# define dup2(fd1, fd2) _haiku_build_dup2(fd1, fd2)
|
||||
# define linkat(toFD, toPath, pathFD, path, flag) \
|
||||
_haiku_build_linkat(toFD, toPath, pathFD, path, flag)
|
||||
# define unlinkat(fd, path, flag) _haiku_build_unlinkat(fd, path, flag)
|
||||
# define readlinkat(fd, path, buffer, bufferSize) \
|
||||
_haiku_build_readlinkat(fd, path, buffer, bufferSize)
|
||||
# define symlinkat(toPath, fd, symlinkPath) \
|
||||
_haiku_build_symlinkat(toPath, fd, symlinkPath)
|
||||
# define ftruncate(fd, newSize) _haiku_build_ftruncate(fd, newSize)
|
||||
# define fchown(fd, owner, group) _haiku_build_fchown(fd, owner, group)
|
||||
# define fchownat(fd, path, owner, group, flag) \
|
||||
_haiku_build_fchownat(fd, path, owner, group, flag)
|
||||
# define mknodat(fd, name, mode, dev) \
|
||||
_haiku_build_mknodat(fd, name, mode, dev)
|
||||
# define creat(path, mode) _haiku_build_creat(path, mode)
|
||||
# define open(path, openMode...) _haiku_build_open(path, openMode)
|
||||
# define openat(fd, path, openMode...) \
|
||||
_haiku_build_openat(fd, path, openMode)
|
||||
# define fcntl(fd, op...) _haiku_build_fcntl(fd, op)
|
||||
# define renameat(fromFD, from, toFD, to) \
|
||||
_haiku_build_renameat(fromFD, from, toFD, to)
|
||||
#endif // _HAIKU_BUILD_DONT_REMAP_FD_FUNCTIONS
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user