fix building without libattr

This commit is contained in:
Antonio SJ Musumeci 2014-05-19 09:34:31 -04:00
parent bb7a966296
commit 7f640c4d9e
6 changed files with 52 additions and 5 deletions

View File

@ -37,10 +37,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#include <sys/types.h> #include <sys/types.h>
#include <attr/xattr.h>
#include <unistd.h> #include <unistd.h>
#include "fs.hpp" #include "fs.hpp"
#include "xattr.hpp"
using std::string; using std::string;
using std::vector; using std::vector;
@ -446,6 +446,7 @@ namespace fs
listxattr(const string path, listxattr(const string path,
vector<char> &attrs) vector<char> &attrs)
{ {
#ifndef WITHOUT_XATTR
int rv; int rv;
int size; int size;
@ -459,6 +460,10 @@ namespace fs
} }
return rv; return rv;
#else
errno = ENOTSUP;
return -1;
#endif
} }
int int
@ -497,6 +502,7 @@ namespace fs
const string attr, const string attr,
vector<char> &value) vector<char> &value)
{ {
#ifndef WITHOUT_XATTR
int rv; int rv;
int size; int size;
@ -510,6 +516,10 @@ namespace fs
} }
return rv; return rv;
#else
errno = ENOTSUP;
return -1;
#endif
} }
int int
@ -562,11 +572,16 @@ namespace fs
const string value, const string value,
const int flags) const int flags)
{ {
#ifndef WITHOUT_XATTR
return ::setxattr(path.c_str(), return ::setxattr(path.c_str(),
key.c_str(), key.c_str(),
value.data(), value.data(),
value.size(), value.size(),
flags); flags);
#else
errno = ENOTSUP;
return -1;
#endif
} }
int int
@ -575,11 +590,16 @@ namespace fs
const string value, const string value,
const int flags) const int flags)
{ {
#ifndef WITHOUT_XATTR
return ::fsetxattr(fd, return ::fsetxattr(fd,
key.c_str(), key.c_str(),
value.data(), value.data(),
value.size(), value.size(),
flags); flags);
#else
errno = ENOTSUP;
return -1;
#endif
} }
int int

View File

@ -27,12 +27,12 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <attr/xattr.h>
#include "config.hpp" #include "config.hpp"
#include "fs.hpp" #include "fs.hpp"
#include "ugid.hpp" #include "ugid.hpp"
#include "assert.hpp" #include "assert.hpp"
#include "xattr.hpp"
using std::string; using std::string;
using std::vector; using std::vector;

View File

@ -26,13 +26,13 @@
#include <vector> #include <vector>
#include <sys/types.h> #include <sys/types.h>
#include <attr/xattr.h>
#include <errno.h> #include <errno.h>
#include "config.hpp" #include "config.hpp"
#include "fs.hpp" #include "fs.hpp"
#include "ugid.hpp" #include "ugid.hpp"
#include "assert.hpp" #include "assert.hpp"
#include "xattr.hpp"
using std::string; using std::string;
using std::vector; using std::vector;

View File

@ -27,12 +27,12 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <attr/xattr.h>
#include "config.hpp" #include "config.hpp"
#include "ugid.hpp" #include "ugid.hpp"
#include "fs.hpp" #include "fs.hpp"
#include "assert.hpp" #include "assert.hpp"
#include "xattr.hpp"
using std::string; using std::string;
using std::vector; using std::vector;

View File

@ -27,12 +27,12 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <attr/xattr.h>
#include "config.hpp" #include "config.hpp"
#include "fs.hpp" #include "fs.hpp"
#include "ugid.hpp" #include "ugid.hpp"
#include "assert.hpp" #include "assert.hpp"
#include "xattr.hpp"
using std::string; using std::string;
using std::vector; using std::vector;

27
src/xattr.hpp Normal file
View File

@ -0,0 +1,27 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Antonio SJ Musumeci <trapexit@spawn.link>
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 <attr/xattr.h>
#endif