mirror of https://github.com/trapexit/mergerfs.git
Antonio SJ Musumeci
3 years ago
34 changed files with 462 additions and 954 deletions
-
177src/fuse_create.cpp
-
35src/fuse_init.cpp
-
121src/fuse_link.cpp
-
130src/fuse_mkdir.cpp
-
58src/fuse_readdir_plus.cpp
-
37src/fuse_readdirplus.cpp
-
4src/fuse_readdirplus.hpp
-
48src/fuse_readdirplus_policy.hpp
-
37src/fuse_readdirplus_policy_base.hpp
-
34src/fuse_readdirplus_policy_enosys.cpp
-
39src/fuse_readdirplus_policy_enosys.hpp
-
39src/fuse_readdirplus_policy_factory.cpp
-
30src/fuse_readdirplus_policy_factory.hpp
-
21src/fuse_readdirplus_policy_linux.cpp
-
24src/fuse_readdirplus_policy_linux.hpp
-
21src/fuse_readdirplus_policy_posix.cpp
-
26src/fuse_readdirplus_policy_posix.hpp
-
126src/fuse_statfs.cpp
-
33src/fuse_statfs_policy_branch.cpp
-
6src/fuse_statfs_policy_full.hpp
-
150src/fuse_symlink.cpp
-
3src/fuse_symlink.hpp
-
6src/fuse_symlink_policy.hpp
-
6src/fuse_symlink_policy_base.hpp
-
4src/fuse_symlink_policy_epff.cpp
-
4src/fuse_symlink_policy_epff.hpp
-
4src/fuse_symlink_policy_ff.cpp
-
4src/fuse_symlink_policy_ff.hpp
-
116src/fuse_utimens.cpp
-
22src/fuse_utimens_policy.hpp
-
2src/fuse_utimens_policy_base.hpp
-
13src/mergerfs.cpp
-
7src/state.cpp
-
21src/state.hpp
@ -1,58 +0,0 @@ |
|||||
/*
|
|
||||
ISC License |
|
||||
|
|
||||
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
|
||||
|
|
||||
Permission to use, copy, modify, and/or distribute this software for any |
|
||||
purpose with or without fee is hereby granted, provided that the above |
|
||||
copyright notice and this permission notice appear in all copies. |
|
||||
|
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
||||
*/ |
|
||||
|
|
||||
#include "fuse_readdir_plus_linux.hpp"
|
|
||||
#include "fuse_readdir_plus_posix.hpp"
|
|
||||
|
|
||||
#include "config.hpp"
|
|
||||
#include "dirinfo.hpp"
|
|
||||
#include "rwlock.hpp"
|
|
||||
#include "ugid.hpp"
|
|
||||
|
|
||||
#include "fuse.h"
|
|
||||
|
|
||||
|
|
||||
namespace FUSE::READDIR_PLUS |
|
||||
{ |
|
||||
int |
|
||||
readdir_plus(const fuse_file_info_t *ffi_, |
|
||||
fuse_dirents_t *buf_) |
|
||||
{ |
|
||||
Config::Read cfg; |
|
||||
DirInfo *di = reinterpret_cast<DirInfo*>(ffi_->fh); |
|
||||
const fuse_context *fc = fuse_get_context(); |
|
||||
const ugid::Set ugid(fc->uid,fc->gid); |
|
||||
|
|
||||
switch(cfg->readdir) |
|
||||
{ |
|
||||
case ReadDir::ENUM::LINUX: |
|
||||
return FUSE::READDIR_PLUS_LINUX::readdir_plus_linux(cfg->branches, |
|
||||
di->fusepath.c_str(), |
|
||||
cfg->cache_entry, |
|
||||
cfg->cache_attr, |
|
||||
buf_); |
|
||||
default: |
|
||||
case ReadDir::ENUM::POSIX: |
|
||||
return FUSE::READDIR_PLUS_POSIX::readdir_plus_posix(cfg->branches, |
|
||||
di->fusepath.c_str(), |
|
||||
cfg->cache_entry, |
|
||||
cfg->cache_attr, |
|
||||
buf_); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,37 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#include "state.hpp"
|
||||
|
#include "ugid.hpp"
|
||||
|
|
||||
|
#include "fuse.h"
|
||||
|
|
||||
|
|
||||
|
namespace FUSE::READDIRPLUS |
||||
|
{ |
||||
|
int |
||||
|
readdirplus(const fuse_file_info_t *ffi_, |
||||
|
fuse_dirents_t *buf_) |
||||
|
{ |
||||
|
State s; |
||||
|
const fuse_context *fc = fuse_get_context(); |
||||
|
const ugid::Set ugid(fc->uid,fc->gid); |
||||
|
|
||||
|
return s->readdirplus(ffi_,buf_); |
||||
|
} |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "fuse_readdirplus_policy_base.hpp"
|
||||
|
#include "fuse_readdirplus_policy_factory.hpp"
|
||||
|
|
||||
|
#include "fuse.h"
|
||||
|
|
||||
|
|
||||
|
namespace FUSE::READDIRPLUS |
||||
|
{ |
||||
|
class Policy |
||||
|
{ |
||||
|
public: |
||||
|
Policy(const toml::value &toml_) |
||||
|
{ |
||||
|
_readdirplus = POLICY::factory(toml_); |
||||
|
} |
||||
|
|
||||
|
public: |
||||
|
int |
||||
|
operator()(const fuse_file_info_t *ffi_, |
||||
|
fuse_dirents_t *buf_) |
||||
|
{ |
||||
|
return (*_readdirplus)(ffi_,buf_); |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
POLICY::Base::Ptr _readdirplus; |
||||
|
}; |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "fuse.h"
|
||||
|
|
||||
|
#include <memory>
|
||||
|
|
||||
|
|
||||
|
namespace FUSE::READDIRPLUS::POLICY |
||||
|
{ |
||||
|
class Base |
||||
|
{ |
||||
|
public: |
||||
|
typedef std::shared_ptr<Base> Ptr; |
||||
|
|
||||
|
public: |
||||
|
virtual int operator()(const fuse_file_info_t *ffi, |
||||
|
fuse_dirents_t *buf) = 0; |
||||
|
}; |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#include "fuse_readdirplus_policy_enosys.hpp"
|
||||
|
|
||||
|
#include "errno.hpp"
|
||||
|
|
||||
|
|
||||
|
FUSE::READDIRPLUS::POLICY::enosys::enosys(const toml::value &toml_) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
int |
||||
|
FUSE::READDIRPLUS::POLICY::enosys::operator()(const fuse_file_info_t *ffi_, |
||||
|
fuse_dirents_t *buf_) |
||||
|
{ |
||||
|
return -ENOSYS; |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "fuse_readdirplus_policy_base.hpp"
|
||||
|
|
||||
|
#include "branches.hpp"
|
||||
|
|
||||
|
#include "toml.hpp"
|
||||
|
|
||||
|
|
||||
|
namespace FUSE::READDIRPLUS::POLICY |
||||
|
{ |
||||
|
class enosys : public Base |
||||
|
{ |
||||
|
public: |
||||
|
enosys(const toml::value &); |
||||
|
|
||||
|
public: |
||||
|
int operator()(const fuse_file_info_t *ffi, |
||||
|
fuse_dirents_t *buf) final; |
||||
|
}; |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#include "fuse_readdirplus_policy_factory.hpp"
|
||||
|
|
||||
|
#include "fuse_readdirplus_policy_enosys.hpp"
|
||||
|
|
||||
|
#include <stdexcept>
|
||||
|
|
||||
|
|
||||
|
namespace FUSE::READDIRPLUS::POLICY |
||||
|
{ |
||||
|
Base::Ptr |
||||
|
factory(const toml::value &toml_) |
||||
|
{ |
||||
|
std::string str; |
||||
|
|
||||
|
str = toml::find_or(toml_,"func","readdirplus","policy","enosys"); |
||||
|
if(str == "enosys") |
||||
|
return std::make_shared<enosys>(toml_); |
||||
|
|
||||
|
throw std::runtime_error("readdirplus"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "fuse_readdirplus_policy_base.hpp"
|
||||
|
|
||||
|
#include "toml.hpp"
|
||||
|
|
||||
|
|
||||
|
namespace FUSE::READDIRPLUS::POLICY |
||||
|
{ |
||||
|
Base::Ptr |
||||
|
factory(const toml::value &); |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2022, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#include "fuse_statfs_policy_branch.hpp"
|
||||
|
|
||||
|
|
||||
|
FUSE::STATFS::POLICY::Branch::Branch(const toml::value &toml_) |
||||
|
: _branches(toml_) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
int |
||||
|
FUSE::STATFS::POLICY::Branch::operator()(const gfs::path &fusepath_, |
||||
|
struct statvfs *fsstat) |
||||
|
{ |
||||
|
return 0; |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue