2014-05-12 12:41:46 -04:00
|
|
|
/*
|
2016-01-14 16:50:22 -05:00
|
|
|
Copyright (c) 2016, 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.
|
2014-05-12 12:41:46 -04:00
|
|
|
*/
|
|
|
|
|
2017-06-30 11:15:20 -04:00
|
|
|
#pragma once
|
2014-05-12 12:41:46 -04:00
|
|
|
|
2018-10-20 23:40:02 -04:00
|
|
|
#include "branch.hpp"
|
2020-06-22 13:03:48 -04:00
|
|
|
#include "config_inodecalc.hpp"
|
2020-06-26 16:50:49 -04:00
|
|
|
#include "config_readdir.hpp"
|
2020-07-12 14:03:14 -04:00
|
|
|
#include "config_moveonenospc.hpp"
|
2019-09-24 10:27:46 -04:00
|
|
|
#include "enum.hpp"
|
|
|
|
#include "errno.hpp"
|
|
|
|
#include "func_category.hpp"
|
|
|
|
#include "funcs.hpp"
|
2018-10-02 14:22:37 -04:00
|
|
|
#include "policy.hpp"
|
2019-01-06 12:52:55 -05:00
|
|
|
#include "policy_cache.hpp"
|
2019-09-24 10:27:46 -04:00
|
|
|
#include "tofrom_wrapper.hpp"
|
2018-10-02 14:22:37 -04:00
|
|
|
|
2014-09-26 18:31:22 -04:00
|
|
|
#include <fuse.h>
|
|
|
|
|
2014-05-12 12:41:46 -04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-01-25 07:03:46 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2019-09-24 10:27:46 -04:00
|
|
|
typedef ToFromWrapper<bool> ConfigBOOL;
|
|
|
|
typedef ToFromWrapper<uint64_t> ConfigUINT64;
|
|
|
|
typedef ToFromWrapper<int> ConfigINT;
|
|
|
|
typedef ToFromWrapper<std::string> ConfigSTR;
|
|
|
|
typedef std::map<std::string,ToFromString*> Str2TFStrMap;
|
|
|
|
|
2019-01-25 07:03:46 -05:00
|
|
|
class Config
|
2014-05-12 12:41:46 -04:00
|
|
|
{
|
2019-01-25 07:03:46 -05:00
|
|
|
public:
|
2019-09-24 10:27:46 -04:00
|
|
|
enum class StatFSEnum
|
|
|
|
{
|
|
|
|
BASE,
|
|
|
|
FULL
|
|
|
|
};
|
|
|
|
typedef Enum<StatFSEnum> StatFS;
|
|
|
|
|
|
|
|
enum class StatFSIgnoreEnum
|
|
|
|
{
|
|
|
|
NONE,
|
|
|
|
RO,
|
|
|
|
NC
|
|
|
|
};
|
|
|
|
typedef Enum<StatFSIgnoreEnum> StatFSIgnore;
|
|
|
|
|
|
|
|
enum class CacheFilesEnum
|
|
|
|
{
|
|
|
|
LIBFUSE,
|
|
|
|
OFF,
|
|
|
|
PARTIAL,
|
|
|
|
FULL,
|
|
|
|
AUTO_FULL
|
|
|
|
};
|
|
|
|
typedef Enum<CacheFilesEnum> CacheFiles;
|
|
|
|
|
|
|
|
enum class XAttrEnum
|
|
|
|
{
|
|
|
|
PASSTHROUGH = 0,
|
|
|
|
NOSYS = ENOSYS,
|
|
|
|
NOATTR = ENOATTR
|
|
|
|
};
|
|
|
|
typedef Enum<XAttrEnum> XAttr;
|
2019-05-23 23:22:36 -04:00
|
|
|
|
2019-01-25 07:03:46 -05:00
|
|
|
public:
|
|
|
|
Config();
|
|
|
|
|
|
|
|
public:
|
2019-09-24 10:27:46 -04:00
|
|
|
mutable PolicyCache open_cache;
|
2019-01-25 07:03:46 -05:00
|
|
|
|
|
|
|
public:
|
2019-09-24 10:27:46 -04:00
|
|
|
const std::string controlfile;
|
2019-01-25 07:03:46 -05:00
|
|
|
|
|
|
|
public:
|
2019-09-24 10:27:46 -04:00
|
|
|
ConfigBOOL async_read;
|
|
|
|
ConfigBOOL auto_cache;
|
|
|
|
Branches branches;
|
|
|
|
ConfigUINT64 cache_attr;
|
|
|
|
ConfigUINT64 cache_entry;
|
|
|
|
CacheFiles cache_files;
|
|
|
|
ConfigUINT64 cache_negative_entry;
|
|
|
|
ConfigBOOL cache_readdir;
|
|
|
|
ConfigUINT64 cache_statfs;
|
|
|
|
ConfigBOOL cache_symlinks;
|
|
|
|
FuncCategories category;
|
|
|
|
ConfigBOOL direct_io;
|
|
|
|
ConfigBOOL dropcacheonclose;
|
|
|
|
ConfigSTR fsname;
|
|
|
|
Funcs func;
|
|
|
|
ConfigUINT64 fuse_msg_size;
|
|
|
|
ConfigBOOL ignorepponrename;
|
2020-06-22 13:03:48 -04:00
|
|
|
InodeCalc inodecalc;
|
2019-09-24 10:27:46 -04:00
|
|
|
ConfigBOOL kernel_cache;
|
|
|
|
ConfigBOOL link_cow;
|
|
|
|
ConfigUINT64 minfreespace;
|
|
|
|
ConfigSTR mount;
|
2020-07-12 14:03:14 -04:00
|
|
|
MoveOnENOSPC moveonenospc;
|
2019-09-24 10:27:46 -04:00
|
|
|
ConfigBOOL nullrw;
|
|
|
|
ConfigUINT64 pid;
|
|
|
|
ConfigBOOL posix_acl;
|
2020-06-26 16:50:49 -04:00
|
|
|
ReadDir readdir;
|
2019-09-24 10:27:46 -04:00
|
|
|
ConfigBOOL readdirplus;
|
|
|
|
ConfigBOOL security_capability;
|
|
|
|
SrcMounts srcmounts;
|
|
|
|
StatFS statfs;
|
|
|
|
StatFSIgnore statfs_ignore;
|
|
|
|
ConfigBOOL symlinkify;
|
|
|
|
ConfigUINT64 symlinkify_timeout;
|
|
|
|
ConfigINT threads;
|
|
|
|
ConfigSTR version;
|
|
|
|
ConfigBOOL writeback_cache;
|
|
|
|
XAttr xattr;
|
2019-01-25 07:03:46 -05:00
|
|
|
|
|
|
|
public:
|
2019-09-24 10:27:46 -04:00
|
|
|
friend std::ostream& operator<<(std::ostream &s,
|
|
|
|
const Config &c);
|
2019-01-25 07:03:46 -05:00
|
|
|
|
|
|
|
public:
|
2019-09-24 10:27:46 -04:00
|
|
|
bool has_key(const std::string &key) const;
|
|
|
|
void keys(std::string &s) const;
|
|
|
|
void keys_xattr(std::string &s) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
int get(const std::string &key, std::string *val) const;
|
|
|
|
int set_raw(const std::string &key, const std::string &val);
|
|
|
|
int set(const std::string &key, const std::string &val);
|
2019-01-25 07:03:46 -05:00
|
|
|
|
|
|
|
public:
|
2019-09-24 10:27:46 -04:00
|
|
|
static const Config &ro(void);
|
|
|
|
static Config &rw(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Str2TFStrMap _map;
|
2019-01-25 07:03:46 -05:00
|
|
|
};
|