mirror of https://github.com/trapexit/mergerfs.git
				
				
			
				 35 changed files with 982 additions and 990 deletions
			
			
		- 
					72README.md
- 
					21src/access.cpp
- 
					51src/buildmap.hpp
- 
					51src/buildvector.hpp
- 
					70src/category.cpp
- 
					98src/category.hpp
- 
					14src/chmod.cpp
- 
					16src/chown.cpp
- 
					15src/config.cpp
- 
					15src/config.hpp
- 
					37src/create.cpp
- 
					535src/fs.cpp
- 
					83src/fs.hpp
- 
					18src/getattr.cpp
- 
					35src/getxattr.cpp
- 
					14src/link.cpp
- 
					42src/listxattr.cpp
- 
					1src/mergerfs.cpp
- 
					30src/mkdir.cpp
- 
					32src/mknod.cpp
- 
					22src/open.cpp
- 
					7src/option_parser.cpp
- 
					259src/policy.cpp
- 
					180src/policy.hpp
- 
					20src/readlink.cpp
- 
					14src/removexattr.cpp
- 
					20src/rename.cpp
- 
					12src/rmdir.cpp
- 
					95src/setxattr.cpp
- 
					10src/symlink.cpp
- 
					2src/test.cpp
- 
					14src/truncate.cpp
- 
					12src/unlink.cpp
- 
					14src/utimens.cpp
- 
					41src/write.cpp
| @ -0,0 +1,51 @@ | |||
| /*
 | |||
|    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 <algorithm>
 | |||
| 
 | |||
| template<typename K,typename V> | |||
| class buildmap | |||
| { | |||
| public: | |||
|   buildmap(const K &key, | |||
|            const V &val) | |||
|   { | |||
|     _map.insert(std::make_pair(key,val)); | |||
|   } | |||
| 
 | |||
|   buildmap<K,V> &operator()(const K &key, | |||
|                             const V &val) | |||
|   { | |||
|     _map.insert(std::make_pair(key,val)); | |||
|     return *this; | |||
|   } | |||
| 
 | |||
|   operator std::map<K,V>() | |||
|   { | |||
|     return _map; | |||
|   } | |||
| 
 | |||
| private: | |||
|   std::map<K,V> _map; | |||
| }; | |||
| @ -0,0 +1,51 @@ | |||
| /*
 | |||
|    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 <algorithm>
 | |||
| 
 | |||
| template<typename V, bool SORT = false> | |||
| class buildvector | |||
| { | |||
| public: | |||
|   buildvector(const V &val) | |||
|   { | |||
|     _vector.push_back(val); | |||
|   } | |||
| 
 | |||
|   buildvector<V,SORT> &operator()(const V &val) | |||
|   { | |||
|     _vector.push_back(val); | |||
|     return *this; | |||
|   } | |||
| 
 | |||
|   operator std::vector<V>() | |||
|   { | |||
|     if(SORT == true) | |||
|       std::sort(_vector.begin(),_vector.end()); | |||
|     return _vector; | |||
|   } | |||
| 
 | |||
| private: | |||
|   std::vector<V> _vector; | |||
| }; | |||
| @ -0,0 +1,70 @@ | |||
| /*
 | |||
|   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 "category.hpp"
 | |||
| #include "buildvector.hpp"
 | |||
| 
 | |||
| #define CATEGORY(X) Category(Category::Enum::X,#X)
 | |||
| 
 | |||
| namespace mergerfs | |||
| { | |||
|   const std::vector<Category> Category::_categories_ = | |||
|     buildvector<Category,true> | |||
|     (CATEGORY(invalid)) | |||
|     (CATEGORY(action)) | |||
|     (CATEGORY(create)) | |||
|     (CATEGORY(search)); | |||
|    | |||
|   const Category * const Category::categories = &_categories_[1]; | |||
| 
 | |||
|   const Category &Category::invalid = Category::categories[Category::Enum::invalid]; | |||
|   const Category &Category::action  = Category::categories[Category::Enum::action]; | |||
|   const Category &Category::create  = Category::categories[Category::Enum::create]; | |||
|   const Category &Category::search  = Category::categories[Category::Enum::search];   | |||
|    | |||
|   const Category& | |||
|   Category::find(const std::string str) | |||
|   { | |||
|     for(int i = Enum::BEGIN; i != Enum::END; ++i) | |||
|       { | |||
|         if(categories[i] == str) | |||
|           return categories[i]; | |||
|       } | |||
| 
 | |||
|     return invalid; | |||
|   } | |||
| 
 | |||
|   const Category& | |||
|   Category::find(const Category::Enum::Type i) | |||
|   { | |||
|     if(i >= Category::Enum::BEGIN && | |||
|        i  < Category::Enum::END) | |||
|       return categories[i]; | |||
| 
 | |||
|     return invalid; | |||
|   }   | |||
| } | |||
| @ -0,0 +1,98 @@ | |||
| /*
 | |||
|    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 __CATEGORY_HPP__
 | |||
| #define __CATEGORY_HPP__
 | |||
| 
 | |||
| #include <string>
 | |||
| #include <vector>
 | |||
| 
 | |||
| namespace mergerfs | |||
| { | |||
|   class Category | |||
|   { | |||
|   public: | |||
|     struct Enum | |||
|     { | |||
|       enum Type | |||
|         { | |||
|           invalid = -1, | |||
|           BEGIN   = 0, | |||
|           action  = BEGIN, | |||
|           create, | |||
|           search, | |||
|           END | |||
|         }; | |||
|     }; | |||
| 
 | |||
|   private: | |||
|     Enum::Type  _enum; | |||
|     std::string _str; | |||
| 
 | |||
|   public: | |||
|     Category() | |||
|       : _enum(invalid), | |||
|         _str(invalid) | |||
|     { | |||
|     } | |||
| 
 | |||
|     Category(const Enum::Type  enum_, | |||
|              const std::string str_) | |||
|       : _enum(enum_), | |||
|         _str(str_) | |||
|     { | |||
|     } | |||
| 
 | |||
|   public: | |||
|     operator const Enum::Type() const { return _enum; } | |||
|     operator const std::string() const { return _str; } | |||
|     operator const Category*() 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 Category &r) const | |||
|     { return _enum != r._enum; } | |||
| 
 | |||
|     bool operator<(const Category &r) const | |||
|     { return _enum < r._enum; } | |||
| 
 | |||
|   public: | |||
|     static const Category &find(const std::string); | |||
|     static const Category &find(const Enum::Type); | |||
| 
 | |||
|   public: | |||
|     static const std::vector<Category>  _categories_; | |||
|     static const Category * const       categories; | |||
|     static const Category              &invalid; | |||
|     static const Category              &action; | |||
|     static const Category              &create; | |||
|     static const Category              &search; | |||
|   }; | |||
| } | |||
| 
 | |||
| #endif
 | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue