You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.4 KiB

  1. /*
  2. Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted, provided that the above
  5. copyright notice and this permission notice appear in all copies.
  6. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. */
  14. #pragma once
  15. #include "branch.hpp"
  16. #include "config_cachefiles.hpp"
  17. #include "config_inodecalc.hpp"
  18. #include "config_moveonenospc.hpp"
  19. #include "config_nfsopenhack.hpp"
  20. #include "config_readdir.hpp"
  21. #include "config_statfs.hpp"
  22. #include "config_statfsignore.hpp"
  23. #include "config_xattr.hpp"
  24. #include "enum.hpp"
  25. #include "errno.hpp"
  26. #include "func_category.hpp"
  27. #include "funcs.hpp"
  28. #include "policy.hpp"
  29. #include "policy_cache.hpp"
  30. #include "tofrom_wrapper.hpp"
  31. #include <fuse.h>
  32. #include <string>
  33. #include <vector>
  34. #include <stdint.h>
  35. #include <sys/stat.h>
  36. typedef ToFromWrapper<bool> ConfigBOOL;
  37. typedef ToFromWrapper<uint64_t> ConfigUINT64;
  38. typedef ToFromWrapper<int> ConfigINT;
  39. typedef ToFromWrapper<std::string> ConfigSTR;
  40. typedef std::map<std::string,ToFromString*> Str2TFStrMap;
  41. class Config
  42. {
  43. public:
  44. Config();
  45. public:
  46. mutable PolicyCache open_cache;
  47. public:
  48. const std::string controlfile;
  49. public:
  50. ConfigBOOL async_read;
  51. ConfigBOOL auto_cache;
  52. Branches branches;
  53. ConfigUINT64 cache_attr;
  54. ConfigUINT64 cache_entry;
  55. CacheFiles cache_files;
  56. ConfigUINT64 cache_negative_entry;
  57. ConfigBOOL cache_readdir;
  58. ConfigUINT64 cache_statfs;
  59. ConfigBOOL cache_symlinks;
  60. FuncCategories category;
  61. ConfigBOOL direct_io;
  62. ConfigBOOL dropcacheonclose;
  63. ConfigSTR fsname;
  64. Funcs func;
  65. ConfigUINT64 fuse_msg_size;
  66. ConfigBOOL ignorepponrename;
  67. InodeCalc inodecalc;
  68. ConfigBOOL kernel_cache;
  69. ConfigBOOL link_cow;
  70. ConfigUINT64 minfreespace;
  71. ConfigSTR mount;
  72. MoveOnENOSPC moveonenospc;
  73. NFSOpenHack nfsopenhack;
  74. ConfigBOOL nullrw;
  75. ConfigUINT64 pid;
  76. ConfigBOOL posix_acl;
  77. ReadDir readdir;
  78. ConfigBOOL readdirplus;
  79. ConfigBOOL security_capability;
  80. SrcMounts srcmounts;
  81. StatFS statfs;
  82. StatFSIgnore statfs_ignore;
  83. ConfigBOOL symlinkify;
  84. ConfigUINT64 symlinkify_timeout;
  85. ConfigINT threads;
  86. ConfigSTR version;
  87. ConfigBOOL writeback_cache;
  88. XAttr xattr;
  89. public:
  90. friend std::ostream& operator<<(std::ostream &s,
  91. const Config &c);
  92. public:
  93. bool has_key(const std::string &key) const;
  94. void keys(std::string &s) const;
  95. void keys_xattr(std::string &s) const;
  96. public:
  97. int get(const std::string &key, std::string *val) const;
  98. int set_raw(const std::string &key, const std::string &val);
  99. int set(const std::string &key, const std::string &val);
  100. public:
  101. static const Config &ro(void);
  102. static Config &rw(void);
  103. private:
  104. Str2TFStrMap _map;
  105. };