Browse Source

remove libattr dependency

pull/515/head
Antonio SJ Musumeci 6 years ago
parent
commit
1885a82cce
  1. 18
      Makefile
  2. 8
      README.md
  3. 3
      debian/control
  4. 8
      man/mergerfs.1
  5. 1
      mergerfs.spec
  6. 69
      src/fs_base_getxattr.hpp
  7. 40
      src/fs_base_listxattr.hpp
  8. 2
      src/fs_base_removexattr.hpp
  9. 18
      src/fs_base_setxattr.hpp
  10. 80
      src/fs_xattr.cpp
  11. 17
      src/xattr.hpp

18
Makefile

@ -41,7 +41,7 @@ ifeq ($(PANDOC),)
$(warning "pandoc does not appear available: manpage won't be buildable")
endif
XATTR_AVAILABLE = $(shell test ! -e /usr/include/attr/xattr.h; echo $$?)
USE_XATTR = 1
INTERNAL_FUSE = 1
EXTERNAL_FUSE_MIN_REQ = 2.9.7
@ -73,6 +73,7 @@ CFLAGS = -g -Wall \
$(FUSE_CFLAGS) \
-DFUSE_USE_VERSION=29 \
-MMD \
-DUSE_XATTR=$(USE_XATTR) \
-DUGID_USE_RWLOCK=$(UGID_USE_RWLOCK)
PREFIX = /usr/local
@ -88,17 +89,12 @@ INSTALLBINDIR = $(DESTDIR)$(BINDIR)
INSTALLSBINDIR = $(DESTDIR)$(SBINDIR)
INSTALLMAN1DIR = $(DESTDIR)$(MAN1DIR)
ifeq ($(XATTR_AVAILABLE),0)
$(warning "xattr not available: disabling")
CFLAGS += -DWITHOUT_XATTR
endif
all: $(TARGET)
help:
@echo "usage: make"
@echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
@echo "make INTERNAL_FUSE=0 - to build program with external (system) libfuse rather than the bundled one ('-o threads=' option will be unavailable)"
@echo "make USE_XATTR=0 - build program without xattrs functionality"
@echo "make INTERNAL_FUSE=0 - to build program with external (system) libfuse rather than the bundled one ('-o threads=' option will be unavailable)"
$(TARGET): version obj/obj-stamp $(FUSE_TARGET) $(OBJ)
$(CXX) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $@ $(FUSE_LIBS) -ldl -pthread -lrt
@ -218,13 +214,13 @@ install-build-pkgs:
ifeq ($(shell test -e /usr/bin/apt-get; echo $$?),0)
apt-get -qy update
apt-get -qy --no-install-suggests --no-install-recommends --force-yes \
install build-essential git g++ debhelper libattr1-dev python automake libtool lsb-release
install build-essential git g++ debhelper python automake libtool lsb-release
else ifeq ($(shell test -e /usr/bin/dnf; echo $$?),0)
dnf -y update
dnf -y install git rpm-build libattr-devel gcc-c++ make which python automake libtool gettext-devel
dnf -y install git rpm-build gcc-c++ make which python automake libtool gettext-devel
else ifeq ($(shell test -e /usr/bin/yum; echo $$?),0)
yum -y update
yum -y install git rpm-build libattr-devel gcc-c++ make which python automake libtool gettext-devel
yum -y install git rpm-build gcc-c++ make which python automake libtool gettext-devel
endif
unexport CFLAGS

8
README.md

@ -271,7 +271,7 @@ $ sudo apt-get -y update
$ sudo apt-get -y install git make
$ cd mergerfs
$ make install-build-pkgs
$ # build-essential git g++ debhelper libattr1-dev python automake libtool lsb-release
$ # build-essential git g++ debhelper python automake libtool lsb-release
$ make deb
$ sudo dpkg -i ../mergerfs_version_arch.deb
```
@ -283,14 +283,14 @@ $ su -
# dnf -y install git make
# cd mergerfs
# make install-build-pkgs
# # rpm-build libattr-devel gcc-c++ which python automake libtool gettext-devel
# # rpm-build gcc-c++ which python automake libtool gettext-devel
# make rpm
# rpm -i rpmbuild/RPMS/<arch>/mergerfs-<verion>.<arch>.rpm
```
#### Generically
Have git, g++, make, python, libattr1, automake, libtool installed.
Have git, g++, make, python, automake, libtool installed.
```
$ cd mergerfs
@ -302,7 +302,7 @@ $ sudo make install
**NOTE:** Configurable threading and thus `-o threads=num` option will be unavailable when built with system libfuse.
Have git, g++, make, python, libattr1, pkg-config installed.
Have git, g++, make, python, pkg-config installed.
Also, install libfuse >= 2.9.7 (but not libfuse-3.x) and matching libfuse-dev (or libfuse-devel).
```

3
debian/control

@ -2,8 +2,7 @@ Source: mergerfs
Section: utils
Priority: optional
Maintainer: Antonio SJ Musumeci <trapexit@spawn.link>
Build-Depends: debhelper (>= 8.0.0),
libattr1-dev
Build-Depends: debhelper (>= 8.0.0)
Standards-Version: 3.9.4
Homepage: http://github.com/trapexit/mergerfs

8
man/mergerfs.1

@ -708,7 +708,7 @@ $\ sudo\ apt\-get\ \-y\ update
$\ sudo\ apt\-get\ \-y\ install\ git\ make
$\ cd\ mergerfs
$\ make\ install\-build\-pkgs
$\ #\ build\-essential\ git\ g++\ debhelper\ libattr1\-dev\ python\ automake\ libtool\ lsb\-release
$\ #\ build\-essential\ git\ g++\ debhelper\ python\ automake\ libtool\ lsb\-release
$\ make\ deb
$\ sudo\ dpkg\ \-i\ ../mergerfs_version_arch.deb
\f[]
@ -722,14 +722,14 @@ $\ su\ \-
#\ dnf\ \-y\ install\ git\ make
#\ cd\ mergerfs
#\ make\ install\-build\-pkgs
#\ #\ rpm\-build\ libattr\-devel\ gcc\-c++\ which\ python\ automake\ libtool\ gettext\-devel
#\ #\ rpm\-build\ gcc\-c++\ which\ python\ automake\ libtool\ gettext\-devel
#\ make\ rpm
#\ rpm\ \-i\ rpmbuild/RPMS/<arch>/mergerfs\-<verion>.<arch>.rpm
\f[]
.fi
.SS Generically
.PP
Have git, g++, make, python, libattr1, automake, libtool installed.
Have git, g++, make, python, automake, libtool installed.
.IP
.nf
\f[C]
@ -743,7 +743,7 @@ $\ sudo\ make\ install
\f[B]NOTE:\f[] Configurable threading and thus \f[C]\-o\ threads=num\f[]
option will be unavailable when built with system libfuse.
.PP
Have git, g++, make, python, libattr1, pkg\-config installed.
Have git, g++, make, python, pkg\-config installed.
Also, install libfuse >= 2.9.7 (but not libfuse\-3.x) and matching
libfuse\-dev (or libfuse\-devel).
.IP

1
mergerfs.spec

@ -10,7 +10,6 @@ URL: https://github.com/trapexit/mergerfs
Source: mergerfs-%{version}.tar.gz
BuildRequires: gcc-c++
BuildRequires: libattr-devel
# rpmbuild driven by the Makefile uses git to generate a version number
BuildRequires: git

69
src/fs_base_getxattr.hpp

