mirror of https://github.com/trapexit/mergerfs.git
Browse Source
Merge pull request #791 from trapexit/configcleanup
Merge pull request #791 from trapexit/configcleanup
cleanup: move some config data structures to separate filespull/792/head
trapexit
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 348 additions and 177 deletions
-
136src/config.cpp
-
38src/config.hpp
-
62src/config_cachefiles.cpp
-
32src/config_cachefiles.hpp
-
50src/config_statfs.cpp
-
29src/config_statfs.hpp
-
54src/config_statfsignore.cpp
-
29src/config_statfsignore.hpp
-
54src/config_xattr.cpp
-
31src/config_xattr.hpp
-
1src/fuse_create.cpp
-
6src/fuse_listxattr.cpp
-
1src/fuse_open.cpp
-
2src/fuse_statfs.cpp
@ -0,0 +1,62 @@ |
|||
/*
|
|||
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_cachefiles.hpp"
|
|||
#include "ef.hpp"
|
|||
#include "errno.hpp"
|
|||
|
|||
template<> |
|||
std::string |
|||
CacheFiles::to_string() const |
|||
{ |
|||
switch(_data) |
|||
{ |
|||
case CacheFiles::ENUM::LIBFUSE: |
|||
return "libfuse"; |
|||
case CacheFiles::ENUM::OFF: |
|||
return "off"; |
|||
case CacheFiles::ENUM::PARTIAL: |
|||
return "partial"; |
|||
case CacheFiles::ENUM::FULL: |
|||
return "full"; |
|||
case CacheFiles::ENUM::AUTO_FULL: |
|||
return "auto-full"; |
|||
} |
|||
|
|||
return "invalid"; |
|||
} |
|||
|
|||
template<> |
|||
int |
|||
CacheFiles::from_string(const std::string &s_) |
|||
{ |
|||
if(s_ == "libfuse") |
|||
_data = CacheFiles::ENUM::LIBFUSE; |
|||
ef(s_ == "off") |
|||
_data = CacheFiles::ENUM::OFF; |
|||
ef(s_ == "partial") |
|||
_data = CacheFiles::ENUM::PARTIAL; |
|||
ef(s_ == "full") |
|||
_data = CacheFiles::ENUM::FULL; |
|||
ef(s_ == "auto-full") |
|||
_data = CacheFiles::ENUM::AUTO_FULL; |
|||
else |
|||
return -EINVAL; |
|||
|
|||
return 0; |
|||
} |
@ -0,0 +1,32 @@ |
|||
/*
|
|||
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 CacheFilesEnum |
|||
{ |
|||
LIBFUSE, |
|||
OFF, |
|||
PARTIAL, |
|||
FULL, |
|||
AUTO_FULL |
|||
}; |
|||
|
|||
typedef Enum<CacheFilesEnum> CacheFiles; |
@ -0,0 +1,50 @@ |
|||
/*
|
|||
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_statfs.hpp"
|
|||
#include "ef.hpp"
|
|||
#include "errno.hpp"
|
|||
|
|||
template<> |
|||
std::string |
|||
StatFS::to_string() const |
|||
{ |
|||
switch(_data) |
|||
{ |
|||
case StatFS::ENUM::BASE: |
|||
return "base"; |
|||
case StatFS::ENUM::FULL: |
|||
return "full"; |
|||
} |
|||
|
|||
return "invalid"; |
|||
} |
|||
|
|||
template<> |
|||
int |
|||
StatFS::from_string(const std::string &s_) |
|||
{ |
|||
if(s_ == "base") |
|||
_data = StatFS::ENUM::BASE; |
|||
ef(s_ == "full") |
|||
_data = StatFS::ENUM::FULL; |
|||
else |
|||
return -EINVAL; |
|||
|
|||
return 0; |
|||
} |
@ -0,0 +1,29 @@ |
|||
/*
|
|||
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 StatFSEnum |
|||
{ |
|||
BASE, |
|||
FULL |
|||
}; |
|||
|
|||
typedef Enum<StatFSEnum> StatFS; |
@ -0,0 +1,54 @@ |
|||
/*
|
|||
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_statfsignore.hpp"
|
|||
#include "ef.hpp"
|
|||
#include "errno.hpp"
|
|||
|
|||
template<> |
|||
std::string |
|||
StatFSIgnore::to_string() const |
|||
{ |
|||
switch(_data) |
|||
{ |
|||
case StatFSIgnore::ENUM::NONE: |
|||
return "none"; |
|||
case StatFSIgnore::ENUM::RO: |
|||
return "ro"; |
|||
case StatFSIgnore::ENUM::NC: |
|||
return "nc"; |
|||
} |
|||
|
|||
return "invalid"; |
|||
} |
|||
|
|||
template<> |
|||
int |
|||
StatFSIgnore::from_string(const std::string &s_) |
|||
{ |
|||
if(s_ == "none") |
|||
_data = StatFSIgnore::ENUM::NONE; |
|||
ef(s_ == "ro") |
|||
_data = StatFSIgnore::ENUM::RO; |
|||
ef(s_ == "nc") |
|||
_data = StatFSIgnore::ENUM::NC; |
|||
else |
|||
return -EINVAL; |
|||
|
|||
return 0; |
|||
} |
@ -0,0 +1,29 @@ |
|||
/*
|
|||
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 StatFSIgnoreEnum |
|||
{ |
|||
NONE, |
|||
RO, |
|||
NC |
|||
}; |
|||
typedef Enum<StatFSIgnoreEnum> StatFSIgnore; |
@ -0,0 +1,54 @@ |
|||
/*
|
|||
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_xattr.hpp"
|
|||
#include "ef.hpp"
|
|||
#include "errno.hpp"
|
|||
|
|||
template<> |
|||
std::string |
|||
XAttr::to_string() const |
|||
{ |
|||
switch(_data) |
|||
{ |
|||
case XAttr::ENUM::PASSTHROUGH: |
|||
return "passthrough"; |
|||
case XAttr::ENUM::NOSYS: |
|||
return "nosys"; |
|||
case XAttr::ENUM::NOATTR: |
|||
return "noattr"; |
|||
} |
|||
|
|||
return "invalid"; |
|||
} |
|||
|
|||
template<> |
|||
int |
|||
XAttr::from_string(const std::string &s_) |
|||
{ |
|||
if(s_ == "passthrough") |
|||
_data = XAttr::ENUM::PASSTHROUGH; |
|||
ef(s_ == "nosys") |
|||
_data = XAttr::ENUM::NOSYS; |
|||
ef(s_ == "noattr") |
|||
_data = XAttr::ENUM::NOATTR; |
|||
else |
|||
return -EINVAL; |
|||
|
|||
return 0; |
|||
} |
@ -0,0 +1,31 @@ |
|||
/*
|
|||
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"
|
|||
#include "errno.hpp"
|
|||
|
|||
enum class XAttrEnum |
|||
{ |
|||
PASSTHROUGH = 0, |
|||
NOSYS = ENOSYS, |
|||
NOATTR = ENOATTR |
|||
}; |
|||
|
|||
typedef Enum<XAttrEnum> XAttr; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue