--- a/src/utils/pxattr.cpp
+++ b/src/utils/pxattr.cpp
@@ -27,16 +27,24 @@
\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 @@
#include <sys/xattr.h>
#elif defined(__APPLE__)
#include <sys/xattr.h>
+#elif defined(__OpenBSD__)
#else
#error "Unknown system can't compile"
#endif
@@ -162,6 +171,8 @@
} else {
ret = fgetxattr(fd, name.c_str(), buf.buf, ret, 0, 0);
}
+#else
+ errno = ENOTSUP;
#endif
if (ret >= 0)
@@ -257,6 +268,8 @@
ret = fsetxattr(fd, name.c_str(), value.c_str(),
value.length(), 0, opts);
}
+#else
+ errno = ENOTSUP;
#endif
return ret >= 0;
}
@@ -302,6 +315,8 @@
} else {
ret = fremovexattr(fd, name.c_str(), 0);
}
+#else
+ errno = ENOTSUP;
#endif
return ret >= 0;
}
@@ -384,7 +399,12 @@
} else {
ret = flistxattr(fd, buf.buf, ret, 0);
}
+#else
+ errno = ENOTSUP;
#endif
+
+ if (ret < 0)
+ return false;
char *bufstart = buf.buf;