@ -18,25 +18,78 @@
#pragma once
#include <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
#include <sys/types.h>
#include <string>
namespace fs
{
static
inline
int
lgetxattr(const std::string &path,
const char *attrname,
void *value,
const size_t size)
lgetxattr(const char *path_,
const char *attrname_,
void *value_,
const size_t size_)
{
#ifdef USE_XATTR
return ::lgetxattr(path_,attrname_,value_,size_);
#else
return (errno=ENOTSUP,-1);
#endif
}
static
inline
int
lgetxattr(const std::string &path_,
const char *attrname_,
void *value_,
const size_t size_)
{
return fs::lgetxattr(path_.c_str(),attrname_,value_,size_);
}
static
inline
int
lgetxattr(const std::string &path_,
const std::string &attrname_,
void *value_,
const size_t size_)
{
return fs::lgetxattr(path_.c_str(),
attrname_.c_str(),
value_,
size_);
}
static
inline
int
fgetxattr(const int fd_,
const char *attrname_,
void *value_,
const size_t size_)
{
#ifndef WITHOUT_XATTR
return ::lgetxattr(path.c_str(),attrname,value,size);
#ifdef USE_XATTR
return ::fgetxattr(fd_,attrname_,value_,size_);
#else
return (errno=ENOTSUP,-1);
#endif
}
static
inline
int
fgetxattr(const int fd_,
const std::string &attrname_,
void *value_,
const size_t size_)
{
return fs::fgetxattr(fd_,attrname_.c_str(),value_,size_);
}
}

40
src/fs_base_listxattr.hpp

@ -18,22 +18,48 @@
#pragma once
#include <sys/types.h>
#include "errno.hpp"
#include "xattr.hpp"
#include <sys/types.h>
#include <string>
namespace fs
{
static
inline
int
llistxattr(const std::string &path,
char *list,
const size_t size)
llistxattr(const char *path_,
char *list_,
const size_t size_)
{
#ifdef USE_XATTR
return ::llistxattr(path_,list_,size_);
#else
return (errno=ENOTSUP,-1);
#endif
}
static
inline
int
llistxattr(const std::string &path_,
char *list_,
const size_t size_)
{
return fs::llistxattr(path_.c_str(),list_,size_);
}
static
inline
int
flistxattr(const int fd_,
char *list_,
const size_t size_)
{
#ifndef WITHOUT_XATTR
return ::llistxattr(path.c_str(),list,size);
#ifdef USE_XATTR
return ::flistxattr(fd_,list_,size_);
#else
return (errno=ENOTSUP,-1);
#endif

2
src/fs_base_removexattr.hpp

@ -31,7 +31,7 @@ namespace fs
lremovexattr(const std::string &path,
const char *attrname)
{
#ifndef WITHOUT_XATTR
#ifdef USE_XATTR
return ::lremovexattr(path.c_str(),attrname);
#else
return (errno=ENOTSUP,-1);

18
src/fs_base_setxattr.hpp

@ -34,10 +34,26 @@ namespace fs
const size_t size,
const int flags)
{
#ifndef WITHOUT_XATTR
#ifdef USE_XATTR
return ::lsetxattr(path.c_str(),name,value,size,flags);
#else
return (errno=ENOTSUP,-1);
#endif
}
static
inline
int
fsetxattr(const int fd_,
const char *name_,
const void *value_,
const size_t size_,
const int flags_)
{
#ifdef USE_XATTR
return ::fsetxattr(fd_,name_,value_,size_,flags_);
#else
return (errno=ENOTSUP,-1);
#endif
}
}

80
src/fs_xattr.cpp

@ -14,22 +14,20 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "errno.hpp"
#include "fs_base_close.hpp"
#include "fs_base_getxattr.hpp"
#include "fs_base_listxattr.hpp"
#include "fs_base_open.hpp"
#include "fs_base_removexattr.hpp"
#include "fs_base_setxattr.hpp"
#include "str.hpp"
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include "errno.hpp"
#include "fs_base_open.hpp"
#include "fs_base_close.hpp"
#include "str.hpp"
#include "xattr.hpp"
using std::string;
using std::vector;
@ -44,57 +42,49 @@ namespace fs
list(const int fd,
vector<char> &attrs)
{
#ifndef WITHOUT_XATTR
ssize_t rv;
rv = -1;
errno = ERANGE;
while((rv == -1) && (errno == ERANGE))
{
rv = ::flistxattr(fd,NULL,0);
rv = fs::flistxattr(fd,NULL,0);
if(rv <= 0)
return rv;
attrs.resize(rv);
rv = ::flistxattr(fd,&attrs[0],rv);
rv = fs::flistxattr(fd,&attrs[0],rv);
}
return rv;
#else
return (errno=ENOTSUP,-1);
#endif
}
int
list(const string &path,
vector<char> &attrs)
{
#ifndef WITHOUT_XATTR
ssize_t rv;
rv = -1;
errno = ERANGE;
while((rv == -1) && (errno == ERANGE))
{
rv = ::llistxattr(path.c_str(),NULL,0);
rv = fs::llistxattr(path,NULL,0);
if(rv <= 0)
return rv;
attrs.resize(rv);
rv = ::llistxattr(path.c_str(),&attrs[0],rv);
rv = fs::llistxattr(path,&attrs[0],rv);
}
return rv;
#else
return (errno=ENOTSUP,-1);
#endif
}
int
list(const int fd,
vector<string> &attrvector)
vector<string> &attrvector)
{
int rv;
vector<char> attrs;
@ -159,26 +149,22 @@ namespace fs
const string &attr,
vector<char> &value)
{
#ifndef WITHOUT_XATTR
ssize_t rv;
rv = -1;
errno = ERANGE;
while((rv == -1) && (errno == ERANGE))
{
rv = ::fgetxattr(fd,attr.c_str(),NULL,0);
rv = fs::fgetxattr(fd,attr,NULL,0);
if(rv <= 0)
return rv;
value.resize(rv);
rv = ::fgetxattr(fd,attr.c_str(),&value[0],rv);
rv = fs::fgetxattr(fd,attr,&value[0],rv);
}
return rv;
#else
return (errno=ENOTSUP,-1);
#endif
}
int
@ -186,26 +172,22 @@ namespace fs
const string &attr,
vector<char> &value)
{
#ifndef WITHOUT_XATTR
ssize_t rv;
rv = -1;
errno = ERANGE;
while((rv == -1) && (errno == ERANGE))
{
rv = ::lgetxattr(path.c_str(),attr.c_str(),NULL,0);
rv = fs::lgetxattr(path,attr,NULL,0);
if(rv <= 0)
return rv;
value.resize(rv);
rv = ::lgetxattr(path.c_str(),attr.c_str(),&value[0],rv);
rv = fs::lgetxattr(path,attr,&value[0],rv);
}
return rv;
#else
return (errno=ENOTSUP,-1);
#endif
}
int
@ -300,15 +282,11 @@ namespace fs
const string &value,
const int flags)
{
#ifndef WITHOUT_XATTR
return ::fsetxattr(fd,
key.c_str(),
value.data(),
value.size(),
flags);
#else
return (errno=ENOTSUP,-1);
#endif
return fs::fsetxattr(fd,
key.c_str(),
value.data(),
value.size(),
flags);
}
int
@ -317,15 +295,11 @@ namespace fs
const string &value,
const int flags)
{
#ifndef WITHOUT_XATTR
return ::lsetxattr(path.c_str(),
key.c_str(),
value.data(),
value.size(),
flags);
#else
return (errno=ENOTSUP,-1);
#endif
return fs::lsetxattr(path.c_str(),
key.c_str(),
value.data(),
value.size(),
flags);
}
int

17
src/xattr.hpp

@ -16,8 +16,21 @@
#pragma once
#ifndef WITHOUT_XATTR
#include <attr/xattr.h>
#if defined(__ANDROID__)
# include <sys/cdefs.h>
#elif defined(__APPLE__)
# include <TargetConditionals.h>
#elif defined(__linux__)
# include <features.h>
#endif
#ifdef USE_XATTR
# ifdef __GLIBC__
# include <sys/xattr.h>
# else
# undef USE_XATTR
# warning "USE_XATTR unset: xattrs disabled"
# endif
#endif
#ifndef XATTR_CREATE

Loading…
Cancel
Save