mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-20 00:17:43 +00:00
Compare commits
119
Commits
threadpool
...
mfm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3dfe45bd3 | ||
|
|
8b099982da | ||
|
|
e2f1343435 | ||
|
|
4e58caac83 | ||
|
|
261453bd87 | ||
|
|
b11848cc19 | ||
|
|
d63f451232 | ||
|
|
6e6093bc9f | ||
|
|
21d67a903c | ||
|
|
239f27ec6a | ||
|
|
6ecadf2477 | ||
|
|
baf78b7578 | ||
|
|
1b15ffce94 | ||
|
|
4cec9428d6 | ||
|
|
1be94b72c4 | ||
|
|
412ed6bb4c | ||
|
|
fc23f6fc79 | ||
|
|
590cfe7e35 | ||
|
|
b08b727a72 | ||
|
|
da240c1756 | ||
|
|
a4663bd546 | ||
|
|
97c6964415 | ||
|
|
6b8e6459d4 | ||
|
|
13697c49d3 | ||
|
|
0776783767 | ||
|
|
07302d3c8e | ||
|
|
43633bd80f | ||
|
|
03563cba73 | ||
|
|
56ca294acb | ||
|
|
52bee524fe | ||
|
|
0ea606a398 | ||
|
|
6474f7cb27 | ||
|
|
42658b8a10 | ||
|
|
1ca97602f6 | ||
|
|
6ef6198719 | ||
|
|
3c5ef655ea | ||
|
|
db9880e568 | ||
|
|
9e7af2f5bc | ||
|
|
896244b76d | ||
|
|
1c27ae2074 | ||
|
|
30304a5d5d | ||
|
|
e649385ab9 | ||
|
|
ba7367e9f8 | ||
|
|
98076e6e6d | ||
|
|
51fc08eaaa | ||
|
|
a0945e5f12 | ||
|
|
cff15446ec | ||
|
|
056fe774be | ||
|
|
b5435c0119 | ||
|
|
f84db6e76a | ||
|
|
ca8193a18b | ||
|
|
dc0c6d5506 | ||
|
|
94c7c5b6b2 | ||
|
|
c83949790f | ||
|
|
e544d19f68 | ||
|
|
c70b0fa79f | ||
|
|
5612491a6a | ||
|
|
7126108e4d | ||
|
|
ee9c7728a0 | ||
|
|
5363c4c70c | ||
|
|
20f1352a4b | ||
|
|
f3ffc3319d | ||
|
|
a75ec5c176 | ||
|
|
40c3995109 | ||
|
|
e67fe02bf1 | ||
|
|
a034588526 | ||
|
|
01be549023 | ||
|
|
accf56044f | ||
|
|
ab9678ba5d | ||
|
|
404eb4e35b | ||
|
|
5783e32849 | ||
|
|
566e6e4af0 | ||
|
|
04ad916571 | ||
|
|
1f4827e032 | ||
|
|
755962b865 | ||
|
|
3b3d2b24a9 | ||
|
|
f529b8a709 | ||
|
|
a8de05369e | ||
|
|
a5cd0c68b9 | ||
|
|
f455208d16 | ||
|
|
907bc2b424 | ||
|
|
91614a1197 | ||
|
|
c34f4e650c | ||
|
|
d50c3e2614 | ||
|
|
976918b5bb | ||
|
|
fc09316c6d | ||
|
|
acc329aed0 | ||
|
|
f6e618091d | ||
|
|
0046b32f13 | ||
|
|
4316ab40f2 | ||
|
|
5f293452b6 | ||
|
|
4a6cec777b | ||
|
|
7a59cc8da8 | ||
|
|
ff35f87a05 | ||
|
|
37f53c2873 | ||
|
|
d47b805477 | ||
|
|
0bd04307b2 | ||
|
|
eefea74996 | ||
|
|
f639f28ccd | ||
|
|
c5934c5fcc | ||
|
|
b46cfd3258 | ||
|
|
39d6d89fa0 | ||
|
|
72c4bd56af | ||
|
|
a9126957e6 | ||
|
|
6d725a7743 | ||
|
|
23bd3ba020 | ||
|
|
97a722660f | ||
|
|
d2499e87d6 | ||
|
|
e1dd0ab847 | ||
|
|
72b30e3e21 | ||
|
|
b2170f3ab3 | ||
|
|
fab71e37f0 | ||
|
|
cf1514efc8 | ||
|
|
192230ba16 | ||
|
|
7ba4cdeaba | ||
|
|
907dddb0ca | ||
|
|
d88731a380 | ||
|
|
750062559a | ||
|
|
69ed827fe1 |
@@ -140,7 +140,7 @@ INSTALLMAN1DIR ?= $(DESTDIR)$(MAN1DIR)
|
||||
|
||||
|
||||
.PHONY: all
|
||||
all: libfuse $(BUILDDIR)/mergerfs $(BUILDDIR)/fsck.mergerfs $(BUILDDIR)/mergerfs.collect-info
|
||||
all: libfuse $(BUILDDIR)/mergerfs $(BUILDDIR)/fsck.mergerfs $(BUILDDIR)/mergerfs.collect-info $(BUILDDIR)/mfm
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@@ -162,6 +162,9 @@ $(BUILDDIR)/fsck.mergerfs:
|
||||
$(BUILDDIR)/mergerfs.collect-info:
|
||||
$(LN) -sf "mergerfs" $@
|
||||
|
||||
$(BUILDDIR)/mfm:
|
||||
$(LN) -sf "mergerfs" $@
|
||||
|
||||
$(BUILDDIR)/tests: $(BUILDDIR)/mergerfs $(TESTS_OBJS)
|
||||
$(CXX) $(CXXFLAGS) $(TESTS_FLAGS) $(INC_FLAGS) $(MFS_FLAGS) $(CPPFLAGS) $(TESTS_OBJS) -o $@ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
@@ -223,6 +226,7 @@ install-base: all
|
||||
$(INSTALL) -v -m 0755 "$(BUILDDIR)/mergerfs" "$(INSTALLBINDIR)/mergerfs"
|
||||
$(LN) -fs "mergerfs" "${INSTALLBINDIR}/fsck.mergerfs"
|
||||
$(LN) -fs "mergerfs" "${INSTALLBINDIR}/mergerfs.collect-info"
|
||||
$(LN) -fs "mergerfs" "${INSTALLBINDIR}/mfm"
|
||||
|
||||
.PHONY: install-mount-tools
|
||||
install-mount-tools: install-base
|
||||
|
||||
+10
-4
@@ -27,10 +27,11 @@
|
||||
#include "fs_xattr.hpp"
|
||||
#include "ugid.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace stdfs = std::filesystem;
|
||||
|
||||
static
|
||||
bool
|
||||
@@ -65,13 +66,18 @@ fs::clonepath(const string &srcpath_,
|
||||
struct stat st;
|
||||
string dstpath;
|
||||
string srcpath;
|
||||
string dirname;
|
||||
stdfs::path dirname;
|
||||
stdfs::path relpath;
|
||||
|
||||
if((relpath_ == NULL) || (relpath_[0] == '\0'))
|
||||
return 0;
|
||||
|
||||
dirname = fs::path::dirname(relpath_);
|
||||
if(dirname != "/")
|
||||
relpath = relpath_;
|
||||
if(relpath_[0] != '/')
|
||||
relpath = "/" / relpath;
|
||||
|
||||
dirname = relpath.parent_path();
|
||||
if(dirname != dirname.root_path())
|
||||
{
|
||||
rv = fs::clonepath(srcpath_,dstpath_,dirname,return_metadata_errors_);
|
||||
if(rv < 0)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "mergerfs.hpp"
|
||||
#include "mergerfs_fsck.hpp"
|
||||
#include "mergerfs_collect_info.hpp"
|
||||
#include "mfm.hpp"
|
||||
|
||||
#include "fs_path.hpp"
|
||||
#include "fs_readahead.hpp"
|
||||
@@ -373,6 +374,8 @@ _pick_app_and_run(int argc_,
|
||||
return mergerfs::fsck::main(argc_,argv_);
|
||||
if(appname == "mergerfs.collect-info")
|
||||
return mergerfs::collect_info::main(argc_,argv_);
|
||||
if(appname == "mfm")
|
||||
return mfm::main(argc_,argv_);
|
||||
|
||||
return l::main(argc_,argv_);
|
||||
}
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#include "mfm.hpp"
|
||||
|
||||
#include "mfm_options.hpp"
|
||||
|
||||
#include "CLI11.hpp"
|
||||
|
||||
static
|
||||
void
|
||||
_setup_argparser_dup(CLI::App &app_,
|
||||
mfm::Opts::Dup &opts_)
|
||||
{
|
||||
CLI::App *subcmd;
|
||||
|
||||
subcmd = app_.add_subcommand("dup",
|
||||
"duplicate files");
|
||||
subcmd->add_option("path",opts_.paths)
|
||||
->description("")
|
||||
->type_name("PATH")
|
||||
->check(CLI::ExistingPath)
|
||||
->required();
|
||||
|
||||
auto func = std::bind(mfm::dup,std::cref(opts_));
|
||||
|
||||
subcmd->callback(func);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_setup_argparser_watch(CLI::App &app_,
|
||||
mfm::Opts::Watch &opts_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_setup_argparser_migrate(CLI::App &app_,
|
||||
mfm::Opts::Migrate &opts_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_setup_argparser_rebalance(CLI::App &app_,
|
||||
mfm::Opts::Rebalance &opts_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
_setup_argparser(CLI::App &app_,
|
||||
mfm::Opts &opts_)
|
||||
{
|
||||
_setup_argparser_dup(app_,opts_.dup);
|
||||
_setup_argparser_migrate(app_,opts_.migrate);
|
||||
_setup_argparser_rebalance(app_,opts_.rebalance);
|
||||
_setup_argparser_watch(app_,opts_.watch);
|
||||
}
|
||||
|
||||
#include "fmt/core.h"
|
||||
|
||||
int
|
||||
mfm::main(int argc_,
|
||||
char **argv_)
|
||||
{
|
||||
CLI::App app;
|
||||
mfm::Opts opts;
|
||||
|
||||
app.description("mfm: mergerfs filesystem manager");
|
||||
app.name("USAGE:: mfm");
|
||||
|
||||
::_setup_argparser(app,opts);
|
||||
|
||||
try
|
||||
{
|
||||
app.parse(argc_,argv_);
|
||||
}
|
||||
catch(const CLI::ParseError &e_)
|
||||
{
|
||||
return app.exit(e_);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "mfm_options.hpp"
|
||||
|
||||
namespace mfm
|
||||
{
|
||||
int main(int argc,
|
||||
char **argv);
|
||||
|
||||
void dup(const Opts::Dup &dup);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "mfm_options.hpp"
|
||||
|
||||
#include "str.hpp"
|
||||
#include "fs_clonepath.hpp"
|
||||
#include "fs_copyfile.hpp"
|
||||
|
||||
#include "fmt/core.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
namespace stdfs = std::filesystem;
|
||||
|
||||
namespace mfm
|
||||
{
|
||||
void dup(const Opts::Dup &opts);
|
||||
}
|
||||
|
||||
void
|
||||
mfm::dup(const Opts::Dup &opts_)
|
||||
{
|
||||
std::vector<std::filesystem::path> srcpaths;
|
||||
|
||||
// TODO: expand if mergerfs mount
|
||||
srcpaths = opts_.paths;
|
||||
|
||||
for(const auto &srcpath : srcpaths)
|
||||
{
|
||||
if(stdfs::is_regular_file(srcpath))
|
||||
{
|
||||
}
|
||||
else if(stdfs::is_directory(srcpath))
|
||||
{
|
||||
auto dir_opts = (stdfs::directory_options::follow_directory_symlink |
|
||||
stdfs::directory_options::skip_permission_denied);
|
||||
|
||||
for(const stdfs::directory_entry &de :
|
||||
stdfs::recursive_directory_iterator(srcpath,dir_opts))
|
||||
{
|
||||
if(!str::startswith(de.path().filename().string(),".dup_"))
|
||||
continue;
|
||||
|
||||
for(const auto &de :
|
||||
stdfs::recursive_directory_iterator(de.path().parent_path()))
|
||||
{
|
||||
if(!de.is_regular_file())
|
||||
continue;
|
||||
|
||||
auto relpath = "/" / stdfs::relative(de.path(),srcpath);
|
||||
|
||||
for(const auto &dstpath : srcpaths)
|
||||
{
|
||||
if(dstpath == srcpath)
|
||||
continue;
|
||||
|
||||
auto srcfullpath = srcpath / relpath.relative_path();
|
||||
auto dstfullpath = srcpath / relpath.relative_path();
|
||||
|
||||
if(stdfs::exists(dstfullpath))
|
||||
continue;
|
||||
|
||||
fmt::println("copy {} to {} : {} : {}",
|
||||
srcpath.string(),
|
||||
dstpath.string(),
|
||||
relpath.parent_path().string(),
|
||||
relpath.filename().string());
|
||||
|
||||
fs::clonepath(srcpath,
|
||||
dstpath,
|
||||
relpath.parent_path());
|
||||
fs::copyfile(srcpath / relpath.relative_path(),
|
||||
dstpath / relpath.relative_path(),
|
||||
{.cleanup_failure=false});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//throw std::runtime_error("invalid file type");
|
||||
fmt::println("invalid file type: {}",srcpath.string());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "int_types.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace mfm
|
||||
{
|
||||
struct Opts
|
||||
{
|
||||
struct Dup
|
||||
{
|
||||
std::vector<std::filesystem::path> paths;
|
||||
} dup;
|
||||
|
||||
struct Watch
|
||||
{
|
||||
std::filesystem::path path;
|
||||
} watch;
|
||||
|
||||
struct Migrate
|
||||
{
|
||||
std::vector<std::filesystem::path> src;
|
||||
std::vector<std::filesystem::path> dst;
|
||||
} migrate;
|
||||
|
||||
struct Rebalance
|
||||
{
|
||||
std::vector<std::filesystem::path> dirpaths;
|
||||
} rebalance;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user