mirror of https://github.com/trapexit/mergerfs.git
Antonio SJ Musumeci
10 years ago
32 changed files with 570 additions and 123 deletions
-
84README.md
-
2src/access.cpp
-
2src/category.cpp
-
4src/category.hpp
-
2src/chmod.cpp
-
2src/chown.cpp
-
42src/config.cpp
-
29src/config.hpp
-
2src/create.cpp
-
29src/fs.cpp
-
3src/fs.hpp
-
105src/fusefunc.cpp
-
139src/fusefunc.hpp
-
2src/getattr.cpp
-
70src/getxattr.cpp
-
2src/ioctl.cpp
-
2src/link.cpp
-
23src/listxattr.cpp
-
4src/mkdir.cpp
-
4src/mknod.cpp
-
2src/open.cpp
-
9src/option_parser.cpp
-
2src/readlink.cpp
-
2src/removexattr.cpp
-
2src/rename.cpp
-
2src/rmdir.cpp
-
74src/setxattr.cpp
-
28src/str.cpp
-
4src/str.hpp
-
2src/truncate.cpp
-
2src/unlink.cpp
-
2src/utimens.cpp
@ -0,0 +1,105 @@ |
|||||
|
/*
|
||||
|
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 <string>
|
||||
|
#include <vector>
|
||||
|
|
||||
|
#include "fusefunc.hpp"
|
||||
|
#include "category.hpp"
|
||||
|
#include "buildvector.hpp"
|
||||
|
|
||||
|
#define FUSEFUNC(X,Y) FuseFunc(FuseFunc::Enum::X,#X,Category::Enum::Y)
|
||||
|
|
||||
|
namespace mergerfs |
||||
|
{ |
||||
|
const std::vector<FuseFunc> FuseFunc::_fusefuncs_ = |
||||
|
buildvector<FuseFunc,true> |
||||
|
(FUSEFUNC(invalid,invalid)) |
||||
|
(FUSEFUNC(access,search)) |
||||
|
(FUSEFUNC(chmod,action)) |
||||
|
(FUSEFUNC(chown,action)) |
||||
|
(FUSEFUNC(create,create)) |
||||
|
(FUSEFUNC(getattr,search)) |
||||
|
(FUSEFUNC(getxattr,search)) |
||||
|
(FUSEFUNC(link,action)) |
||||
|
(FUSEFUNC(listxattr,search)) |
||||
|
(FUSEFUNC(mkdir,create)) |
||||
|
(FUSEFUNC(mknod,create)) |
||||
|
(FUSEFUNC(open,search)) |
||||
|
(FUSEFUNC(readlink,search)) |
||||
|
(FUSEFUNC(removexattr,action)) |
||||
|
(FUSEFUNC(rename,action)) |
||||
|
(FUSEFUNC(rmdir,action)) |
||||
|
(FUSEFUNC(setxattr,action)) |
||||
|
(FUSEFUNC(symlink,search)) |
||||
|
(FUSEFUNC(truncate,action)) |
||||
|
(FUSEFUNC(unlink,action)) |
||||
|
(FUSEFUNC(utimens,action)) |
||||
|
; |
||||
|
|
||||
|
const FuseFunc * const FuseFunc::fusefuncs = &_fusefuncs_[1]; |
||||
|
|
||||
|
const FuseFunc &FuseFunc::invalid = FuseFunc::fusefuncs[FuseFunc::Enum::invalid]; |
||||
|
const FuseFunc &FuseFunc::access = FuseFunc::fusefuncs[FuseFunc::Enum::access]; |
||||
|
const FuseFunc &FuseFunc::chmod = FuseFunc::fusefuncs[FuseFunc::Enum::chmod]; |
||||
|
const FuseFunc &FuseFunc::chown = FuseFunc::fusefuncs[FuseFunc::Enum::chown]; |
||||
|
const FuseFunc &FuseFunc::create = FuseFunc::fusefuncs[FuseFunc::Enum::create]; |
||||
|
const FuseFunc &FuseFunc::getattr = FuseFunc::fusefuncs[FuseFunc::Enum::getattr]; |
||||
|
const FuseFunc &FuseFunc::getxattr = FuseFunc::fusefuncs[FuseFunc::Enum::getxattr]; |
||||
|
const FuseFunc &FuseFunc::link = FuseFunc::fusefuncs[FuseFunc::Enum::link]; |
||||
|
const FuseFunc &FuseFunc::listxattr = FuseFunc::fusefuncs[FuseFunc::Enum::listxattr]; |
||||
|
const FuseFunc &FuseFunc::mkdir = FuseFunc::fusefuncs[FuseFunc::Enum::mkdir]; |
||||
|
const FuseFunc &FuseFunc::mknod = FuseFunc::fusefuncs[FuseFunc::Enum::mknod]; |
||||
|
const FuseFunc &FuseFunc::open = FuseFunc::fusefuncs[FuseFunc::Enum::open]; |
||||
|
const FuseFunc &FuseFunc::readlink = FuseFunc::fusefuncs[FuseFunc::Enum::readlink]; |
||||
|
const FuseFunc &FuseFunc::removexattr = FuseFunc::fusefuncs[FuseFunc::Enum::removexattr]; |
||||
|
const FuseFunc &FuseFunc::rmdir = FuseFunc::fusefuncs[FuseFunc::Enum::rmdir]; |
||||
|
const FuseFunc &FuseFunc::setxattr = FuseFunc::fusefuncs[FuseFunc::Enum::setxattr]; |
||||
|
const FuseFunc &FuseFunc::symlink = FuseFunc::fusefuncs[FuseFunc::Enum::symlink]; |
||||
|
const FuseFunc &FuseFunc::truncate = FuseFunc::fusefuncs[FuseFunc::Enum::truncate]; |
||||
|
const FuseFunc &FuseFunc::unlink = FuseFunc::fusefuncs[FuseFunc::Enum::unlink]; |
||||
|
const FuseFunc &FuseFunc::utimens = FuseFunc::fusefuncs[FuseFunc::Enum::utimens]; |
||||
|
|
||||
|
const FuseFunc& |
||||
|
FuseFunc::find(const std::string &str) |
||||
|
{ |
||||
|
for(int i = Enum::BEGIN; i != Enum::END; ++i) |
||||
|
{ |
||||
|
if(fusefuncs[i] == str) |
||||
|
return fusefuncs[i]; |
||||
|
} |
||||
|
|
||||
|
return invalid; |
||||
|
} |
||||
|
|
||||
|
const FuseFunc& |
||||
|
FuseFunc::find(const FuseFunc::Enum::Type i) |
||||
|
{ |
||||
|
if(i >= FuseFunc::Enum::BEGIN && |
||||
|
i < FuseFunc::Enum::END) |
||||
|
return fusefuncs[i]; |
||||
|
|
||||
|
return invalid; |
||||
|
} |
||||
|
} |
@ -0,0 +1,139 @@ |
|||||
|
/*
|
||||
|
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. |
||||
|
*/ |
||||
|
|
||||
|
#ifndef __FUSEFUNC_HPP__
|
||||
|
#define __FUSEFUNC_HPP__
|
||||
|
|
||||
|
#include <string>
|
||||
|
#include <vector>
|
||||
|
|
||||
|
#include "category.hpp"
|
||||
|
|
||||
|
namespace mergerfs |
||||
|
{ |
||||
|
class FuseFunc |
||||
|
{ |
||||
|
public: |
||||
|
struct Enum |
||||
|
{ |
||||
|
enum Type |
||||
|
{ |
||||
|
invalid = -1, |
||||
|
BEGIN = 0, |
||||
|
access = BEGIN, |
||||
|
chmod, |
||||
|
chown, |
||||
|
create, |
||||
|
getattr, |
||||
|
getxattr, |
||||
|
link, |
||||
|
listxattr, |
||||
|
mkdir, |
||||
|
mknod, |
||||
|
open, |
||||
|
readlink, |
||||
|
removexattr, |
||||
|
rename, |
||||
|
rmdir, |
||||
|
setxattr, |
||||
|
symlink, |
||||
|
truncate, |
||||
|
unlink, |
||||
|
utimens, |
||||
|
END |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
|
private: |
||||
|
Enum::Type _enum; |
||||
|
std::string _str; |
||||
|
Category::Enum::Type _category; |
||||
|
|
||||
|
public: |
||||
|
FuseFunc() |
||||
|
: _enum(invalid), |
||||
|
_str(invalid), |
||||
|
_category(Category::Enum::invalid) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
FuseFunc(const Enum::Type enum_, |
||||
|
const std::string &str_, |
||||
|
const Category::Enum::Type category_) |
||||
|
: _enum(enum_), |
||||
|
_str(str_), |
||||
|
_category(category_) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public: |
||||
|
operator const Enum::Type() const { return _enum; } |
||||
|
operator const std::string&() const { return _str; } |
||||
|
operator const Category::Enum::Type() const { return _category; } |
||||
|
operator const FuseFunc*() const { return this; } |
||||
|
|
||||
|
bool operator==(const std::string &str_) const |
||||
|
{ return _str == str_; } |
||||
|
|
||||
|
bool operator==(const Enum::Type enum_) const |
||||
|
{ return _enum == enum_; } |
||||
|
|
||||
|
bool operator!=(const FuseFunc &r) const |
||||
|
{ return _enum != r._enum; } |
||||
|
|
||||
|
bool operator<(const FuseFunc &r) const |
||||
|
{ return _enum < r._enum; } |
||||
|
|
||||
|
public: |
||||
|
static const FuseFunc &find(const std::string&); |
||||
|
static const FuseFunc &find(const Enum::Type); |
||||
|
|
||||
|
public: |
||||
|
static const std::vector<FuseFunc> _fusefuncs_; |
||||
|
static const FuseFunc * const fusefuncs; |
||||
|
static const FuseFunc &invalid; |
||||
|
static const FuseFunc &access; |
||||
|
static const FuseFunc &chmod; |
||||
|
static const FuseFunc &chown; |
||||
|
static const FuseFunc &create; |
||||
|
static const FuseFunc &getattr; |
||||
|
static const FuseFunc &getxattr; |
||||
|
static const FuseFunc &link; |
||||
|
static const FuseFunc &listxattr; |
||||
|
static const FuseFunc &mkdir; |
||||
|
static const FuseFunc &mknod; |
||||
|
static const FuseFunc &open; |
||||
|
static const FuseFunc &readlink; |
||||
|
static const FuseFunc &removexattr; |
||||
|
static const FuseFunc &rename; |
||||
|
static const FuseFunc &rmdir; |
||||
|
static const FuseFunc &setxattr; |
||||
|
static const FuseFunc &symlink; |
||||
|
static const FuseFunc &truncate; |
||||
|
static const FuseFunc &unlink; |
||||
|
static const FuseFunc &utimens; |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
#endif
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue