mergerfs/src/config.hpp

134 lines
3.2 KiB
C++
Raw Normal View History

2014-05-12 12:41:46 -04: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
#include "branch.hpp"
#include "fusefunc.hpp"
#include "policy.hpp"
#include <fuse.h>
2015-06-16 22:12:55 -04:00
#include <stdint.h>
#include <sys/stat.h>
2014-05-12 12:41:46 -04:00
#include <string>
#include <vector>
namespace mergerfs
{
2015-07-21 14:19:17 -04:00
class Config
2014-05-12 12:41:46 -04:00
{
2018-11-02 10:23:56 -04:00
public:
struct StatFS
{
enum Enum
{
BASE,
FULL
};
};
struct StatFSIgnore
{
enum Enum
{
NONE,
RO,
NC
};
};
2015-07-21 14:19:17 -04:00
public:
Config();
public:
int set_func_policy(const std::string &fusefunc_,
const std::string &policy_);
int set_category_policy(const std::string &category_,
const std::string &policy_);
2015-07-21 14:19:17 -04:00
public:
std::string destmount;
Branches branches;
mutable pthread_rwlock_t branches_lock;
uint64_t minfreespace;
bool moveonenospc;
bool direct_io;
bool dropcacheonclose;
bool symlinkify;
time_t symlinkify_timeout;
bool nullrw;
bool ignorepponrename;
2018-09-30 19:47:44 -04:00
bool security_capability;
bool link_cow;
int xattr;
2018-11-02 10:23:56 -04:00
StatFS::Enum statfs;
StatFSIgnore::Enum statfs_ignore;
2015-07-21 14:19:17 -04:00
public:
const Policy *policies[FuseFunc::Enum::END];
const Policy *&access;
const Policy *&chmod;
const Policy *&chown;
const Policy *&create;
const Policy *&getattr;
const Policy *&getxattr;
const Policy *&link;
const Policy *&listxattr;
const Policy *&mkdir;
const Policy *&mknod;
const Policy *&open;
const Policy *&readlink;
const Policy *&removexattr;
const Policy *&rename;
const Policy *&rmdir;
const Policy *&setxattr;
const Policy *&symlink;
const Policy *&truncate;
const Policy *&unlink;
const Policy *&utimens;
public:
const std::string controlfile;
public:
2017-04-11 08:53:46 -04:00
static
const
Config &
get(void)
{
const fuse_context *fc = fuse_get_context();
return get(fc);
}
2015-07-21 14:19:17 -04:00
static
const Config &
get(const fuse_context *fc)
2014-05-12 12:41:46 -04:00
{
2015-07-21 14:19:17 -04:00
return *((Config*)fc->private_data);
}
static
Config &
get_writable(void)
{
return (*((Config*)fuse_get_context()->private_data));
}
};
2014-05-12 12:41:46 -04:00
}