portability to debian kfreebsd

This commit is contained in:
Jean-Francois Dockes 2013-09-30 08:53:15 +02:00
parent 334e16bee5
commit 7daaf60093

View File

@ -24,16 +24,22 @@ OTHER DEALINGS IN THE SOFTWARE.
*/ */
/** \file pxattr.cpp /** \file pxattr.cpp
\brief This is a comment for file pxattr.cpp \brief Portable External Attributes API
*/ */
// We want this to compile even to empty on non-supported systems. makes #if defined(__gnu_linux__) || \
// things easier for autoconf (defined(__FreeBSD_kernel__)&&defined(__GLIBC__)&&!defined(__FreeBSD__)) ||\
#if defined(__FreeBSD__) || defined(__gnu_linux__) || defined(__APPLE__) || \
defined(__CYGWIN32__) defined(__CYGWIN32__)
#define PXALINUX
#endif
// If the platform is not supported, let this file be empty instead of
// breaking the compile, this will let the build work if the rest of
// the software is not actually calling us.
#if defined(__FreeBSD__) || defined(PXALINUX) || defined(__APPLE__)
#ifndef TEST_PXATTR #ifndef TEST_PXATTR
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
@ -42,9 +48,7 @@ OTHER DEALINGS IN THE SOFTWARE.
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
#include <sys/extattr.h> #include <sys/extattr.h>
#include <sys/uio.h> #include <sys/uio.h>
#elif defined(__gnu_linux__) #elif defined(PXALINUX)
#include <sys/xattr.h>
#elif defined(__CYGWIN32__)
#include <sys/xattr.h> #include <sys/xattr.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <sys/xattr.h> #include <sys/xattr.h>
@ -111,7 +115,7 @@ get(int fd, const string& path, const string& _name, string *value,
ret = extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, ret = extattr_get_fd(fd, EXTATTR_NAMESPACE_USER,
name.c_str(), buf.buf, ret); name.c_str(), buf.buf, ret);
} }
#elif defined(__gnu_linux__) #elif defined(PXALINUX)
if (fd < 0) { if (fd < 0) {
if (flags & PXATTR_NOFOLLOW) { if (flags & PXATTR_NOFOLLOW) {
ret = lgetxattr(path.c_str(), name.c_str(), 0, 0); ret = lgetxattr(path.c_str(), name.c_str(), 0, 0);
@ -218,7 +222,7 @@ set(int fd, const string& path, const string& _name,
ret = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, ret = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER,
name.c_str(), value.c_str(), value.length()); name.c_str(), value.c_str(), value.length());
} }
#elif defined(__gnu_linux__) #elif defined(PXALINUX)
int opts = 0; int opts = 0;
if (flags & PXATTR_CREATE) if (flags & PXATTR_CREATE)
opts = XATTR_CREATE; opts = XATTR_CREATE;
@ -278,7 +282,7 @@ del(int fd, const string& path, const string& _name, flags flags, nspace dom)
} else { } else {
ret = extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name.c_str()); ret = extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name.c_str());
} }
#elif defined(__gnu_linux__) #elif defined(PXALINUX)
if (fd < 0) { if (fd < 0) {
if (flags & PXATTR_NOFOLLOW) { if (flags & PXATTR_NOFOLLOW) {
ret = lremovexattr(path.c_str(), name.c_str()); ret = lremovexattr(path.c_str(), name.c_str());
@ -333,7 +337,7 @@ list(int fd, const string& path, vector<string>* names, flags flags, nspace dom)
} else { } else {
ret = extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, buf.buf, ret); ret = extattr_list_fd(fd, EXTATTR_NAMESPACE_USER, buf.buf, ret);
} }
#elif defined(__gnu_linux__) #elif defined(PXALINUX)
if (fd < 0) { if (fd < 0) {
if (flags & PXATTR_NOFOLLOW) { if (flags & PXATTR_NOFOLLOW) {
ret = llistxattr(path.c_str(), 0, 0); ret = llistxattr(path.c_str(), 0, 0);
@ -450,7 +454,7 @@ bool list(int fd, vector<string>* names, flags flags, nspace dom)
return list(fd, nullstring, names, flags, dom); return list(fd, nullstring, names, flags, dom);
} }
#if defined(__gnu_linux__) || defined(COMPAT1) #if defined(PXALINUX) || defined(COMPAT1)
static const string userstring("user."); static const string userstring("user.");
#else #else
static const string userstring(""); static const string userstring("");