From e8252860372ee3a6e63ab1d1dce87f4310ee921e Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 9 Apr 2015 09:08:30 +0200 Subject: [PATCH] OpenBSD has no xattrs, help recoll build anyway --- src/utils/pxattr.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/utils/pxattr.cpp b/src/utils/pxattr.cpp index abfbb733..1f3c7b13 100644 --- a/src/utils/pxattr.cpp +++ b/src/utils/pxattr.cpp @@ -27,16 +27,24 @@ OTHER DEALINGS IN THE SOFTWARE. \brief Portable External Attributes API */ +// PXALINUX: platforms like kfreebsd which aren't linux but use the +// same xattr interface #if defined(__gnu_linux__) || \ (defined(__FreeBSD_kernel__)&&defined(__GLIBC__)&&!defined(__FreeBSD__)) ||\ defined(__CYGWIN__) #define PXALINUX #endif -// If the platform is not supported, let this file be empty instead of +// If the platform is not known yet, 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__) +// the software is not actually calling us. If it does call us, this +// will bring attention to the necessity of a port. +// +// If the platform is known not supporting extattrs (e.g.__OpenBSD__), +// just let the methods return errors (like they would on a non-xattr +// fs on e.g. linux) +#if defined(__FreeBSD__) || defined(PXALINUX) || defined(__APPLE__) \ + || defined(__OpenBSD__) #ifndef TEST_PXATTR @@ -52,6 +60,7 @@ OTHER DEALINGS IN THE SOFTWARE. #include #elif defined(__APPLE__) #include +#elif defined(__OpenBSD__) #else #error "Unknown system can't compile" #endif @@ -162,6 +171,8 @@ get(int fd, const string& path, const string& _name, string *value, } else { ret = fgetxattr(fd, name.c_str(), buf.buf, ret, 0, 0); } +#else + errno = ENOTSUP; #endif if (ret >= 0) @@ -257,6 +268,8 @@ set(int fd, const string& path, const string& _name, ret = fsetxattr(fd, name.c_str(), value.c_str(), value.length(), 0, opts); } +#else + errno = ENOTSUP; #endif return ret >= 0; } @@ -302,6 +315,8 @@ del(int fd, const string& path, const string& _name, flags flags, nspace dom) } else { ret = fremovexattr(fd, name.c_str(), 0); } +#else + errno = ENOTSUP; #endif return ret >= 0; } @@ -384,8 +399,13 @@ list(int fd, const string& path, vector* names, flags flags, nspace dom) } else { ret = flistxattr(fd, buf.buf, ret, 0); } +#else + errno = ENOTSUP; #endif + if (ret < 0) + return false; + char *bufstart = buf.buf; // All systems return a 0-separated string list except FreeBSD