Browse Source

add clonepath tool

pull/42/head
Antonio SJ Musumeci 10 years ago
parent
commit
d1f3bd82e8
  1. 43
      Makefile
  2. 54
      src/clonepath.cpp
  3. 30
      src/clonepath.hpp
  4. 18
      src/mergerfs.cpp

43
Makefile

@ -27,6 +27,7 @@ MKDIR = $(shell which mkdir)
TOUCH = $(shell which touch)
CP = $(shell which cp)
RM = $(shell which rm)
LN = $(shell which ln)
FIND = $(shell which find)
INSTALL = $(shell which install)
MKTEMP = $(shell which mktemp)
@ -82,8 +83,8 @@ LDFLAGS = $(shell $(PKGCONFIG) fuse --libs)
BINDIR = $(PREFIX)/usr/bin
MANDIR = $(PREFIX)/usr/share/man/man1
INSTALLTARGET = $(DESTDIR)/$(BINDIR)/$(TARGET)
MANTARGET = $(DESTDIR)/$(MANDIR)/$(MANPAGE)
INSTALLBINDIR = $(DESTDIR)$(BINDIR)
INSTALLMANDIR = $(DESTDIR)$(MANDIR)
ifeq ($(XATTR_AVAILABLE),0)
$(warning "xattr not available: disabling")
@ -98,7 +99,7 @@ ifeq ($(KERNEL),Darwin)
CFLAGS += -DOSX
endif
all: $(TARGET)
all: $(TARGET) clonepath
help:
@echo "usage: make"
@ -107,6 +108,9 @@ help:
$(TARGET): obj/obj-stamp $(OBJ)
$(CXX) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
clonepath: $(TARGET)
$(LN) -s $< $@
changelog:
$(GIT) log --pretty --numstat --summary | git2cl > ChangeLog
@ -118,22 +122,37 @@ obj/%.o: src/%.cpp
$(CXX) $(CFLAGS) -c $< -o $@
clean:
$(RM) -rf obj "$(TARGET)" "$(MANPAGE)"
$(RM) -rf obj
$(RM) -f "$(TARGET)" "$(MANPAGE)" clonepath
$(FIND) -name "*~" -delete
distclean: clean
$(GIT) clean -fd
install: $(TARGET) $(MANPAGE)
$(INSTALL) -m 0755 -D "$(TARGET)" "$(INSTALLTARGET)"
$(INSTALL) -m 0644 -D "$(MANPAGE)" "$(MANTARGET)"
install: install-base install-clonepath install-man
install-base: $(TARGET)
$(INSTALL) -v -m 0755 -D "$(TARGET)" "$(INSTALLBINDIR)/$(TARGET)"
install-clonepath: clonepath
$(CP) -a $< "$(INSTALLBINDIR)/$<"
install-man: $(MANPAGE)
$(INSTALL) -v -m 0644 -D "$(MANPAGE)" "$(INSTALLMANDIR)/$(MANPAGE)"
install-strip: install-base
$(STRIP) "$(INSTALLBINDIR)/$(TARGET)"
uninstall: uninstall-base uninstall-clonepath uninstall-man
uninstall-base:
$(RM) -f "$(INSTALLBINDIR)/$(TARGET)"
install-strip: install
$(STRIP) "$(INSTALLTARGET)"
uninstall-clonepath:
$(RM) -f "$(INSTALLBINDIR)/clonepath"
uninstall:
$(RM) "$(INSTALLTARGET)"
$(RM) "$(MANTARGET)"
uninstall-man:
$(RM) -f "$(INSTALLMANDIR)/$(MANPAGE")
$(MANPAGE): README.md
$(PANDOC) -s -t man -o $(MANPAGE) README.md

54
src/clonepath.cpp

@ -0,0 +1,54 @@
/*
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.
*/
#include <unistd.h>
#include <iostream>
#include "fs.hpp"
namespace clonepath
{
static
void
print_usage_and__exit(void)
{
std::cerr << "usage: clonepath "
<< "<sourcedir> <destdir> <relativepath>"
<< std::endl;
_exit(1);
}
int
main(const int argc,
char * const argv[])
{
if(argc != 4)
print_usage_and__exit();
return fs::clonepath(argv[1],
argv[2],
argv[3]);
}
}

30
src/clonepath.hpp

@ -0,0 +1,30 @@
/*
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.
*/
namespace clonepath
{
int
main(const int argc,
char * const *argv);
}

18
src/mergerfs.cpp

@ -33,6 +33,8 @@
#include "resources.hpp"
#include "fs.hpp"
#include "clonepath.hpp"
#include "access.hpp"
#include "chmod.hpp"
#include "chown.hpp"
@ -73,6 +75,14 @@
namespace local
{
static
std::string
getappname(const int argc,
char * const *argv)
{
return fs::basename(argv[0]);
}
static
void
get_fuse_operations(struct fuse_operations &ops)
@ -179,9 +189,11 @@ int
main(int argc,
char **argv)
{
int rv;
std::string appname;
rv = mergerfs::main(argc,argv);
appname = local::getappname(argc,argv);
if(appname == "clonepath")
return clonepath::main(argc,argv);
return rv;
return mergerfs::main(argc,argv);
}
Loading…
Cancel
Save