mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Enable dynamic loading of setxattr(2) in Darwin/Mac OS X if compiled with dl interface, TODO old dyld interface.
This commit is contained in:
@@ -26,8 +26,15 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(CheckSymbolExists)
|
||||||
find_library(CARBON_LIBRARY NAMES Carbon)
|
find_library(CARBON_LIBRARY NAMES Carbon)
|
||||||
|
|
||||||
|
CHECK_SYMBOL_EXISTS(dlsym dlfcn.h HAVE_DLSYM)
|
||||||
|
|
||||||
|
if(HAVE_DLSYM)
|
||||||
|
add_sub_definitions(HAVE_DLSYM)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_sources(os.c darwin.h volume.c volume.h attr.c attr.h rsrcfork.c rsrcfork.h sparse.c xattr.c xattr.h)
|
add_sources(os.c darwin.h volume.c volume.h attr.c attr.h rsrcfork.c rsrcfork.h sparse.c xattr.c xattr.h)
|
||||||
|
|
||||||
if(CARBON_LIBRARY)
|
if(CARBON_LIBRARY)
|
||||||
|
|||||||
@@ -22,7 +22,11 @@ Aaru Data Preservation Suite
|
|||||||
Copyright (C) 2011-2021 Natalia Portillo
|
Copyright (C) 2011-2021 Natalia Portillo
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
// TODO: old dyld interface
|
||||||
|
#if HAVE_DLSYM
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#endif // HAVE_DLSYM
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -33,13 +37,15 @@ Copyright (C) 2011-2021 Natalia Portillo
|
|||||||
|
|
||||||
void DarwinExtendedAttributes(const char* path)
|
void DarwinExtendedAttributes(const char* path)
|
||||||
{
|
{
|
||||||
|
// TODO: old dyld interface
|
||||||
|
#if HAVE_DLSYM
|
||||||
int ret;
|
int ret;
|
||||||
FILE* file;
|
FILE* file;
|
||||||
int rc;
|
int rc;
|
||||||
int cRc;
|
int cRc;
|
||||||
_darwin_setxattr darwin_setxattr;
|
_darwin_setxattr darwin_setxattr;
|
||||||
|
|
||||||
darwin_setxattr = (_darwin_setxattr)dlsym(RTLD_DEFAULT, "setxattr");
|
darwin_setxattr = (_darwin_setxattr)dlsym(RTLD_DEFAULT, "setxattr");
|
||||||
|
|
||||||
if(!darwin_setxattr)
|
if(!darwin_setxattr)
|
||||||
{
|
{
|
||||||
@@ -100,4 +106,8 @@ void DarwinExtendedAttributes(const char* path)
|
|||||||
if(ret) cRc = errno;
|
if(ret) cRc = errno;
|
||||||
}
|
}
|
||||||
log_write("\tFile with an extended attribute called \"com.ibm.os2.icon\", rc = %d, cRc = %d\n", rc, cRc);
|
log_write("\tFile with an extended attribute called \"com.ibm.os2.icon\", rc = %d, cRc = %d\n", rc, cRc);
|
||||||
|
#else // HAVE_DLSYM
|
||||||
|
printf("This version is not compiled to try extended attributes. This version MUST NOT be used in Mac OS X 10.4 "
|
||||||
|
"(Darwin 8.0) or higher\n");
|
||||||
|
#endif // HAVE_DLSYM
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user