mirror of https://github.com/trapexit/mergerfs.git
Browse Source
new features: follow-symlinks, rename-exdev, link-exdev
new features: follow-symlinks, rename-exdev, link-exdev
* follow-symlinks: allows mergerfs to transparently follow symlinks * link-exdev: in the event a link returns EXDEV create a symlink instead * rename-exdev: in the event a rename returns EXDEV move the oldpath and create a symlink for the newpathpull/883/head
Antonio SJ Musumeci
4 years ago
26 changed files with 6991 additions and 461 deletions
-
2Makefile
-
51README.md
-
2libfuse/Makefile
-
17libfuse/include/fuse.h
-
132libfuse/lib/fuse.c
-
81man/mergerfs.1
-
8src/config.cpp
-
9src/config.hpp
-
58src/config_follow_symlinks.cpp
-
30src/config_follow_symlinks.hpp
-
58src/config_link_exdev.cpp
-
30src/config_link_exdev.hpp
-
54src/config_rename_exdev.cpp
-
29src/config_rename_exdev.hpp
-
4src/enum.hpp
-
22src/fs_mkdir.hpp
-
35src/fs_mkdir_as_root.hpp
-
21src/fs_symlink.hpp
-
64src/fuse_getattr.cpp
-
308src/fuse_link.cpp
-
8src/fuse_link.hpp
-
448src/fuse_rename.cpp
-
28src/fuse_rmdir.cpp
-
50src/fuse_symlink.cpp
-
15src/fuse_symlink.hpp
-
5742src/ghc/filesystem.hpp
@ -0,0 +1,58 @@ |
|||||
|
/*
|
||||
|
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 "config_follow_symlinks.hpp"
|
||||
|
#include "ef.hpp"
|
||||
|
#include "errno.hpp"
|
||||
|
|
||||
|
template<> |
||||
|
std::string |
||||
|
FollowSymlinks::to_string(void) const |
||||
|
{ |
||||
|
switch(_data) |
||||
|
{ |
||||
|
case FollowSymlinks::ENUM::NEVER: |
||||
|
return "never"; |
||||
|
case FollowSymlinks::ENUM::DIRECTORY: |
||||
|
return "directory"; |
||||
|
case FollowSymlinks::ENUM::REGULAR: |
||||
|
return "regular"; |
||||
|
case FollowSymlinks::ENUM::ALL: |
||||
|
return "all"; |
||||
|
} |
||||
|
|
||||
|
return "invalid"; |
||||
|
} |
||||
|
|
||||
|
template<> |
||||
|
int |
||||
|
FollowSymlinks::from_string(const std::string &s_) |
||||
|
{ |
||||
|
if(s_ == "never") |
||||
|
_data = FollowSymlinks::ENUM::NEVER; |
||||
|
ef(s_ == "directory") |
||||
|
_data = FollowSymlinks::ENUM::DIRECTORY; |
||||
|
ef(s_ == "regular") |
||||
|
_data = FollowSymlinks::ENUM::REGULAR; |
||||
|
ef(s_ == "all") |
||||
|
_data = FollowSymlinks::ENUM::ALL; |
||||
|
else |
||||
|
return -EINVAL; |
||||
|
|
||||
|
return 0; |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
/*
|
||||
|
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. |
||||
|
*/ |
||||
|
|
||||
|
#pragma once
|
||||
|
|
||||
|
#include "enum.hpp"
|
||||
|
|
||||
|
enum class FollowSymlinksEnum |
||||
|
{ |
||||
|
NEVER, |
||||
|
DIRECTORY, |
||||
|
REGULAR, |
||||
|
ALL |
||||
|
}; |
||||
|
typedef Enum<FollowSymlinksEnum> FollowSymlinks; |
@ -0,0 +1,58 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2021, 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 "config_link_exdev.hpp"
|
||||
|
#include "ef.hpp"
|
||||
|
#include "errno.hpp"
|
||||
|
|
||||
|
template<> |
||||
|
std::string |
||||
|
LinkEXDEV::to_string(void) const |
||||
|
{ |
||||
|
switch(_data) |
||||
|
{ |
||||
|
case LinkEXDEV::ENUM::PASSTHROUGH: |
||||
|
return "passthrough"; |
||||
|
case LinkEXDEV::ENUM::REL_SYMLINK: |
||||
|
return "rel-symlink"; |
||||
|
case LinkEXDEV::ENUM::ABS_BASE_SYMLINK: |
||||
|
return "abs-base-symlink"; |
||||
|
case LinkEXDEV::ENUM::ABS_POOL_SYMLINK: |
||||
|
return "abs-pool-symlink"; |
||||
|
} |
||||
|
|
||||
|
return "invalid"; |
||||
|
} |
||||
|
|
||||
|
template<> |
||||
|
int |
||||
|
LinkEXDEV::from_string(const std::string &s_) |
||||
|
{ |
||||
|
if(s_ == "passthrough") |
||||
|
_data = LinkEXDEV::ENUM::PASSTHROUGH; |
||||
|
ef(s_ == "rel-symlink") |
||||
|
_data = LinkEXDEV::ENUM::REL_SYMLINK; |
||||
|
ef(s_ == "abs-base-symlink") |
||||
|
_data = LinkEXDEV::ENUM::ABS_BASE_SYMLINK; |
||||
|
ef(s_ == "abs-pool-symlink") |
||||
|
_data = LinkEXDEV::ENUM::ABS_POOL_SYMLINK; |
||||
|
else |
||||
|
return -EINVAL; |
||||
|
|
||||
|
return 0; |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2021, 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 "enum.hpp"
|
||||
|
|
||||
|
enum class LinkEXDEVEnum |
||||
|
{ |
||||
|
PASSTHROUGH, |
||||
|
REL_SYMLINK, |
||||
|
ABS_BASE_SYMLINK, |
||||
|
ABS_POOL_SYMLINK |
||||
|
}; |
||||
|
typedef Enum<LinkEXDEVEnum> LinkEXDEV; |
@ -0,0 +1,54 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2021, 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 "config_rename_exdev.hpp"
|
||||
|
#include "ef.hpp"
|
||||
|
#include "errno.hpp"
|
||||
|
|
||||
|
template<> |
||||
|
std::string |
||||
|
RenameEXDEV::to_string(void) const |
||||
|
{ |
||||
|
switch(_data) |
||||
|
{ |
||||
|
case RenameEXDEV::ENUM::PASSTHROUGH: |
||||
|
return "passthrough"; |
||||
|
case RenameEXDEV::ENUM::REL_SYMLINK: |
||||
|
return "rel-symlink"; |
||||
|
case RenameEXDEV::ENUM::ABS_SYMLINK: |
||||
|
return "abs-symlink"; |
||||
|
} |
||||
|
|
||||
|
return "invalid"; |
||||
|
} |
||||
|
|
||||
|
template<> |
||||
|
int |
||||
|
RenameEXDEV::from_string(const std::string &s_) |
||||
|
{ |
||||
|
if(s_ == "passthrough") |
||||
|
_data = RenameEXDEV::ENUM::PASSTHROUGH; |
||||
|
ef(s_ == "rel-symlink") |
||||
|
_data = RenameEXDEV::ENUM::REL_SYMLINK; |
||||
|
ef(s_ == "abs-symlink") |
||||
|
_data = RenameEXDEV::ENUM::ABS_SYMLINK; |
||||
|
else |
||||
|
return -EINVAL; |
||||
|
|
||||
|
return 0; |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2021, 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 "enum.hpp"
|
||||
|
|
||||
|
enum class RenameEXDEVEnum |
||||
|
{ |
||||
|
PASSTHROUGH, |
||||
|
REL_SYMLINK, |
||||
|
ABS_SYMLINK |
||||
|
}; |
||||
|
typedef Enum<RenameEXDEVEnum> RenameEXDEV; |
@ -0,0 +1,35 @@ |
|||||
|
/*
|
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2021, 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 "fs_mkdir.hpp"
|
||||
|
#include "ugid.hpp"
|
||||
|
|
||||
|
namespace fs |
||||
|
{ |
||||
|
template<typename T> |
||||
|
static |
||||
|
inline |
||||
|
int |
||||
|
mkdir_as_root(const T &path_, |
||||
|
const mode_t mode_) |
||||
|
{ |
||||
|
const ugid::SetRootGuard guard; |
||||
|
|
||||
|
return fs::mkdir(path_,mode_); |
||||
|
} |
||||
|
} |
5742
src/ghc/filesystem.hpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue