Browse Source

Merge pull request #121 from trapexit/xattr-version

add user.mergerfs.version xattr
pull/122/head
Antonio SJ Musumeci 9 years ago
parent
commit
27cf7f8148
  1. 11
      Makefile
  2. 10
      src/getxattr.cpp
  3. 3
      src/listxattr.cpp

11
Makefile

@ -106,7 +106,7 @@ help:
@echo "usage: make" @echo "usage: make"
@echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)" @echo "make XATTR_AVAILABLE=0 - to build program without xattrs functionality (auto discovered otherwise)"
$(TARGET): obj/obj-stamp $(OBJ)
$(TARGET): src/version.hpp obj/obj-stamp $(OBJ)
$(CXX) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS) $(CXX) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
clonepath: $(TARGET) clonepath: $(TARGET)
@ -118,6 +118,13 @@ changelog:
authors: authors:
$(GIT) log --format='%aN <%aE>' | sort -f | uniq > AUTHORS $(GIT) log --format='%aN <%aE>' | sort -f | uniq > AUTHORS
src/version.hpp:
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
@echo "#ifndef _VERSION_HPP" > src/version.hpp
@echo "#define _VERSION_HPP" >> src/version.hpp
@echo "static const char MERGERFS_VERSION[] = \"$(VERSION)\";" >> src/version.hpp
@echo "#endif" >> src/version.hpp
obj/obj-stamp: obj/obj-stamp:
$(MKDIR) -p obj $(MKDIR) -p obj
$(TOUCH) $@ $(TOUCH) $@
@ -163,7 +170,7 @@ $(MANPAGE): README.md
man: $(MANPAGE) man: $(MANPAGE)
tarball: clean man changelog authors
tarball: clean man changelog authors src/version.hpp
$(eval VERSION := $(shell $(GIT) describe --always --tags --dirty)) $(eval VERSION := $(shell $(GIT) describe --always --tags --dirty))
$(eval VERSION := $(subst -,_,$(VERSION))) $(eval VERSION := $(subst -,_,$(VERSION)))
$(eval FILENAME := $(TARGET)-$(VERSION)) $(eval FILENAME := $(TARGET)-$(VERSION))

10
src/getxattr.cpp

@ -40,6 +40,7 @@
#include "rwlock.hpp" #include "rwlock.hpp"
#include "xattr.hpp" #include "xattr.hpp"
#include "str.hpp" #include "str.hpp"
#include "version.hpp"
using std::string; using std::string;
using std::vector; using std::vector;
@ -134,6 +135,13 @@ _getxattr_controlfile_policies(const Config &config,
attrvalue += ',' + (string)Policy::policies[i]; attrvalue += ',' + (string)Policy::policies[i];
} }
static
void
_getxattr_controlfile_version(string &attrvalue)
{
attrvalue = MERGERFS_VERSION;
}
static static
int int
_getxattr_controlfile(const Config &config, _getxattr_controlfile(const Config &config,
@ -158,6 +166,8 @@ _getxattr_controlfile(const Config &config,
_getxattr_controlfile_minfreespace(config,attrvalue); _getxattr_controlfile_minfreespace(config,attrvalue);
else if(attr[2] == "policies") else if(attr[2] == "policies")
_getxattr_controlfile_policies(config,attrvalue); _getxattr_controlfile_policies(config,attrvalue);
else if(attr[2] == "version")
_getxattr_controlfile_version(attrvalue);
break; break;
case 4: case 4:

3
src/listxattr.cpp

@ -53,7 +53,8 @@ _listxattr_controlfile(char *list,
buildvector<string> buildvector<string>
("user.mergerfs.srcmounts") ("user.mergerfs.srcmounts")
("user.mergerfs.minfreespace") ("user.mergerfs.minfreespace")
("user.mergerfs.policies");
("user.mergerfs.policies")
("user.mergerfs.version");
xattrs.reserve(512); xattrs.reserve(512);
for(size_t i = 0; i < strs.size(); i++) for(size_t i = 0; i < strs.size(); i++)

Loading…
Cancel
Save