libroot_build: Properly remap fs_attr_* functions.
This was done using macros before, which isn't the way we have things set up. In theory that method should work, however if not all consumers include the libroot_build headers properly, then it breaks in subtle but confusing ways, which is not what we want at all. Thanks to Jessica for advice. Change-Id: Idd45df5547daecf8239932957088da03ddfccf87
This commit is contained in:
committed by
waddlesplash
parent
88c1a9d048
commit
648f0d5f08
@@ -179,6 +179,22 @@ int _haiku_build_renameat(int fromFD, const char* from, int toFD,
|
||||
# define fcntl(fd, op...) _haiku_build_fcntl(fd, op)
|
||||
# define renameat(fromFD, from, toFD, to) \
|
||||
_haiku_build_renameat(fromFD, from, toFD, to)
|
||||
|
||||
# if defined(HAIKU_HOST_USE_XATTR) && defined(HAIKU_HOST_PLATFORM_HAIKU)
|
||||
# define fs_read_attr _haiku_build_fs_read_attr
|
||||
# define fs_write_attr _haiku_build_fs_write_attr
|
||||
# define fs_remove_attr _haiku_build_fs_remove_attr
|
||||
# define fs_stat_attr _haiku_build_fs_stat_attr
|
||||
# define fs_open_attr _haiku_build_fs_open_attr
|
||||
# define fs_fopen_attr _haiku_build_fs_fopen_attr
|
||||
# define fs_close_attr _haiku_build_fs_close_attr
|
||||
# define fs_open_attr_dir _haiku_build_fs_open_attr_dir
|
||||
# define fs_fopen_attr_dir _haiku_build_fs_fopen_attr_dir
|
||||
# define fs_close_attr_dir _haiku_build_fs_close_attr_dir
|
||||
# define fs_read_attr_dir _haiku_build_fs_read_attr_dir
|
||||
# define fs_rewind_attr_dir _haiku_build_fs_rewind_attr_dir
|
||||
# endif
|
||||
|
||||
#endif // _HAIKU_BUILD_DONT_REMAP_FD_FUNCTIONS
|
||||
|
||||
|
||||
|
||||
@@ -21,24 +21,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Since libroot_build is also used on Haiku and linked against the real
|
||||
* libroot which also has the fs*attr functions, these must be shadowed. */
|
||||
#ifndef BUILDING_FS_ATTR_HAIKU
|
||||
#define fs_read_attr build_fs_read_attr
|
||||
#define fs_write_attr build_fs_write_attr
|
||||
#define fs_remove_attr build_fs_remove_attr
|
||||
#define fs_stat_attr build_fs_stat_attr
|
||||
#define fs_open_attr build_fs_open_attr
|
||||
#define fs_fopen_attr build_fs_fopen_attr
|
||||
#define fs_close_attr build_fs_close_attr
|
||||
#define fs_open_attr_dir build_fs_open_attr_dir
|
||||
#define fs_fopen_attr_dir build_fs_fopen_attr_dir
|
||||
#define fs_close_attr_dir build_fs_close_attr_dir
|
||||
#define fs_read_attr_dir build_fs_read_attr_dir
|
||||
#define fs_rewind_attr_dir build_fs_rewind_attr_dir
|
||||
#endif
|
||||
|
||||
|
||||
extern ssize_t fs_read_attr(int fd, const char *attribute, uint32 type,
|
||||
off_t pos, void *buffer, size_t readBytes);
|
||||
extern ssize_t fs_write_attr(int fd, const char *attribute, uint32 type,
|
||||
@@ -54,6 +36,7 @@ extern int fs_fopen_attr(int fd, const char *attribute, uint32 type,
|
||||
extern int fs_close_attr(int fd);
|
||||
|
||||
extern DIR *fs_open_attr_dir(const char *path);
|
||||
extern DIR *fs_lopen_attr_dir(const char *path);
|
||||
extern DIR *fs_fopen_attr_dir(int fd);
|
||||
extern int fs_close_attr_dir(DIR *dir);
|
||||
extern struct dirent *fs_read_attr_dir(DIR *dir);
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
/*! Shim over the host Haiku fs_attr API */
|
||||
|
||||
#define BUILDING_FS_ATTR_HAIKU
|
||||
// so build fs_attr.h will not shadow the fs*attr functions
|
||||
|
||||
|
||||
#ifdef BUILDING_FS_SHELL
|
||||
# include "compat.h"
|
||||
@@ -55,15 +52,21 @@ namespace {
|
||||
|
||||
// fs_open_attr_dir
|
||||
extern "C" DIR *
|
||||
build_fs_open_attr_dir(const char *path)
|
||||
_haiku_build_fs_open_attr_dir(const char *path)
|
||||
{
|
||||
return fs_open_attr_dir(path);
|
||||
}
|
||||
|
||||
// fs_fopen_attr_dir
|
||||
extern "C" DIR* fs_lopen_attr_dir(const char *path);
|
||||
// fs_lopen_attr_dir
|
||||
extern "C" DIR*
|
||||
build_fs_fopen_attr_dir(int fd)
|
||||
_haiku_build_fs_lopen_attr_dir(const char *path)
|
||||
{
|
||||
return fs_lopen_attr_dir(path);
|
||||
}
|
||||
|
||||
// fs_fopen_attr_dir
|
||||
extern "C" DIR*
|
||||
_haiku_build_fs_fopen_attr_dir(int fd)
|
||||
{
|
||||
LocalFD localFD;
|
||||
status_t error = localFD.Init(fd);
|
||||
@@ -81,28 +84,28 @@ build_fs_fopen_attr_dir(int fd)
|
||||
|
||||
// fs_close_attr_dir
|
||||
extern "C" int
|
||||
build_fs_close_attr_dir(DIR *dir)
|
||||
_haiku_build_fs_close_attr_dir(DIR *dir)
|
||||
{
|
||||
return fs_close_attr_dir(dir);
|
||||
}
|
||||
|
||||
// fs_read_attr_dir
|
||||
extern "C" struct dirent *
|
||||
build_fs_read_attr_dir(DIR *dir)
|
||||
_haiku_build_fs_read_attr_dir(DIR *dir)
|
||||
{
|
||||
return fs_read_attr_dir(dir);
|
||||
}
|
||||
|
||||
// fs_rewind_attr_dir
|
||||
extern "C" void
|
||||
build_fs_rewind_attr_dir(DIR *dir)
|
||||
_haiku_build_fs_rewind_attr_dir(DIR *dir)
|
||||
{
|
||||
return fs_rewind_attr_dir(dir);
|
||||
}
|
||||
|
||||
// fs_fopen_attr
|
||||
extern "C" int
|
||||
build_fs_fopen_attr(int fd, const char *attribute, uint32 type, int openMode)
|
||||
_haiku_build_fs_fopen_attr(int fd, const char *attribute, uint32 type, int openMode)
|
||||
{
|
||||
if (fd < 0) {
|
||||
errno = B_BAD_VALUE;
|
||||
@@ -126,14 +129,14 @@ build_fs_fopen_attr(int fd, const char *attribute, uint32 type, int openMode)
|
||||
|
||||
// fs_close_attr
|
||||
extern "C" int
|
||||
build_fs_close_attr(int fd)
|
||||
_haiku_build_fs_close_attr(int fd)
|
||||
{
|
||||
return fs_close_attr(fd);
|
||||
}
|
||||
|
||||
// fs_read_attr
|
||||
extern "C" ssize_t
|
||||
build_fs_read_attr(int fd, const char* attribute, uint32 type, off_t pos,
|
||||
_haiku_build_fs_read_attr(int fd, const char* attribute, uint32 type, off_t pos,
|
||||
void *buffer, size_t readBytes)
|
||||
{
|
||||
LocalFD localFD;
|
||||
@@ -166,7 +169,7 @@ build_fs_read_attr(int fd, const char* attribute, uint32 type, off_t pos,
|
||||
|
||||
// fs_write_attr
|
||||
extern "C" ssize_t
|
||||
build_fs_write_attr(int fd, const char* attribute, uint32 type, off_t pos,
|
||||
_haiku_build_fs_write_attr(int fd, const char* attribute, uint32 type, off_t pos,
|
||||
const void *buffer, size_t writeBytes)
|
||||
{
|
||||
LocalFD localFD;
|
||||
@@ -192,7 +195,7 @@ build_fs_write_attr(int fd, const char* attribute, uint32 type, off_t pos,
|
||||
|
||||
// fs_remove_attr
|
||||
extern "C" int
|
||||
build_fs_remove_attr(int fd, const char* attribute)
|
||||
_haiku_build_fs_remove_attr(int fd, const char* attribute)
|
||||
{
|
||||
LocalFD localFD;
|
||||
status_t error = localFD.Init(fd);
|
||||
@@ -223,7 +226,7 @@ build_fs_remove_attr(int fd, const char* attribute)
|
||||
|
||||
// fs_stat_attr
|
||||
extern "C" int
|
||||
build_fs_stat_attr(int fd, const char *attribute, struct attr_info *attrInfo)
|
||||
_haiku_build_fs_stat_attr(int fd, const char *attribute, struct attr_info *attrInfo)
|
||||
{
|
||||
if (!attribute || !attrInfo) {
|
||||
errno = B_BAD_VALUE;
|
||||
@@ -277,9 +280,9 @@ _kern_open_attr_dir(int fd, const char *path)
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
dir = build_fs_open_attr_dir(realPath.c_str());
|
||||
dir = _haiku_build_fs_open_attr_dir(realPath.c_str());
|
||||
} else
|
||||
dir = build_fs_fopen_attr_dir(fd);
|
||||
dir = _haiku_build_fs_fopen_attr_dir(fd);
|
||||
|
||||
if (!dir)
|
||||
return errno;
|
||||
@@ -305,7 +308,7 @@ _kern_remove_attr(int fd, const char *name)
|
||||
if (!name)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if (build_fs_remove_attr(fd, name) < 0)
|
||||
if (_haiku_build_fs_remove_attr(fd, name) < 0)
|
||||
return errno;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -276,3 +276,121 @@ renameat(int fromFD, const char* from, int toFD, const char* to)
|
||||
|
||||
return _haiku_build_renameat(fromFD, from, toFD, to);
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAIKU_HOST_USE_XATTR) && defined(HAIKU_HOST_PLATFORM_HAIKU)
|
||||
// fs_attr_* functions only need to be remapped on Haiku
|
||||
|
||||
|
||||
extern "C" void* HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_open_attr_dir(const char *path)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_open_attr_dir);
|
||||
|
||||
return _haiku_build_fs_open_attr_dir(path);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void* HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_lopen_attr_dir(const char *path)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_lopen_attr_dir);
|
||||
|
||||
return _haiku_build_fs_lopen_attr_dir(path);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void* HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_fopen_attr_dir(int fd)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_fopen_attr_dir);
|
||||
|
||||
return _haiku_build_fs_fopen_attr_dir(fd);
|
||||
}
|
||||
|
||||
|
||||
extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_close_attr_dir(void *dir)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_close_attr_dir);
|
||||
|
||||
return _haiku_build_fs_close_attr_dir(dir);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void* HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_read_attr_dir(void *dir)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_read_attr_dir);
|
||||
|
||||
return _haiku_build_fs_read_attr_dir(dir);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_rewind_attr_dir(void *dir)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_rewind_attr_dir);
|
||||
|
||||
_haiku_build_fs_rewind_attr_dir(dir);
|
||||
}
|
||||
|
||||
|
||||
extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_fopen_attr(int fd, const char *attribute, uint32 type, int openMode)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_fopen_attr);
|
||||
|
||||
return _haiku_build_fs_fopen_attr(fd, attribute, type, openMode);
|
||||
}
|
||||
|
||||
|
||||
extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_close_attr(int fd)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_close_attr);
|
||||
|
||||
return _haiku_build_fs_close_attr(fd);
|
||||
}
|
||||
|
||||
|
||||
extern "C" ssize_t HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_read_attr(int fd, const char* attribute, uint32 type, off_t pos,
|
||||
void *buffer, size_t readBytes)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_read_attr);
|
||||
|
||||
return _haiku_build_fs_read_attr(fd, attribute, type, pos, buffer,
|
||||
readBytes);
|
||||
}
|
||||
|
||||
|
||||
extern "C" ssize_t HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_write_attr(int fd, const char* attribute, uint32 type, off_t pos,
|
||||
const void *buffer, size_t writeBytes)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_write_attr);
|
||||
|
||||
return _haiku_build_fs_write_attr(fd, attribute, type, pos, buffer,
|
||||
writeBytes);
|
||||
}
|
||||
|
||||
|
||||
extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_remove_attr(int fd, const char* attribute)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_remove_attr);
|
||||
|
||||
return _haiku_build_fs_remove_attr(fd, attribute);
|
||||
}
|
||||
|
||||
|
||||
extern "C" int HIDDEN_FUNCTION_ATTRIBUTE
|
||||
fs_stat_attr(int fd, const char *attribute, struct attr_info *attrInfo)
|
||||
{
|
||||
HIDDEN_FUNCTION(fs_stat_attr);
|
||||
|
||||
return _haiku_build_fs_stat_attr(fd, attribute, attrInfo);
|
||||
}
|
||||
|
||||
#endif // defined(HAIKU_HOST_USE_XATTR) && defined(HAIKU_HOST_PLATFORM_HAIKU)
|
||||
|
||||
@@ -46,6 +46,31 @@ int _haiku_build_fcntl(int fd, int op, int argument);
|
||||
int _haiku_build_renameat(int fromFD, const char* from, int toFD,
|
||||
const char* to);
|
||||
|
||||
#ifdef HAIKU_HOST_PLATFORM_HAIKU
|
||||
|
||||
ssize_t _haiku_build_fs_read_attr(int fd, const char *attribute, uint32 type,
|
||||
off_t pos, void *buffer, size_t readBytes);
|
||||
ssize_t _haiku_build_fs_write_attr(int fd, const char *attribute, uint32 type,
|
||||
off_t pos, const void *buffer, size_t readBytes);
|
||||
int _haiku_build_fs_remove_attr(int fd, const char *attribute);
|
||||
int _haiku_build_fs_stat_attr(int fd, const char *attribute,
|
||||
struct attr_info *attrInfo);
|
||||
|
||||
int _haiku_build_fs_open_attr(const char *path, const char *attribute,
|
||||
uint32 type, int openMode);
|
||||
int _haiku_build_fs_fopen_attr(int fd, const char *attribute, uint32 type,
|
||||
int openMode);
|
||||
int _haiku_build_fs_close_attr(int fd);
|
||||
|
||||
void *_haiku_build_fs_open_attr_dir(const char *path);
|
||||
void *_haiku_build_fs_lopen_attr_dir(const char *path);
|
||||
void *_haiku_build_fs_fopen_attr_dir(int fd);
|
||||
int _haiku_build_fs_close_attr_dir(void *dir);
|
||||
void *_haiku_build_fs_read_attr_dir(void *dir);
|
||||
void _haiku_build_fs_rewind_attr_dir(void *dir);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user