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.

94 lines
2.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. #ifndef __CONFIG_HPP__
  15. #define __CONFIG_HPP__
  16. #include <fuse.h>
  17. #include <sys/stat.h>
  18. #include <stdint.h>
  19. #include <string>
  20. #include <vector>
  21. #include "policy.hpp"
  22. #include "fusefunc.hpp"
  23. namespace mergerfs
  24. {
  25. class Config
  26. {
  27. public:
  28. Config();
  29. public:
  30. int set_func_policy(const std::string &fusefunc_,
  31. const std::string &policy_);
  32. int set_category_policy(const std::string &category,
  33. const std::string &policy);
  34. public:
  35. std::string destmount;
  36. std::vector<std::string> srcmounts;
  37. mutable pthread_rwlock_t srcmountslock;
  38. size_t minfreespace;
  39. bool moveonenospc;
  40. public:
  41. const Policy *policies[FuseFunc::Enum::END];
  42. const Policy *&access;
  43. const Policy *&chmod;
  44. const Policy *&chown;
  45. const Policy *&create;
  46. const Policy *&getattr;
  47. const Policy *&getxattr;
  48. const Policy *&link;
  49. const Policy *&listxattr;
  50. const Policy *&mkdir;
  51. const Policy *&mknod;
  52. const Policy *&open;
  53. const Policy *&readlink;
  54. const Policy *&removexattr;
  55. const Policy *&rename;
  56. const Policy *&rmdir;
  57. const Policy *&setxattr;
  58. const Policy *&symlink;
  59. const Policy *&truncate;
  60. const Policy *&unlink;
  61. const Policy *&utimens;
  62. public:
  63. const std::string controlfile;
  64. public:
  65. static
  66. const Config &
  67. get(const fuse_context *fc)
  68. {
  69. return *((Config*)fc->private_data);
  70. }
  71. static
  72. Config &
  73. get_writable(void)
  74. {
  75. return (*((Config*)fuse_get_context()->private_data));
  76. }
  77. };
  78. }
  79. #endif