From 7f640c4d9e5b50cc6dce8f1f5ee0358b18214052 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Mon, 19 May 2014 09:34:31 -0400 Subject: [PATCH] fix building without libattr --- src/fs.cpp | 22 +++++++++++++++++++++- src/getxattr.cpp | 2 +- src/listxattr.cpp | 2 +- src/removexattr.cpp | 2 +- src/setxattr.cpp | 2 +- src/xattr.hpp | 27 +++++++++++++++++++++++++++ 6 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 src/xattr.hpp diff --git a/src/fs.cpp b/src/fs.cpp index a0a84151..6aca5479 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -37,10 +37,10 @@ #include #include #include -#include #include #include "fs.hpp" +#include "xattr.hpp" using std::string; using std::vector; @@ -446,6 +446,7 @@ namespace fs listxattr(const string path, vector &attrs) { +#ifndef WITHOUT_XATTR int rv; int size; @@ -459,6 +460,10 @@ namespace fs } return rv; +#else + errno = ENOTSUP; + return -1; +#endif } int @@ -497,6 +502,7 @@ namespace fs const string attr, vector &value) { +#ifndef WITHOUT_XATTR int rv; int size; @@ -510,6 +516,10 @@ namespace fs } return rv; +#else + errno = ENOTSUP; + return -1; +#endif } int @@ -562,11 +572,16 @@ namespace fs const string value, const int flags) { +#ifndef WITHOUT_XATTR return ::setxattr(path.c_str(), key.c_str(), value.data(), value.size(), flags); +#else + errno = ENOTSUP; + return -1; +#endif } int @@ -575,11 +590,16 @@ namespace fs const string value, const int flags) { +#ifndef WITHOUT_XATTR return ::fsetxattr(fd, key.c_str(), value.data(), value.size(), flags); +#else + errno = ENOTSUP; + return -1; +#endif } int diff --git a/src/getxattr.cpp b/src/getxattr.cpp index d51591ab..0026e855 100644 --- a/src/getxattr.cpp +++ b/src/getxattr.cpp @@ -27,12 +27,12 @@ #include #include -#include #include "config.hpp" #include "fs.hpp" #include "ugid.hpp" #include "assert.hpp" +#include "xattr.hpp" using std::string; using std::vector; diff --git a/src/listxattr.cpp b/src/listxattr.cpp index 1a42755f..94cd2229 100644 --- a/src/listxattr.cpp +++ b/src/listxattr.cpp @@ -26,13 +26,13 @@ #include #include -#include #include #include "config.hpp" #include "fs.hpp" #include "ugid.hpp" #include "assert.hpp" +#include "xattr.hpp" using std::string; using std::vector; diff --git a/src/removexattr.cpp b/src/removexattr.cpp index ed5a9d03..2b866ca4 100644 --- a/src/removexattr.cpp +++ b/src/removexattr.cpp @@ -27,12 +27,12 @@ #include #include -#include #include "config.hpp" #include "ugid.hpp" #include "fs.hpp" #include "assert.hpp" +#include "xattr.hpp" using std::string; using std::vector; diff --git a/src/setxattr.cpp b/src/setxattr.cpp index f3e44b35..3fd93b9b 100644 --- a/src/setxattr.cpp +++ b/src/setxattr.cpp @@ -27,12 +27,12 @@ #include #include -#include #include "config.hpp" #include "fs.hpp" #include "ugid.hpp" #include "assert.hpp" +#include "xattr.hpp" using std::string; using std::vector; diff --git a/src/xattr.hpp b/src/xattr.hpp new file mode 100644 index 00000000..72f8d267 --- /dev/null +++ b/src/xattr.hpp @@ -0,0 +1,27 @@ +/* + The MIT License (MIT) + + Copyright (c) 2014 Antonio SJ Musumeci + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef WITHOUT_XATTR +#include +#endif