refactor
This commit is contained in:
		| @@ -52,7 +52,8 @@ private: | ||||
|  | ||||
| protected: | ||||
|   bool atime_enabled_{true}; | ||||
|   bool console_enabled_{false}; | ||||
|   bool console_enabled_{true}; | ||||
|   bool foreground_{false}; | ||||
|   std::optional<gid_t> forced_gid_; | ||||
|   std::optional<uid_t> forced_uid_; | ||||
|   std::optional<mode_t> forced_umask_; | ||||
| @@ -95,50 +96,51 @@ private: | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] static auto chmod_(const char *path, mode_t mode, | ||||
|                                    struct fuse_file_info *fi) -> int; | ||||
|                                    struct fuse_file_info *f_info) -> int; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] static auto chmod_(const char *path, mode_t mode) -> int; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid, | ||||
|                                    struct fuse_file_info *fi) -> int; | ||||
|                                    struct fuse_file_info *f_info) -> int; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid) | ||||
|       -> int; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
|   [[nodiscard]] static auto create_(const char *path, mode_t mode, | ||||
|                                     struct fuse_file_info *fi) -> int; | ||||
|                                     struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
|   static void destroy_(void *ptr); | ||||
|  | ||||
|   [[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset, | ||||
|                                        off_t length, struct fuse_file_info *fi) | ||||
|       -> int; | ||||
|                                        off_t length, | ||||
|                                        struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
| #if FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] static auto fgetattr_(const char *path, struct stat *st, | ||||
|                                       struct fuse_file_info *fi) -> int; | ||||
|   [[nodiscard]] static auto fgetattr_(const char *path, struct stat *u_stat, | ||||
|                                       struct fuse_file_info *f_info) -> int; | ||||
| #endif // FUSE_USE_VERSION < 30 | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
|   [[nodiscard]] static auto fsetattr_x_(const char *path, | ||||
|                                         struct setattr_x *attr, | ||||
|                                         struct fuse_file_info *fi) -> int; | ||||
|                                         struct fuse_file_info *f_info) -> int; | ||||
| #endif // defined(__APPLE__) | ||||
|  | ||||
|   [[nodiscard]] static auto fsync_(const char *path, int datasync, | ||||
|                                    struct fuse_file_info *fi) -> int; | ||||
|                                    struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
|   [[nodiscard]] static auto ftruncate_(const char *path, off_t size, | ||||
|                                        struct fuse_file_info *fi) -> int; | ||||
|                                        struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] static auto getattr_(const char *path, struct stat *st, | ||||
|                                      struct fuse_file_info *fi) -> int; | ||||
|   [[nodiscard]] static auto getattr_(const char *path, struct stat *u_stat, | ||||
|                                      struct fuse_file_info *f_info) -> int; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] static auto getattr_(const char *path, struct stat *st) -> int; | ||||
|   [[nodiscard]] static auto getattr_(const char *path, struct stat *u_stat) | ||||
|       -> int; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
| @@ -156,33 +158,34 @@ private: | ||||
|  | ||||
|   [[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int; | ||||
|  | ||||
|   [[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi) | ||||
|       -> int; | ||||
|   [[nodiscard]] static auto open_(const char *path, | ||||
|                                   struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
|   [[nodiscard]] static auto opendir_(const char *path, | ||||
|                                      struct fuse_file_info *fi) -> int; | ||||
|                                      struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
|   [[nodiscard]] static auto read_(const char *path, char *buffer, | ||||
|                                   size_t read_size, off_t read_offset, | ||||
|                                   struct fuse_file_info *fi) -> int; | ||||
|                                   struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] static auto readdir_(const char *path, void *buf, | ||||
|                                      fuse_fill_dir_t fuse_fill_dir, | ||||
|                                      off_t offset, struct fuse_file_info *fi, | ||||
|                                      off_t offset, | ||||
|                                      struct fuse_file_info *f_info, | ||||
|                                      fuse_readdir_flags flags) -> int; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] static auto readdir_(const char *path, void *buf, | ||||
|                                      fuse_fill_dir_t fuse_fill_dir, | ||||
|                                      off_t offset, struct fuse_file_info *fi) | ||||
|       -> int; | ||||
|                                      off_t offset, | ||||
|                                      struct fuse_file_info *f_info) -> int; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
|   [[nodiscard]] static auto release_(const char *path, | ||||
|                                      struct fuse_file_info *fi) -> int; | ||||
|                                      struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
|   [[nodiscard]] static auto releasedir_(const char *path, | ||||
|                                         struct fuse_file_info *fi) -> int; | ||||
|                                         struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] static auto rename_(const char *from, const char *to, | ||||
| @@ -248,7 +251,7 @@ private: | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] static auto truncate_(const char *path, off_t size, | ||||
|                                       struct fuse_file_info *fi) -> int; | ||||
|                                       struct fuse_file_info *f_info) -> int; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] static auto truncate_(const char *path, off_t size) -> int; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
| @@ -258,7 +261,7 @@ private: | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] static auto utimens_(const char *path, | ||||
|                                      const struct timespec tv[2], | ||||
|                                      struct fuse_file_info *fi) -> int; | ||||
|                                      struct fuse_file_info *f_info) -> int; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] static auto utimens_(const char *path, | ||||
|                                      const struct timespec tv[2]) -> int; | ||||
| @@ -266,7 +269,7 @@ private: | ||||
|  | ||||
|   [[nodiscard]] static auto write_(const char *path, const char *buffer, | ||||
|                                    size_t write_size, off_t write_offset, | ||||
|                                    struct fuse_file_info *fi) -> int; | ||||
|                                    struct fuse_file_info *f_info) -> int; | ||||
|  | ||||
| protected: | ||||
|   [[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/) | ||||
| @@ -284,11 +287,11 @@ protected: | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, | ||||
|                                         mode_t /*mode*/, | ||||
|                                         struct fuse_file_info * /*fi*/) | ||||
|                                         struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #else //FUSE_USE_VERSION < 30 | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, | ||||
|                                         mode_t /*mode*/) -> api_error { | ||||
|     return api_error::not_implemented; | ||||
| @@ -298,11 +301,11 @@ protected: | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, | ||||
|                                         gid_t /*gid*/, | ||||
|                                         struct fuse_file_info * /*fi*/) | ||||
|                                         struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #else // FUSE_USE_VERSION < 30 | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, | ||||
|                                         gid_t /*gid*/) -> api_error { | ||||
|     return api_error::not_implemented; | ||||
| @@ -311,7 +314,7 @@ protected: | ||||
|  | ||||
|   [[nodiscard]] virtual auto create_impl(std::string /*api_path*/, | ||||
|                                          mode_t /*mode*/, | ||||
|                                          struct fuse_file_info * /*fi*/) | ||||
|                                          struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| @@ -320,14 +323,14 @@ protected: | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/, | ||||
|                  off_t /*length*/, struct fuse_file_info * /*fi*/) | ||||
|                  off_t /*length*/, struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
|  | ||||
|   [[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/, | ||||
|                                            struct stat * /*st*/, | ||||
|                                            struct fuse_file_info * /*fi*/) | ||||
|                                            struct stat * /*u_stat*/, | ||||
|                                            struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| @@ -335,7 +338,7 @@ protected: | ||||
| #if defined(__APPLE__) | ||||
|   [[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/, | ||||
|                                              struct setattr_x * /*attr*/, | ||||
|                                              struct fuse_file_info * /*fi*/) | ||||
|                                              struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| @@ -343,7 +346,7 @@ protected: | ||||
|  | ||||
|   [[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/, | ||||
|                                         int /*datasync*/, | ||||
|                                         struct fuse_file_info * /*fi*/) | ||||
|                                         struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| @@ -351,7 +354,7 @@ protected: | ||||
| #if FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/, | ||||
|                                             off_t /*size*/, | ||||
|                                             struct fuse_file_info * /*fi*/) | ||||
|                                             struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| @@ -359,14 +362,15 @@ protected: | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, | ||||
|                                           struct stat * /*st*/, | ||||
|                                           struct fuse_file_info * /*fi*/) | ||||
|                                           struct stat * /*u_stat*/, | ||||
|                                           struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #else // FUSE_USE_VERSION < 30 | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, | ||||
|                                           struct stat * /*st*/) -> api_error { | ||||
|                                           struct stat * /*u_stat*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
| @@ -383,7 +387,7 @@ protected: | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) | ||||
|       -> void *; | ||||
| #else // FUSE_USE_VERSION < 30 | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   virtual auto init_impl(struct fuse_conn_info *conn) -> void *; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
| @@ -393,20 +397,20 @@ protected: | ||||
|   } | ||||
|  | ||||
|   [[nodiscard]] virtual auto open_impl(std::string /*api_path*/, | ||||
|                                        struct fuse_file_info * /*fi*/) | ||||
|                                        struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
|  | ||||
|   [[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/, | ||||
|                                           struct fuse_file_info * /*fi*/) | ||||
|                                           struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   read_impl(std::string /*api_path*/, char * /*buffer*/, size_t /*read_size*/, | ||||
|             off_t /*read_offset*/, struct fuse_file_info * /*fi*/, | ||||
|             off_t /*read_offset*/, struct fuse_file_info * /*f_info*/, | ||||
|             std::size_t & /*bytes_read*/) -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| @@ -415,27 +419,27 @@ protected: | ||||
|   [[nodiscard]] virtual auto | ||||
|   readdir_impl(std::string /*api_path*/, void * /*buf*/, | ||||
|                fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, | ||||
|                struct fuse_file_info * /*fi*/, fuse_readdir_flags /*flags*/) | ||||
|                struct fuse_file_info * /*f_info*/, fuse_readdir_flags /*flags*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #else // FUSE_USE_VERSION < 30 | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] virtual auto | ||||
|   readdir_impl(std::string /*api_path*/, void * /*buf*/, | ||||
|                fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, | ||||
|                struct fuse_file_info * /*fi*/) -> api_error { | ||||
|                struct fuse_file_info * /*f_info*/) -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
|   [[nodiscard]] virtual auto release_impl(std::string /*api_path*/, | ||||
|                                           struct fuse_file_info * /*fi*/) | ||||
|                                           struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
|  | ||||
|   [[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/, | ||||
|                                              struct fuse_file_info * /*fi*/) | ||||
|                                              struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| @@ -446,7 +450,7 @@ protected: | ||||
|                                          unsigned int /*flags*/) -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #else // FUSE_USE_VERSION < 30 | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/, | ||||
|                                          std::string /*to_api_path*/) | ||||
|       -> api_error { | ||||
| @@ -551,11 +555,11 @@ protected: | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, | ||||
|                                            off_t /*size*/, | ||||
|                                            struct fuse_file_info * /*fi*/) | ||||
|                                            struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #else // FUSE_USE_VERSION < 30 | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, | ||||
|                                            off_t /*size*/) -> api_error { | ||||
|     return api_error::not_implemented; | ||||
| @@ -570,11 +574,11 @@ protected: | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, | ||||
|                                           const struct timespec /*tv*/[2], | ||||
|                                           struct fuse_file_info * /*fi*/) | ||||
|                                           struct fuse_file_info * /*f_info*/) | ||||
|       -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
| #else // FUSE_USE_VERSION < 30 | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, | ||||
|                                           const struct timespec /*tv*/[2]) | ||||
|       -> api_error { | ||||
| @@ -585,8 +589,8 @@ protected: | ||||
|   [[nodiscard]] virtual auto | ||||
|   write_impl(std::string /*api_path*/, const char * /*buffer*/, | ||||
|              size_t /*write_size*/, off_t /*write_offset*/, | ||||
|              struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/) | ||||
|       -> api_error { | ||||
|              struct fuse_file_info * /*f_info*/, | ||||
|              std::size_t & /*bytes_written*/) -> api_error { | ||||
|     return api_error::not_implemented; | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -79,7 +79,7 @@ protected: | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, | ||||
|                                 struct fuse_file_info *file_info) | ||||
|                                 struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) | ||||
| @@ -88,7 +88,7 @@ protected: | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, | ||||
|                                 struct fuse_file_info *file_info) | ||||
|                                 struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) | ||||
| @@ -96,43 +96,43 @@ protected: | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
|   [[nodiscard]] auto create_impl(std::string api_path, mode_t mode, | ||||
|                                  struct fuse_file_info *file_info) | ||||
|                                  struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   void destroy_impl(void *ptr) override; | ||||
|  | ||||
|   [[nodiscard]] auto fallocate_impl(std::string api_path, int mode, | ||||
|                                     off_t offset, off_t length, | ||||
|                                     struct fuse_file_info *file_info) | ||||
|                                     struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *unix_st, | ||||
|                                    struct fuse_file_info *file_info) | ||||
|   [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *u_stat, | ||||
|                                    struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
|   [[nodiscard]] auto fsetattr_x_impl(std::string api_path, | ||||
|                                      struct setattr_x *attr, | ||||
|                                      struct fuse_file_info *file_info) | ||||
|                                      struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #endif // defined(__APPLE__) | ||||
|  | ||||
|   [[nodiscard]] auto fsync_impl(std::string api_path, int datasync, | ||||
|                                 struct fuse_file_info *file_info) | ||||
|                                 struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
| #if FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, | ||||
|                                     struct fuse_file_info *file_info) | ||||
|                                     struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #endif // FUSE_USE_VERSION < 30 | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st, | ||||
|                                   struct fuse_file_info *file_info) | ||||
|   [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat, | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *unix_st) | ||||
|   [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat) | ||||
|       -> api_error override; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
| @@ -156,37 +156,37 @@ protected: | ||||
|   void notify_fuse_main_exit(int &ret) override; | ||||
|  | ||||
|   [[nodiscard]] auto open_impl(std::string api_path, | ||||
|                                struct fuse_file_info *file_info) | ||||
|                                struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto opendir_impl(std::string api_path, | ||||
|                                   struct fuse_file_info *file_info) | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto read_impl(std::string api_path, char *buffer, | ||||
|                                size_t read_size, off_t read_offset, | ||||
|                                struct fuse_file_info *file_info, | ||||
|                                struct fuse_file_info *f_info, | ||||
|                                std::size_t &bytes_read) -> api_error override; | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, | ||||
|                                   fuse_fill_dir_t fuse_fill_dir, off_t offset, | ||||
|                                   struct fuse_file_info *file_info, | ||||
|                                   struct fuse_file_info *f_info, | ||||
|                                   fuse_readdir_flags flags) | ||||
|       -> api_error override; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, | ||||
|                                   fuse_fill_dir_t fuse_fill_dir, off_t offset, | ||||
|                                   struct fuse_file_info *file_info) | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
|   [[nodiscard]] auto release_impl(std::string api_path, | ||||
|                                   struct fuse_file_info *file_info) | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto releasedir_impl(std::string api_path, | ||||
|                                      struct fuse_file_info *file_info) | ||||
|                                      struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| @@ -262,7 +262,7 @@ protected: | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto truncate_impl(std::string api_path, off_t size, | ||||
|                                    struct fuse_file_info *file_info) | ||||
|                                    struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] auto truncate_impl(std::string api_path, off_t size) | ||||
| @@ -274,7 +274,7 @@ protected: | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto utimens_impl(std::string api_path, | ||||
|                                   const struct timespec tv[2], | ||||
|                                   struct fuse_file_info *file_info) | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] auto utimens_impl(std::string api_path, | ||||
| @@ -284,7 +284,7 @@ protected: | ||||
|  | ||||
|   [[nodiscard]] auto write_impl(std::string api_path, const char *buffer, | ||||
|                                 size_t write_size, off_t write_offset, | ||||
|                                 struct fuse_file_info *file_info, | ||||
|                                 struct fuse_file_info *f_info, | ||||
|                                 std::size_t &bytes_written) | ||||
|       -> api_error override; | ||||
|  | ||||
|   | ||||
| @@ -121,7 +121,7 @@ protected: | ||||
|   static void populate_stat(const std::string &api_path, | ||||
|                             std::uint64_t size_or_count, | ||||
|                             const api_meta_map &meta, bool directory, | ||||
|                             i_provider &provider, struct stat *st); | ||||
|                             i_provider &provider, struct stat *u_stat); | ||||
|  | ||||
|   static void set_timespec_from_meta(const api_meta_map &meta, | ||||
|                                      const std::string &name, | ||||
|   | ||||
| @@ -65,7 +65,7 @@ public: | ||||
|                    &handle) override ;*/ | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   fuse_fgetattr(const char *path, remote::stat &st, bool &directory, | ||||
|   fuse_fgetattr(const char *path, remote::stat &r_stat, bool &directory, | ||||
|                 const remote::file_handle &handle) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
| @@ -83,7 +83,7 @@ public: | ||||
|                                     const remote::file_handle &handle) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto fuse_getattr(const char *path, remote::stat &st, | ||||
|   [[nodiscard]] auto fuse_getattr(const char *path, remote::stat &r_stat, | ||||
|                                   bool &directory) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
| @@ -176,11 +176,11 @@ public: | ||||
|   std::int32_t &flags, std::uint32_t position) override ;*/ | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   fuse_statfs(const char *path, std::uint64_t frsize, remote::statfs &st) | ||||
|   fuse_statfs(const char *path, std::uint64_t frsize, remote::statfs &r_stat) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize, | ||||
|                                    remote::statfs_x &st) | ||||
|                                    remote::statfs_x &r_stat) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto fuse_truncate(const char *path, | ||||
|   | ||||
| @@ -25,7 +25,6 @@ | ||||
|  | ||||
| #include "drives/fuse/fuse_base.hpp" | ||||
| #include "drives/fuse/remotefuse/i_remote_instance.hpp" | ||||
| #include "events/event_system.hpp" | ||||
|  | ||||
| namespace repertory { | ||||
| class app_config; | ||||
| @@ -40,6 +39,11 @@ public: | ||||
|   remote_fuse_drive(app_config &config, remote_instance_factory factory, | ||||
|                     lock_data &lock) | ||||
|       : fuse_base(config), factory_(std::move(factory)), lock_data_(lock) {} | ||||
|   remote_fuse_drive(const remote_fuse_drive &) = delete; | ||||
|   remote_fuse_drive(remote_fuse_drive &&) = delete; | ||||
|  | ||||
|   auto operator=(const remote_fuse_drive &) -> remote_fuse_drive & = delete; | ||||
|   auto operator=(remote_fuse_drive &&) -> remote_fuse_drive & = delete; | ||||
|  | ||||
|   ~remote_fuse_drive() override = default; | ||||
|  | ||||
| @@ -54,95 +58,97 @@ private: | ||||
|  | ||||
| private: | ||||
|   static void populate_stat(const remote::stat &r_stat, bool directory, | ||||
|                             struct stat &unix_st); | ||||
|                             struct stat &u_stat); | ||||
|  | ||||
| protected: | ||||
|   [[nodiscard]] auto access_impl(std::string api_path, | ||||
|                                  int mask) -> api_error override; | ||||
|   [[nodiscard]] auto access_impl(std::string api_path, int mask) | ||||
|       -> api_error override; | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
|   [[nodiscard]] auto chflags_impl(std::string api_path, | ||||
|                                   uint32_t flags) -> api_error override; | ||||
|   [[nodiscard]] auto chflags_impl(std::string api_path, uint32_t flags) | ||||
|       -> api_error override; | ||||
| #endif // __APPLE__ | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto | ||||
|   chmod_impl(std::string api_path, mode_t mode, | ||||
|              struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, | ||||
|                                 struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else | ||||
|   [[nodiscard]] auto chmod_impl(std::string api_path, | ||||
|                                 mode_t mode) -> api_error override; | ||||
|   [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) | ||||
|       -> api_error override; | ||||
| #endif | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto | ||||
|   chown_impl(std::string api_path, uid_t uid, gid_t gid, | ||||
|              struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, | ||||
|                                 struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else | ||||
|   [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, | ||||
|                                 gid_t gid) -> api_error override; | ||||
|   [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) | ||||
|       -> api_error override; | ||||
| #endif | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   create_impl(std::string api_path, mode_t mode, | ||||
|               struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto create_impl(std::string api_path, mode_t mode, | ||||
|                                  struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   void destroy_impl(void * /*ptr*/) override; | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   fgetattr_impl(std::string api_path, struct stat *unix_st, | ||||
|                 struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *u_stat, | ||||
|                                    struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
|   [[nodiscard]] auto | ||||
|   fsetattr_x_impl(std::string api_path, struct setattr_x *attr, | ||||
|                   struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto fsetattr_x_impl(std::string api_path, | ||||
|                                      struct setattr_x *attr, | ||||
|                                      struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #endif // __APPLE__ | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   fsync_impl(std::string api_path, int datasync, | ||||
|              struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto fsync_impl(std::string api_path, int datasync, | ||||
|                                 struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
| #if FUSE_USE_VERSION < 30 | ||||
|   [[nodiscard]] auto | ||||
|   ftruncate_impl(std::string api_path, off_t size, | ||||
|                  struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, | ||||
|                                     struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #endif | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto | ||||
|   getattr_impl(std::string api_path, struct stat *unix_st, | ||||
|                struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat, | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else | ||||
|   [[nodiscard]] auto getattr_impl(std::string api_path, | ||||
|                                   struct stat *unix_st) -> api_error override; | ||||
|   [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat) | ||||
|       -> api_error override; | ||||
| #endif | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
|   [[nodiscard]] auto | ||||
|   getxtimes_impl(std::string api_path, struct timespec *bkuptime, | ||||
|                  struct timespec *crtime) -> api_error override; | ||||
|   [[nodiscard]] auto getxtimes_impl(std::string api_path, | ||||
|                                     struct timespec *bkuptime, | ||||
|                                     struct timespec *crtime) | ||||
|       -> api_error override; | ||||
| #endif // __APPLE__ | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   auto init_impl(struct fuse_conn_info *conn, | ||||
|                  struct fuse_config *cfg) -> void * override; | ||||
|   auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) | ||||
|       -> void * override; | ||||
| #else | ||||
|   auto init_impl(struct fuse_conn_info *conn) -> void * override; | ||||
| #endif | ||||
|  | ||||
|   [[nodiscard]] auto mkdir_impl(std::string api_path, | ||||
|                                 mode_t mode) -> api_error override; | ||||
|   [[nodiscard]] auto mkdir_impl(std::string api_path, mode_t mode) | ||||
|       -> api_error override; | ||||
|  | ||||
|   void notify_fuse_main_exit(int &ret) override; | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   open_impl(std::string api_path, | ||||
|             struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto open_impl(std::string api_path, | ||||
|                                struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   opendir_impl(std::string api_path, | ||||
|                struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto opendir_impl(std::string api_path, | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto read_impl(std::string api_path, char *buffer, | ||||
|                                size_t read_size, off_t read_offset, | ||||
| @@ -150,29 +156,30 @@ protected: | ||||
|                                std::size_t &bytes_read) -> api_error override; | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto | ||||
|   readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, | ||||
|                off_t offset, struct fuse_file_info *f_info, | ||||
|                fuse_readdir_flags flags) -> api_error override; | ||||
|   [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, | ||||
|                                   fuse_fill_dir_t fuse_fill_dir, off_t offset, | ||||
|                                   struct fuse_file_info *f_info, | ||||
|                                   fuse_readdir_flags flags) | ||||
|       -> api_error override; | ||||
| #else | ||||
|   [[nodiscard]] auto | ||||
|   readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, | ||||
|                off_t offset, | ||||
|                struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto readdir_impl(std::string api_path, void *buf, | ||||
|                                   fuse_fill_dir_t fuse_fill_dir, off_t offset, | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #endif | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   release_impl(std::string api_path, | ||||
|                struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto release_impl(std::string api_path, | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   releasedir_impl(std::string api_path, | ||||
|                   struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto releasedir_impl(std::string api_path, | ||||
|                                      struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto rename_impl(std::string from_api_path, | ||||
|                                  std::string to_api_path, | ||||
|                                  unsigned int flags) -> api_error override; | ||||
|                                  std::string to_api_path, unsigned int flags) | ||||
|       -> api_error override; | ||||
| #else | ||||
|   [[nodiscard]] auto rename_impl(std::string from_api_path, | ||||
|                                  std::string to_api_path) -> api_error override; | ||||
| @@ -181,58 +188,60 @@ protected: | ||||
|   [[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override; | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
|   [[nodiscard]] auto | ||||
|   setattr_x_impl(std::string api_path, | ||||
|                  struct setattr_x *attr) -> api_error override; | ||||
|   [[nodiscard]] auto setattr_x_impl(std::string api_path, | ||||
|                                     struct setattr_x *attr) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   setbkuptime_impl(std::string api_path, | ||||
|                    const struct timespec *bkuptime) -> api_error override; | ||||
|   [[nodiscard]] auto setbkuptime_impl(std::string api_path, | ||||
|                                       const struct timespec *bkuptime) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   setchgtime_impl(std::string api_path, | ||||
|                   const struct timespec *chgtime) -> api_error override; | ||||
|   [[nodiscard]] auto setchgtime_impl(std::string api_path, | ||||
|                                      const struct timespec *chgtime) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   setcrtime_impl(std::string api_path, | ||||
|                  const struct timespec *crtime) -> api_error override; | ||||
|   [[nodiscard]] auto setcrtime_impl(std::string api_path, | ||||
|                                     const struct timespec *crtime) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   setvolname_impl(const char *volname) -> api_error override; | ||||
|   [[nodiscard]] virtual auto setvolname_impl(const char *volname) | ||||
|       -> api_error override; | ||||
|  | ||||
|   [[nodiscard]] auto statfs_x_impl(std::string api_path, | ||||
|                                    struct statfs *stbuf) -> api_error override; | ||||
|   [[nodiscard]] auto statfs_x_impl(std::string api_path, struct statfs *stbuf) | ||||
|       -> api_error override; | ||||
|  | ||||
| #else  // __APPLE__ | ||||
|   [[nodiscard]] auto statfs_impl(std::string api_path, | ||||
|                                  struct statvfs *stbuf) -> api_error override; | ||||
|   [[nodiscard]] auto statfs_impl(std::string api_path, struct statvfs *stbuf) | ||||
|       -> api_error override; | ||||
| #endif // __APPLE__ | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto | ||||
|   truncate_impl(std::string api_path, off_t size, | ||||
|                 struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto truncate_impl(std::string api_path, off_t size, | ||||
|                                    struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else | ||||
|   [[nodiscard]] auto truncate_impl(std::string api_path, | ||||
|                                    off_t size) -> api_error override; | ||||
|   [[nodiscard]] auto truncate_impl(std::string api_path, off_t size) | ||||
|       -> api_error override; | ||||
| #endif | ||||
|  | ||||
|   [[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override; | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   [[nodiscard]] auto | ||||
|   utimens_impl(std::string api_path, const struct timespec tv[2], | ||||
|                struct fuse_file_info *f_info) -> api_error override; | ||||
|   [[nodiscard]] auto utimens_impl(std::string api_path, | ||||
|                                   const struct timespec tv[2], | ||||
|                                   struct fuse_file_info *f_info) | ||||
|       -> api_error override; | ||||
| #else | ||||
|   [[nodiscard]] auto | ||||
|   utimens_impl(std::string api_path, | ||||
|                const struct timespec tv[2]) -> api_error override; | ||||
|   [[nodiscard]] auto utimens_impl(std::string api_path, | ||||
|                                   const struct timespec tv[2]) | ||||
|       -> api_error override; | ||||
| #endif | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
|   write_impl(std::string api_path, const char *buffer, size_t write_size, | ||||
|              off_t write_offset, struct fuse_file_info *f_info, | ||||
|              std::size_t &bytes_written) -> api_error override; | ||||
|   [[nodiscard]] auto write_impl(std::string api_path, const char *buffer, | ||||
|                                 size_t write_size, off_t write_offset, | ||||
|                                 struct fuse_file_info *f_info, | ||||
|                                 std::size_t &bytes_written) | ||||
|       -> api_error override; | ||||
| }; | ||||
| } // namespace remote_fuse | ||||
| } // namespace repertory | ||||
|   | ||||
| @@ -50,14 +50,13 @@ private: | ||||
|   [[nodiscard]] auto get_next_handle() -> std::uint64_t; | ||||
|  | ||||
|   [[nodiscard]] auto populate_file_info(const std::string &api_path, | ||||
|                                         remote::file_info &file_info) | ||||
|                                         remote::file_info &r_info) | ||||
|       -> packet::error_type; | ||||
|  | ||||
|   void populate_file_info(const std::string &api_path, const UINT64 &file_size, | ||||
|                           const UINT32 &attributes, | ||||
|                           remote::file_info &file_info); | ||||
|                           const UINT32 &attributes, remote::file_info &r_info); | ||||
|  | ||||
|   static void populate_stat(const struct stat64 &unix_st, remote::stat &r_stat); | ||||
|   static void populate_stat(const struct stat64 &u_stat, remote::stat &r_stat); | ||||
|  | ||||
|   [[nodiscard]] auto update_to_windows_format(const std::string &root_api_path, | ||||
|                                               json &item) -> json &; | ||||
| @@ -264,14 +263,14 @@ public: | ||||
|   [[nodiscard]] auto | ||||
|   winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, | ||||
|                 UINT32 attributes, UINT64 /*allocation_size*/, PVOID *file_desc, | ||||
|                 remote::file_info *file_info, std::string &normalized_name, | ||||
|                 remote::file_info *r_info, std::string &normalized_name, | ||||
|                 BOOLEAN &exists) -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
|   [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, | ||||
|                                           remote::file_info *file_info) | ||||
|                                           remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto | ||||
| @@ -290,14 +289,14 @@ public: | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|                                  UINT32 granted_access, PVOID *file_desc, | ||||
|                                  remote::file_info *file_info, | ||||
|                                  remote::file_info *r_info, | ||||
|                                  std::string &normalized_name) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|                                       BOOLEAN replace_attributes, | ||||
|                                       UINT64 /*allocation_size*/, | ||||
|                                       remote::file_info *file_info) | ||||
|                                       remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
| @@ -316,11 +315,11 @@ public: | ||||
|   [[nodiscard]] auto winfsp_set_basic_info( | ||||
|       PVOID file_desc, UINT32 attributes, UINT64 creation_time, | ||||
|       UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, | ||||
|       remote::file_info *file_info) -> packet::error_type override; | ||||
|       remote::file_info *r_info) -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|                                           BOOLEAN set_allocation_size, | ||||
|                                           remote::file_info *file_info) | ||||
|                                           remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_unmounted(const std::wstring &location) | ||||
| @@ -329,7 +328,7 @@ public: | ||||
|   [[nodiscard]] auto | ||||
|   winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, | ||||
|                BOOLEAN write_to_end, BOOLEAN constrained_io, | ||||
|                PUINT32 bytes_transferred, remote::file_info *file_info) | ||||
|                PUINT32 bytes_transferred, remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
| }; | ||||
| } // namespace remote_fuse | ||||
|   | ||||
| @@ -660,13 +660,13 @@ private: | ||||
|     remote::group_id gid{}; | ||||
|     DECODE_OR_RETURN(request, gid); | ||||
|  | ||||
|     remote::stat st{}; | ||||
|     remote::stat r_stat{}; | ||||
|     bool directory = false; | ||||
|     ret = this->fuse_fgetattr(path.data(), st, directory, handle); | ||||
|     ret = this->fuse_fgetattr(path.data(), r_stat, directory, handle); | ||||
|     if (ret == 0) { | ||||
|       st.st_uid = uid; | ||||
|       st.st_gid = gid; | ||||
|       response.encode(st); | ||||
|       r_stat.st_uid = uid; | ||||
|       r_stat.st_gid = gid; | ||||
|       response.encode(r_stat); | ||||
|       response.encode(static_cast<std::uint8_t>(directory)); | ||||
|     } | ||||
|  | ||||
| @@ -733,13 +733,13 @@ private: | ||||
|     remote::group_id gid; | ||||
|     DECODE_OR_RETURN(request, gid); | ||||
|  | ||||
|     remote::stat st{}; | ||||
|     remote::stat r_stat{}; | ||||
|     bool directory = false; | ||||
|     ret = this->fuse_getattr(path.c_str(), st, directory); | ||||
|     ret = this->fuse_getattr(path.c_str(), r_stat, directory); | ||||
|     if (ret == 0) { | ||||
|       st.st_uid = uid; | ||||
|       st.st_gid = gid; | ||||
|       response.encode(st); | ||||
|       r_stat.st_uid = uid; | ||||
|       r_stat.st_gid = gid; | ||||
|       response.encode(r_stat); | ||||
|       response.encode(static_cast<std::uint8_t>(directory)); | ||||
|     } | ||||
|     return ret; | ||||
| @@ -997,10 +997,10 @@ private: | ||||
|     std::uint64_t frsize{}; | ||||
|     DECODE_OR_RETURN(request, frsize); | ||||
|  | ||||
|     remote::statfs st{}; | ||||
|     ret = this->fuse_statfs(path.data(), frsize, st); | ||||
|     remote::statfs r_stat{}; | ||||
|     ret = this->fuse_statfs(path.data(), frsize, r_stat); | ||||
|     if (ret == 0) { | ||||
|       response.encode(st); | ||||
|       response.encode(r_stat); | ||||
|     } | ||||
|  | ||||
|     return ret; | ||||
| @@ -1016,10 +1016,10 @@ private: | ||||
|     std::uint64_t bsize{}; | ||||
|     DECODE_OR_RETURN(request, bsize); | ||||
|  | ||||
|     remote::statfs_x st{}; | ||||
|     ret = this->fuse_statfs_x(path.data(), bsize, st); | ||||
|     remote::statfs_x r_stat{}; | ||||
|     ret = this->fuse_statfs_x(path.data(), bsize, r_stat); | ||||
|     if (ret == 0) { | ||||
|       response.encode(st); | ||||
|       response.encode(r_stat); | ||||
|     } | ||||
|     return ret; | ||||
|   } | ||||
| @@ -1261,12 +1261,12 @@ private: | ||||
|     DECODE_OR_RETURN(request, allocation_size); | ||||
|  | ||||
|     BOOLEAN exists{0}; | ||||
|     remote::file_info file_info{}; | ||||
|     remote::file_info r_info{}; | ||||
|     std::string normalized_name; | ||||
|     PVOID file_desc{}; | ||||
|     ret = this->winfsp_create(file_name.data(), create_options, granted_access, | ||||
|                               attributes, allocation_size, &file_desc, | ||||
|                               &file_info, normalized_name, exists); | ||||
|                               attributes, allocation_size, &file_desc, &r_info, | ||||
|                               normalized_name, exists); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       if (exists == 0U) { | ||||
| #if defined(_WIN32) | ||||
| @@ -1279,7 +1279,7 @@ private: | ||||
|       } | ||||
|  | ||||
|       response.encode(file_desc); | ||||
|       response.encode(file_info); | ||||
|       response.encode(r_info); | ||||
|       response.encode(normalized_name); | ||||
|       response.encode(exists); | ||||
|     } | ||||
| @@ -1294,10 +1294,10 @@ private: | ||||
|     HANDLE file_desc{}; | ||||
|     DECODE_OR_RETURN(request, file_desc); | ||||
|  | ||||
|     remote::file_info file_info{}; | ||||
|     ret = this->winfsp_flush(file_desc, &file_info); | ||||
|     remote::file_info r_info{}; | ||||
|     ret = this->winfsp_flush(file_desc, &r_info); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       response.encode(file_info); | ||||
|       response.encode(r_info); | ||||
|     } | ||||
|  | ||||
|     return ret; | ||||
| @@ -1311,10 +1311,10 @@ private: | ||||
|     HANDLE file_desc{}; | ||||
|     DECODE_OR_RETURN(request, file_desc); | ||||
|  | ||||
|     remote::file_info file_info{}; | ||||
|     ret = this->winfsp_get_file_info(file_desc, &file_info); | ||||
|     remote::file_info r_info{}; | ||||
|     ret = this->winfsp_get_file_info(file_desc, &r_info); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       response.encode(file_info); | ||||
|       response.encode(r_info); | ||||
|     } | ||||
|     return ret; | ||||
|   } | ||||
| @@ -1394,11 +1394,11 @@ private: | ||||
|     UINT32 granted_access{}; | ||||
|     DECODE_OR_RETURN(request, granted_access); | ||||
|  | ||||
|     remote::file_info file_info{}; | ||||
|     remote::file_info r_info{}; | ||||
|     std::string normalized_name; | ||||
|     PVOID file_desc{}; | ||||
|     ret = this->winfsp_open(file_name.data(), create_options, granted_access, | ||||
|                             &file_desc, &file_info, normalized_name); | ||||
|                             &file_desc, &r_info, normalized_name); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
| #if defined(_WIN32) | ||||
|       this->set_client_id(file_desc, client_id); | ||||
| @@ -1408,7 +1408,7 @@ private: | ||||
|                           client_id); | ||||
| #endif // defined(_WIN32) | ||||
|       response.encode(file_desc); | ||||
|       response.encode(file_info); | ||||
|       response.encode(r_info); | ||||
|       response.encode(normalized_name); | ||||
|     } | ||||
|  | ||||
| @@ -1431,11 +1431,11 @@ private: | ||||
|     UINT64 allocation_size{}; | ||||
|     DECODE_OR_RETURN(request, allocation_size); | ||||
|  | ||||
|     remote::file_info file_info{}; | ||||
|     remote::file_info r_info{}; | ||||
|     ret = this->winfsp_overwrite(file_desc, attributes, replace_attributes, | ||||
|                                  allocation_size, &file_info); | ||||
|                                  allocation_size, &r_info); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       response.encode(file_info); | ||||
|       response.encode(r_info); | ||||
|     } | ||||
|     return ret; | ||||
|   } | ||||
| @@ -1536,12 +1536,12 @@ private: | ||||
|     UINT64 change_time{}; | ||||
|     DECODE_OR_RETURN(request, change_time); | ||||
|  | ||||
|     remote::file_info file_info{}; | ||||
|     remote::file_info r_info{}; | ||||
|     ret = this->winfsp_set_basic_info(file_desc, attributes, creation_time, | ||||
|                                       last_access_time, last_write_time, | ||||
|                                       change_time, &file_info); | ||||
|                                       change_time, &r_info); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       response.encode(file_info); | ||||
|       response.encode(r_info); | ||||
|     } | ||||
|     return ret; | ||||
|   } | ||||
| @@ -1560,11 +1560,11 @@ private: | ||||
|     BOOLEAN set_allocation_size{}; | ||||
|     DECODE_OR_RETURN(request, set_allocation_size); | ||||
|  | ||||
|     remote::file_info file_info{}; | ||||
|     remote::file_info r_info{}; | ||||
|     ret = this->winfsp_set_file_size(file_desc, new_size, set_allocation_size, | ||||
|                                      &file_info); | ||||
|                                      &r_info); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       response.encode(file_info); | ||||
|       response.encode(r_info); | ||||
|     } | ||||
|     return ret; | ||||
|   } | ||||
| @@ -1601,12 +1601,12 @@ private: | ||||
|     auto *buffer = request->current_pointer(); | ||||
|  | ||||
|     UINT32 bytes_transferred{0U}; | ||||
|     remote::file_info file_info{}; | ||||
|     remote::file_info r_info{}; | ||||
|     ret = this->winfsp_write(file_desc, buffer, offset, length, write_to_end, | ||||
|                              constrained_io, &bytes_transferred, &file_info); | ||||
|                              constrained_io, &bytes_transferred, &r_info); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       response.encode(bytes_transferred); | ||||
|       response.encode(file_info); | ||||
|       response.encode(r_info); | ||||
|     } | ||||
|     return ret; | ||||
|   } | ||||
|   | ||||
| @@ -66,7 +66,7 @@ public: | ||||
|                                std::string &volume_label) const = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto populate_file_info(const std::string &api_path, | ||||
|                                                 remote::file_info &fi) const | ||||
|                                                 remote::file_info &r_info) const | ||||
|       -> api_error = 0; | ||||
| }; | ||||
| } // namespace repertory | ||||
|   | ||||
| @@ -42,19 +42,19 @@ public: | ||||
|   [[nodiscard]] virtual auto | ||||
|   winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, | ||||
|                 UINT32 file_attributes, UINT64 allocation_size, | ||||
|                 PVOID *file_desc, remote::file_info *file_info, | ||||
|                 PVOID *file_desc, remote::file_info *r_info, | ||||
|                 std::string &normalized_name, BOOLEAN &exists) | ||||
|       -> packet::error_type = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto winfsp_flush(PVOID file_desc, | ||||
|                                           remote::file_info *file_info) | ||||
|                                           remote::file_info *r_info) | ||||
|       -> packet::error_type = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) | ||||
|       -> packet::error_type = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto winfsp_get_file_info(PVOID file_desc, | ||||
|                                                   remote::file_info *file_info) | ||||
|                                                   remote::file_info *r_info) | ||||
|       -> packet::error_type = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
| @@ -73,13 +73,13 @@ public: | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, | ||||
|               PVOID *file_desc, remote::file_info *file_info, | ||||
|               PVOID *file_desc, remote::file_info *r_info, | ||||
|               std::string &normalized_name) -> packet::error_type = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto | ||||
|   winfsp_overwrite(PVOID file_desc, UINT32 file_attributes, | ||||
|                    BOOLEAN replace_file_attributes, UINT64 allocation_size, | ||||
|                    remote::file_info *file_info) -> packet::error_type = 0; | ||||
|                    remote::file_info *r_info) -> packet::error_type = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto winfsp_read(PVOID file_desc, PVOID buffer, | ||||
|                                          UINT64 offset, UINT32 length, | ||||
| @@ -100,12 +100,11 @@ public: | ||||
|   winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes, | ||||
|                         UINT64 creation_time, UINT64 last_access_time, | ||||
|                         UINT64 last_write_time, UINT64 change_time, | ||||
|                         remote::file_info *file_info) -> packet::error_type = 0; | ||||
|                         remote::file_info *r_info) -> packet::error_type = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto winfsp_set_file_size(PVOID file_desc, | ||||
|                                                   UINT64 new_size, | ||||
|                                                   BOOLEAN set_allocation_size, | ||||
|                                                   remote::file_info *file_info) | ||||
|   [[nodiscard]] virtual auto | ||||
|   winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|                        BOOLEAN set_allocation_size, remote::file_info *r_info) | ||||
|       -> packet::error_type = 0; | ||||
|  | ||||
|   [[nodiscard]] virtual auto winfsp_unmounted(const std::wstring &location) | ||||
| @@ -114,7 +113,7 @@ public: | ||||
|   [[nodiscard]] virtual auto | ||||
|   winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, | ||||
|                BOOLEAN write_to_end, BOOLEAN constrained_io, | ||||
|                PUINT32 bytes_transferred, remote::file_info *file_info) | ||||
|                PUINT32 bytes_transferred, remote::file_info *r_info) | ||||
|       -> packet::error_type = 0; | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -76,17 +76,17 @@ public: | ||||
|   [[nodiscard]] auto | ||||
|   winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, | ||||
|                 UINT32 attributes, UINT64 allocation_size, PVOID *file_desc, | ||||
|                 remote::file_info *file_info, std::string &normalized_name, | ||||
|                 remote::file_info *r_info, std::string &normalized_name, | ||||
|                 BOOLEAN &exists) -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
|   [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, | ||||
|                                           remote::file_info *file_info) | ||||
|                                           remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_get_security_by_name( | ||||
| @@ -103,14 +103,14 @@ public: | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|                                  UINT32 granted_access, PVOID *file_desc, | ||||
|                                  remote::file_info *file_info, | ||||
|                                  remote::file_info *r_info, | ||||
|                                  std::string &normalized_name) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|                                       BOOLEAN replace_attributes, | ||||
|                                       UINT64 allocation_size, | ||||
|                                       remote::file_info *file_info) | ||||
|                                       remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
| @@ -129,11 +129,11 @@ public: | ||||
|   [[nodiscard]] auto winfsp_set_basic_info( | ||||
|       PVOID file_desc, UINT32 attributes, UINT64 creation_time, | ||||
|       UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, | ||||
|       remote::file_info *file_info) -> packet::error_type override; | ||||
|       remote::file_info *r_info) -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|                                           BOOLEAN set_allocation_size, | ||||
|                                           remote::file_info *file_info) | ||||
|                                           remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_unmounted(const std::wstring &location) | ||||
| @@ -142,7 +142,7 @@ public: | ||||
|   [[nodiscard]] auto | ||||
|   winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, | ||||
|                BOOLEAN write_to_end, BOOLEAN constrained_io, | ||||
|                PUINT32 bytes_transferred, remote::file_info *file_info) | ||||
|                PUINT32 bytes_transferred, remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
| }; | ||||
| } // namespace remote_winfsp | ||||
|   | ||||
| @@ -50,11 +50,11 @@ private: | ||||
|   [[nodiscard]] auto get_next_handle() -> std::uint64_t; | ||||
|  | ||||
|   [[nodiscard]] auto populate_file_info(const std::string &api_path, | ||||
|                                         remote::file_info &file_info) | ||||
|                                         remote::file_info &r_info) | ||||
|       -> packet::error_type; | ||||
|  | ||||
|   void populate_stat(const char *path, bool directory, remote::stat &r_stat, | ||||
|                      const struct _stat64 &unix_st); | ||||
|                      const struct _stat64 &u_stat); | ||||
|  | ||||
| public: | ||||
|   // FUSE Layer | ||||
| @@ -249,17 +249,17 @@ public: | ||||
|   [[nodiscard]] auto | ||||
|   winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, | ||||
|                 UINT32 attributes, UINT64 allocation_size, PVOID *file_desc, | ||||
|                 remote::file_info *file_info, std::string &normalized_name, | ||||
|                 remote::file_info *r_info, std::string &normalized_name, | ||||
|                 BOOLEAN &exists) -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
|   [[nodiscard]] auto winfsp_flush(PVOID file_desc, remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, | ||||
|                                           remote::file_info *file_info) | ||||
|                                           remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_get_security_by_name( | ||||
| @@ -276,14 +276,14 @@ public: | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|                                  UINT32 granted_access, PVOID *file_desc, | ||||
|                                  remote::file_info *file_info, | ||||
|                                  remote::file_info *r_info, | ||||
|                                  std::string &normalized_name) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|                                       BOOLEAN replace_attributes, | ||||
|                                       UINT64 allocation_size, | ||||
|                                       remote::file_info *file_info) | ||||
|                                       remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
| @@ -302,11 +302,11 @@ public: | ||||
|   [[nodiscard]] auto winfsp_set_basic_info( | ||||
|       PVOID file_desc, UINT32 attributes, UINT64 creation_time, | ||||
|       UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, | ||||
|       remote::file_info *file_info) -> packet::error_type override; | ||||
|       remote::file_info *r_info) -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|                                           BOOLEAN set_allocation_size, | ||||
|                                           remote::file_info *file_info) | ||||
|                                           remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
|  | ||||
|   [[nodiscard]] auto winfsp_unmounted(const std::wstring &location) | ||||
| @@ -315,7 +315,7 @@ public: | ||||
|   [[nodiscard]] auto | ||||
|   winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, | ||||
|                BOOLEAN write_to_end, BOOLEAN constrained_io, | ||||
|                PUINT32 bytes_transferred, remote::file_info *file_info) | ||||
|                PUINT32 bytes_transferred, remote::file_info *r_info) | ||||
|       -> packet::error_type override; | ||||
| }; | ||||
| } // namespace remote_winfsp | ||||
|   | ||||
| @@ -70,9 +70,9 @@ private: | ||||
|   std::string mount_location_; | ||||
|  | ||||
| private: | ||||
|   void populate_file_info(const json &item, FSP_FSCTL_FILE_INFO &file_info); | ||||
|   void populate_file_info(const json &item, FSP_FSCTL_FILE_INFO &f_info); | ||||
|  | ||||
|   static void set_file_info(FileInfo &dest, const remote::file_info &src); | ||||
|   static void set_file_info(FileInfo &f_info, const remote::file_info &r_info); | ||||
|  | ||||
| public: | ||||
|   auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name) | ||||
| @@ -88,10 +88,10 @@ public: | ||||
|               UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, | ||||
|               OpenFileInfo *ofi) -> NTSTATUS override; | ||||
|  | ||||
|   auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info) | ||||
|   auto Flush(PVOID file_node, PVOID file_desc, FileInfo *f_info) | ||||
|       -> NTSTATUS override; | ||||
|  | ||||
|   auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info) | ||||
|   auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *f_info) | ||||
|       -> NTSTATUS override; | ||||
|  | ||||
|   auto GetSecurityByName(PWSTR file_name, PUINT32 attributes, | ||||
| @@ -112,7 +112,7 @@ public: | ||||
|  | ||||
|   auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, | ||||
|                  BOOLEAN replace_attributes, UINT64 allocation_size, | ||||
|                  FileInfo *file_info) -> NTSTATUS override; | ||||
|                  FileInfo *f_info) -> NTSTATUS override; | ||||
|  | ||||
|   auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|             ULONG length, PULONG bytes_transferred) -> NTSTATUS override; | ||||
| @@ -128,18 +128,17 @@ public: | ||||
|   auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, | ||||
|                     UINT64 creation_time, UINT64 last_access_time, | ||||
|                     UINT64 last_write_time, UINT64 change_time, | ||||
|                     FileInfo *file_info) -> NTSTATUS override; | ||||
|                     FileInfo *f_info) -> NTSTATUS override; | ||||
|  | ||||
|   auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size, | ||||
|                    BOOLEAN set_allocation_size, FileInfo *file_info) | ||||
|                    BOOLEAN set_allocation_size, FileInfo *f_info) | ||||
|       -> NTSTATUS override; | ||||
|  | ||||
|   VOID Unmounted(PVOID host) override; | ||||
|  | ||||
|   auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|              ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, | ||||
|              PULONG bytes_transferred, FileInfo *file_info) | ||||
|       -> NTSTATUS override; | ||||
|              PULONG bytes_transferred, FileInfo *f_info) -> NTSTATUS override; | ||||
|  | ||||
|   void shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); } | ||||
|  | ||||
|   | ||||
| @@ -78,7 +78,7 @@ private: | ||||
| private: | ||||
|   [[nodiscard]] auto handle_error(std::string_view function_name, | ||||
|                                   const std::string &api_path, api_error error, | ||||
|                                   FileInfo *file_info, std::uint64_t file_size, | ||||
|                                   FileInfo *f_info, std::uint64_t file_size, | ||||
|                                   bool raise_on_failure_only = false) const | ||||
|       -> NTSTATUS; | ||||
|  | ||||
| @@ -92,8 +92,8 @@ private: | ||||
|   void populate_file_info(std::uint64_t file_size, api_meta_map meta, | ||||
|                           FSP_FSCTL_FILE_INFO &fi) const; | ||||
|  | ||||
|   static void set_file_info(remote::file_info &dest, | ||||
|                             const FSP_FSCTL_FILE_INFO &src); | ||||
|   static void set_file_info(remote::file_info &r_info, | ||||
|                             const FSP_FSCTL_FILE_INFO &f_info); | ||||
|  | ||||
|   void stop_all(); | ||||
|  | ||||
| @@ -111,7 +111,7 @@ public: | ||||
|               UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, | ||||
|               OpenFileInfo *ofi) -> NTSTATUS override; | ||||
|  | ||||
|   auto Flush(PVOID file_node, PVOID file_desc, FileInfo *file_info) | ||||
|   auto Flush(PVOID file_node, PVOID file_desc, FileInfo *f_info) | ||||
|       -> NTSTATUS override; | ||||
|  | ||||
|   [[nodiscard]] auto get_directory_item_count(const std::string &api_path) const | ||||
| @@ -120,7 +120,7 @@ public: | ||||
|   [[nodiscard]] auto get_directory_items(const std::string &api_path) const | ||||
|       -> directory_item_list override; | ||||
|  | ||||
|   auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *file_info) | ||||
|   auto GetFileInfo(PVOID file_node, PVOID file_desc, FileInfo *f_info) | ||||
|       -> NTSTATUS override; | ||||
|  | ||||
|   [[nodiscard]] auto get_file_size(const std::string &api_path) const | ||||
| @@ -167,10 +167,10 @@ public: | ||||
|  | ||||
|   auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, | ||||
|                  BOOLEAN replace_attributes, UINT64 allocation_size, | ||||
|                  FileInfo *file_info) -> NTSTATUS override; | ||||
|                  FileInfo *f_info) -> NTSTATUS override; | ||||
|  | ||||
|   [[nodiscard]] auto populate_file_info(const std::string &api_path, | ||||
|                                         remote::file_info &file_info) const | ||||
|                                         remote::f_info &r_info) const | ||||
|       -> api_error override; | ||||
|  | ||||
|   auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
| @@ -187,18 +187,17 @@ public: | ||||
|   auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, | ||||
|                     UINT64 creation_time, UINT64 last_access_time, | ||||
|                     UINT64 last_write_time, UINT64 change_time, | ||||
|                     FileInfo *file_info) -> NTSTATUS override; | ||||
|                     FileInfo *f_info) -> NTSTATUS override; | ||||
|  | ||||
|   auto SetFileSize(PVOID file_node, PVOID file_desc, UINT64 new_size, | ||||
|                    BOOLEAN set_allocation_size, FileInfo *file_info) | ||||
|                    BOOLEAN set_allocation_size, FileInfo *f_info) | ||||
|       -> NTSTATUS override; | ||||
|  | ||||
|   VOID Unmounted(PVOID host) override; | ||||
|  | ||||
|   auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|              ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, | ||||
|              PULONG bytes_transferred, FileInfo *file_info) | ||||
|       -> NTSTATUS override; | ||||
|              PULONG bytes_transferred, FileInfo *f_info) -> NTSTATUS override; | ||||
|  | ||||
|   void shutdown(); | ||||
|  | ||||
|   | ||||
| @@ -120,13 +120,13 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int { | ||||
| #endif // defined(__APPLE__) | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi) | ||||
|     -> int { | ||||
| auto fuse_base::chmod_(const char *path, mode_t mode, | ||||
|                        struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().chmod_impl(std::move(api_path), mode, fi); | ||||
|         return instance().chmod_impl(std::move(api_path), mode, f_info); | ||||
|       }); | ||||
| } | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
| @@ -142,12 +142,12 @@ auto fuse_base::chmod_(const char *path, mode_t mode) -> int { | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_base::chown_(const char *path, uid_t uid, gid_t gid, | ||||
|                        struct fuse_file_info *fi) -> int { | ||||
|                        struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().chown_impl(std::move(api_path), uid, gid, fi); | ||||
|         return instance().chown_impl(std::move(api_path), uid, gid, f_info); | ||||
|       }); | ||||
| } | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
| @@ -162,12 +162,12 @@ auto fuse_base::chown_(const char *path, uid_t uid, gid_t gid) -> int { | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
| auto fuse_base::create_(const char *path, mode_t mode, | ||||
|                         struct fuse_file_info *fi) -> int { | ||||
|                         struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().create_impl(std::move(api_path), mode, fi); | ||||
|         return instance().create_impl(std::move(api_path), mode, f_info); | ||||
|       }); | ||||
| } | ||||
|  | ||||
| @@ -178,7 +178,7 @@ void fuse_base::destroy_(void *ptr) { | ||||
| } | ||||
|  | ||||
| void fuse_base::destroy_impl(void * /* ptr */) { | ||||
|   if (not console_enabled_) { | ||||
|   if (not foreground_) { | ||||
|     repertory::project_cleanup(); | ||||
|   } | ||||
| } | ||||
| @@ -222,8 +222,8 @@ auto fuse_base::execute_callback( | ||||
|     std::string_view function_name, const char *path, | ||||
|     const std::function<api_error(std::string api_path)> &cb, | ||||
|     bool disable_logging) -> int { | ||||
|   const auto api_path = utils::path::create_api_path(path ? path : ""); | ||||
|   const auto res = utils::from_api_error(cb(api_path)); | ||||
|   auto api_path = utils::path::create_api_path(path ? path : ""); | ||||
|   auto res = utils::from_api_error(cb(api_path)); | ||||
|   raise_fuse_event(function_name, api_path, res, disable_logging); | ||||
|   return res; | ||||
| } | ||||
| @@ -246,79 +246,79 @@ auto fuse_base::execute_void_pointer_callback(std::string_view function_name, | ||||
| } | ||||
|  | ||||
| auto fuse_base::fallocate_(const char *path, int mode, off_t offset, | ||||
|                            off_t length, struct fuse_file_info *fi) -> int { | ||||
|                            off_t length, struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().fallocate_impl(std::move(api_path), mode, offset, | ||||
|                                          length, fi); | ||||
|                                          length, f_info); | ||||
|       }); | ||||
| } | ||||
|  | ||||
| #if FUSE_USE_VERSION < 30 | ||||
| auto fuse_base::fgetattr_(const char *path, struct stat *st, | ||||
|                           struct fuse_file_info *fi) -> int { | ||||
| auto fuse_base::fgetattr_(const char *path, struct stat *u_stat, | ||||
|                           struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().fgetattr_impl(std::move(api_path), st, fi); | ||||
|         return instance().fgetattr_impl(std::move(api_path), u_stat, f_info); | ||||
|       }); | ||||
| } | ||||
| #endif // FUSE_USE_VERSION < 30 | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
| auto fuse_base::fsetattr_x_(const char *path, struct setattr_x *attr, | ||||
|                             struct fuse_file_info *fi) -> int { | ||||
|                             struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().fsetattr_x_impl(std::move(api_path), attr, fi); | ||||
|         return instance().fsetattr_x_impl(std::move(api_path), attr, f_info); | ||||
|       }); | ||||
| } | ||||
| #endif // defined(__APPLE__) | ||||
|  | ||||
| auto fuse_base::fsync_(const char *path, int datasync, | ||||
|                        struct fuse_file_info *fi) -> int { | ||||
|                        struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().fsync_impl(std::move(api_path), datasync, fi); | ||||
|         return instance().fsync_impl(std::move(api_path), datasync, f_info); | ||||
|       }); | ||||
| } | ||||
|  | ||||
| #if FUSE_USE_VERSION < 30 | ||||
| auto fuse_base::ftruncate_(const char *path, off_t size, | ||||
|                            struct fuse_file_info *fi) -> int { | ||||
|                            struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().ftruncate_impl(std::move(api_path), size, fi); | ||||
|         return instance().ftruncate_impl(std::move(api_path), size, f_info); | ||||
|       }); | ||||
| } | ||||
| #endif // FUSE_USE_VERSION < 30 | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_base::getattr_(const char *path, struct stat *st, | ||||
|                          struct fuse_file_info *fi) -> int { | ||||
| auto fuse_base::getattr_(const char *path, struct stat *u_stat, | ||||
|                          struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().getattr_impl(std::move(api_path), st, fi); | ||||
|         return instance().getattr_impl(std::move(api_path), u_stat, f_info); | ||||
|       }); | ||||
| } | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
| auto fuse_base::getattr_(const char *path, struct stat *st) -> int { | ||||
| auto fuse_base::getattr_(const char *path, struct stat *u_stat) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().getattr_impl(std::move(api_path), st); | ||||
|         return instance().getattr_impl(std::move(api_path), u_stat); | ||||
|       }); | ||||
| } | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
| @@ -378,7 +378,7 @@ auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * { | ||||
|     return this; | ||||
|   } | ||||
|  | ||||
|   if (not console_enabled_ && not repertory::project_initialize()) { | ||||
|   if (not foreground_ && not repertory::project_initialize()) { | ||||
|     utils::error::raise_error(function_name, "failed to initialize repertory"); | ||||
|     event_system::instance().raise<unmount_requested>(function_name); | ||||
|     repertory::project_cleanup(); | ||||
| @@ -397,81 +397,90 @@ auto fuse_base::mkdir_(const char *path, mode_t mode) -> int { | ||||
| } | ||||
|  | ||||
| auto fuse_base::mount(std::vector<std::string> args) -> int { | ||||
|   auto ret = parse_args(args); | ||||
|   if (ret == 0) { | ||||
|     std::vector<const char *> fuse_argv(args.size()); | ||||
|     for (std::size_t i = 0u; i < args.size(); ++i) { | ||||
|       fuse_argv[i] = args[i].c_str(); | ||||
|     } | ||||
|   auto res = parse_args(args); | ||||
|   if (res != 0) { | ||||
|     return res; | ||||
|   } | ||||
|  | ||||
|     { | ||||
|       struct fuse_args fa = FUSE_ARGS_INIT( | ||||
|           static_cast<int>(fuse_argv.size()), | ||||
|           reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data()))); | ||||
|   if (not foreground_ && not utils::collection::includes(args, "-f")) { | ||||
|     args.emplace_back("-f"); | ||||
|   } | ||||
|  | ||||
|       char *mount_location{nullptr}; | ||||
|   std::vector<const char *> fuse_argv(args.size()); | ||||
|   for (std::size_t idx{0U}; idx < args.size(); ++idx) { | ||||
|     fuse_argv[idx] = args[idx].c_str(); | ||||
|   } | ||||
|  | ||||
|   { | ||||
|     struct fuse_args f_args = FUSE_ARGS_INIT( | ||||
|         static_cast<int>(fuse_argv.size()), | ||||
|         reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data()))); | ||||
|  | ||||
|     char *mount_location{nullptr}; | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|       struct fuse_cmdline_opts opts{}; | ||||
|       fuse_parse_cmdline(&fa, &opts); | ||||
|       mount_location = opts.mountpoint; | ||||
|     struct fuse_cmdline_opts opts{}; | ||||
|     fuse_parse_cmdline(&f_args, &opts); | ||||
|     mount_location = opts.mountpoint; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|       fuse_parse_cmdline(&fa, &mount_location, nullptr, nullptr); | ||||
|     fuse_parse_cmdline(&f_args, &mount_location, nullptr, nullptr); | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
|       if (mount_location) { | ||||
|         mount_location_ = mount_location; | ||||
|         free(mount_location); | ||||
|       } | ||||
|     if (mount_location != nullptr) { | ||||
|       mount_location_ = mount_location; | ||||
|       free(mount_location); | ||||
|       mount_location = nullptr; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     notify_fuse_args_parsed(args); | ||||
|   notify_fuse_args_parsed(args); | ||||
|  | ||||
| #if FUSE_USE_VERSION < 30 | ||||
|     umask(0); | ||||
| #endif // FUSE_USE_VERSION < 30 | ||||
|  | ||||
|     if (not console_enabled_) { | ||||
|       repertory::project_cleanup(); | ||||
|     } | ||||
|  | ||||
|     ret = fuse_main( | ||||
|   const auto main_func = [&]() -> int { | ||||
|     auto ret = fuse_main( | ||||
|         static_cast<int>(fuse_argv.size()), | ||||
|         reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())), | ||||
|         &fuse_ops_, this); | ||||
|     notify_fuse_main_exit(ret); | ||||
|     return ret; | ||||
|   }; | ||||
|  | ||||
|   if (foreground_) { | ||||
|     return main_func(); | ||||
|   } | ||||
|  | ||||
|   return ret; | ||||
|   repertory::project_cleanup(); | ||||
|   exit(utils::create_daemon(main_func)); | ||||
|   return 0; | ||||
| } | ||||
|  | ||||
| auto fuse_base::open_(const char *path, struct fuse_file_info *fi) -> int { | ||||
| auto fuse_base::open_(const char *path, struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().open_impl(std::move(api_path), fi); | ||||
|         return instance().open_impl(std::move(api_path), f_info); | ||||
|       }); | ||||
| } | ||||
|  | ||||
| auto fuse_base::opendir_(const char *path, struct fuse_file_info *fi) -> int { | ||||
| auto fuse_base::opendir_(const char *path, struct fuse_file_info *f_info) | ||||
|     -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().opendir_impl(std::move(api_path), fi); | ||||
|         return instance().opendir_impl(std::move(api_path), f_info); | ||||
|       }); | ||||
| } | ||||
|  | ||||
| auto fuse_base::read_(const char *path, char *buffer, size_t read_size, | ||||
|                       off_t read_offset, struct fuse_file_info *fi) -> int { | ||||
|                       off_t read_offset, struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   std::size_t bytes_read{}; | ||||
|   const auto res = instance().execute_callback( | ||||
|   auto res = instance().execute_callback( | ||||
|       function_name, path, | ||||
|       [&](std::string api_path) -> api_error { | ||||
|         return instance().read_impl(std::move(api_path), buffer, read_size, | ||||
|                                     read_offset, fi, bytes_read); | ||||
|                                     read_offset, f_info, bytes_read); | ||||
|       }, | ||||
|       true); | ||||
|   return (res == 0) ? static_cast<int>(bytes_read) : res; | ||||
| @@ -480,46 +489,47 @@ auto fuse_base::read_(const char *path, char *buffer, size_t read_size, | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_base::readdir_(const char *path, void *buf, | ||||
|                          fuse_fill_dir_t fuse_fill_dir, off_t offset, | ||||
|                          struct fuse_file_info *fi, fuse_readdir_flags flags) | ||||
|     -> int { | ||||
|                          struct fuse_file_info *f_info, | ||||
|                          fuse_readdir_flags flags) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().readdir_impl(std::move(api_path), buf, fuse_fill_dir, | ||||
|                                        offset, fi, flags); | ||||
|                                        offset, f_info, flags); | ||||
|       }); | ||||
| } | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
| auto fuse_base::readdir_(const char *path, void *buf, | ||||
|                          fuse_fill_dir_t fuse_fill_dir, off_t offset, | ||||
|                          struct fuse_file_info *fi) -> int { | ||||
|                          struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().readdir_impl(std::move(api_path), buf, fuse_fill_dir, | ||||
|                                        offset, fi); | ||||
|                                        offset, f_info); | ||||
|       }); | ||||
| } | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
| auto fuse_base::release_(const char *path, struct fuse_file_info *fi) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().release_impl(std::move(api_path), fi); | ||||
|       }); | ||||
| } | ||||
|  | ||||
| auto fuse_base::releasedir_(const char *path, struct fuse_file_info *fi) | ||||
| auto fuse_base::release_(const char *path, struct fuse_file_info *f_info) | ||||
|     -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().releasedir_impl(std::move(api_path), fi); | ||||
|         return instance().release_impl(std::move(api_path), f_info); | ||||
|       }); | ||||
| } | ||||
|  | ||||
| auto fuse_base::releasedir_(const char *path, struct fuse_file_info *f_info) | ||||
|     -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().releasedir_impl(std::move(api_path), f_info); | ||||
|       }); | ||||
| } | ||||
|  | ||||
| @@ -564,7 +574,7 @@ auto fuse_base::getxattr_(const char *path, const char *name, char *value, | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   int attribute_size = 0; | ||||
|   const auto res = instance().execute_callback( | ||||
|   auto res = instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().getxattr_impl(std::move(api_path), name, value, size, | ||||
|                                         position, attribute_size); | ||||
| @@ -578,7 +588,7 @@ auto fuse_base::getxattr_(const char *path, const char *name, char *value, | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   int attribute_size = 0; | ||||
|   const auto res = instance().execute_callback( | ||||
|   auto res = instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().getxattr_impl(std::move(api_path), name, value, size, | ||||
|                                         attribute_size); | ||||
| @@ -594,7 +604,7 @@ auto fuse_base::listxattr_(const char *path, char *buffer, size_t size) -> int { | ||||
|   int required_size = 0; | ||||
|   bool return_size = false; | ||||
|  | ||||
|   const auto res = instance().execute_callback( | ||||
|   auto res = instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().listxattr_impl(std::move(api_path), buffer, size, | ||||
|                                          required_size, return_size); | ||||
| @@ -618,69 +628,70 @@ void fuse_base::notify_fuse_args_parsed(const std::vector<std::string> &args) { | ||||
| } | ||||
|  | ||||
| auto fuse_base::parse_args(std::vector<std::string> &args) -> int { | ||||
|   auto force_no_console = false; | ||||
|   for (std::size_t i = 1u; !force_no_console && (i < args.size()); ++i) { | ||||
|     if (args[i] == "-nc") { | ||||
|   auto force_no_console{false}; | ||||
|   for (std::size_t idx{1U}; !force_no_console && (idx < args.size()); ++idx) { | ||||
|     if (args[idx] == "-nc") { | ||||
|       force_no_console = true; | ||||
|       console_enabled_ = false; | ||||
|     } | ||||
|   } | ||||
|   utils::collection::remove_element(args, "-nc"); | ||||
|  | ||||
|   for (std::size_t i = 1u; i < args.size(); ++i) { | ||||
|     if (args[i] == "-f") { | ||||
|       console_enabled_ = not force_no_console; | ||||
|     } else if (args[i].find("-o") == 0) { | ||||
|       std::string options = ""; | ||||
|       if (args[i].size() == 2u) { | ||||
|         if ((i + 1) < args.size()) { | ||||
|           options = args[++i]; | ||||
|   for (std::size_t idx{1U}; idx < args.size(); ++idx) { | ||||
|     if (args[idx] == "-f") { | ||||
|       foreground_ = true; | ||||
|     } else if (args[idx].starts_with("-o")) { | ||||
|       std::string options; | ||||
|       if (args[idx].size() == 2U) { | ||||
|         if ((idx + 1) < args.size()) { | ||||
|           options = args[++idx]; | ||||
|         } | ||||
|       } else { | ||||
|         options = args[i].substr(2); | ||||
|         options = args[idx].substr(2); | ||||
|       } | ||||
|  | ||||
|       const auto option_parts = utils::string::split(options, ',', true); | ||||
|       auto option_parts = utils::string::split(options, ',', true); | ||||
|       for (const auto &option : option_parts) { | ||||
|         if (option.find("gid") == 0) { | ||||
|           const auto parts = utils::string::split(option, '=', true); | ||||
|           if (parts.size() == 2u) { | ||||
|             auto gid = getgrnam(parts[1].c_str()); | ||||
|             if (not gid) { | ||||
|               gid = getgrgid(utils::string::to_uint32(parts[1])); | ||||
|         if (option.starts_with("gid")) { | ||||
|           auto parts = utils::string::split(option, '=', true); | ||||
|           if (parts.size() == 2U) { | ||||
|             auto *gid = getgrnam(parts[1U].c_str()); | ||||
|             if (gid == nullptr) { | ||||
|               gid = getgrgid(utils::string::to_uint32(parts[1U])); | ||||
|             } | ||||
|             if ((getgid() != 0) && (gid->gr_gid == 0)) { | ||||
|               std::cerr << "'gid=0' requires running as root" << std::endl; | ||||
|               return -1; | ||||
|             } else { | ||||
|               forced_gid_ = gid->gr_gid; | ||||
|             } | ||||
|  | ||||
|             forced_gid_ = gid->gr_gid; | ||||
|           } | ||||
|         } else if (option.find("noatime") == 0) { | ||||
|         } else if (option.starts_with("noatime")) { | ||||
|           atime_enabled_ = false; | ||||
|         } else if (option.find("uid") == 0) { | ||||
|           const auto parts = utils::string::split(option, '=', true); | ||||
|           if (parts.size() == 2u) { | ||||
|             auto *uid = getpwnam(parts[1u].c_str()); | ||||
|             if (not uid) { | ||||
|         } else if (option.starts_with("uid")) { | ||||
|           auto parts = utils::string::split(option, '=', true); | ||||
|           if (parts.size() == 2U) { | ||||
|             auto *uid = getpwnam(parts[1U].c_str()); | ||||
|             if (uid == nullptr) { | ||||
|               uid = getpwuid(utils::string::to_uint32(parts[1])); | ||||
|             } | ||||
|             if ((getuid() != 0) && (uid->pw_uid == 0)) { | ||||
|               std::cerr << "'uid=0' requires running as root" << std::endl; | ||||
|               return -1; | ||||
|             } else { | ||||
|               forced_uid_ = uid->pw_uid; | ||||
|             } | ||||
|  | ||||
|             forced_uid_ = uid->pw_uid; | ||||
|           } | ||||
|         } else if (option.find("umask") == 0) { | ||||
|           const auto parts = utils::string::split(option, '=', true); | ||||
|           if (parts.size() == 2u) { | ||||
|         } else if (option.starts_with("umask")) { | ||||
|           auto parts = utils::string::split(option, '=', true); | ||||
|           if (parts.size() == 2U) { | ||||
|             static const auto match_number_regex = std::regex("[0-9]+"); | ||||
|             try { | ||||
|               if (not std::regex_match(parts[1], match_number_regex)) { | ||||
|                 throw std::runtime_error("invalid syntax"); | ||||
|               } else { | ||||
|                 forced_umask_ = utils::string::to_uint32(parts[1]); | ||||
|               } | ||||
|  | ||||
|               forced_umask_ = utils::string::to_uint32(parts[1]); | ||||
|             } catch (...) { | ||||
|               std::cerr << ("'" + option + "' invalid syntax") << std::endl; | ||||
|               return -1; | ||||
| @@ -727,7 +738,7 @@ auto fuse_base::setxattr_(const char *path, const char *name, const char *value, | ||||
|                           size_t size, int flags, uint32_t position) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   const auto res = instance().execute_callback( | ||||
|   auto res = instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().setxattr_impl(std::move(api_path), name, value, size, | ||||
|                                         flags, position); | ||||
| @@ -743,7 +754,7 @@ auto fuse_base::setxattr_(const char *path, const char *name, const char *value, | ||||
|                           size_t size, int flags) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   const auto res = instance().execute_callback( | ||||
|   auto res = instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().setxattr_impl(std::move(api_path), name, value, size, | ||||
|                                         flags); | ||||
| @@ -835,12 +846,12 @@ auto fuse_base::statfs_(const char *path, struct statvfs *stbuf) -> int { | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_base::truncate_(const char *path, off_t size, | ||||
|                           struct fuse_file_info *fi) -> int { | ||||
|                           struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().truncate_impl(std::move(api_path), size, fi); | ||||
|         return instance().truncate_impl(std::move(api_path), size, f_info); | ||||
|       }); | ||||
| } | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
| @@ -865,12 +876,12 @@ auto fuse_base::unlink_(const char *path) -> int { | ||||
|  | ||||
| auto fuse_base::unmount(const std::string &mount_location) -> int { | ||||
| #if defined(__APPLE__) | ||||
|   const auto cmd = "umount \"" + mount_location + "\" >/dev/null 2>&1"; | ||||
|   auto cmd = "umount \"" + mount_location + "\" >/dev/null 2>&1"; | ||||
| #else // !defined(__APPLE__) | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|   const auto cmd = "fusermount3 -u \"" + mount_location + "\" >/dev/null 2>&1"; | ||||
|   auto cmd = "fusermount3 -u \"" + mount_location + "\" >/dev/null 2>&1"; | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|   const auto cmd = "fusermount -u \"" + mount_location + "\" >/dev/null 2>&1"; | ||||
|   auto cmd = "fusermount -u \"" + mount_location + "\" >/dev/null 2>&1"; | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
| #endif // defined(__APPLE__) | ||||
|  | ||||
| @@ -879,12 +890,12 @@ auto fuse_base::unmount(const std::string &mount_location) -> int { | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_base::utimens_(const char *path, const struct timespec tv[2], | ||||
|                          struct fuse_file_info *fi) -> int { | ||||
|                          struct fuse_file_info *f_info) -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   return instance().execute_callback( | ||||
|       function_name, path, [&](std::string api_path) -> api_error { | ||||
|         return instance().utimens_impl(std::move(api_path), tv, fi); | ||||
|         return instance().utimens_impl(std::move(api_path), tv, f_info); | ||||
|       }); | ||||
| } | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
| @@ -899,16 +910,17 @@ auto fuse_base::utimens_(const char *path, const struct timespec tv[2]) -> int { | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|  | ||||
| auto fuse_base::write_(const char *path, const char *buffer, size_t write_size, | ||||
|                        off_t write_offset, struct fuse_file_info *fi) -> int { | ||||
|                        off_t write_offset, struct fuse_file_info *f_info) | ||||
|     -> int { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   std::size_t bytes_written{}; | ||||
|  | ||||
|   const auto res = instance().execute_callback( | ||||
|   auto res = instance().execute_callback( | ||||
|       function_name, path, | ||||
|       [&](std::string api_path) -> api_error { | ||||
|         return instance().write_impl(std::move(api_path), buffer, write_size, | ||||
|                                      write_offset, fi, bytes_written); | ||||
|                                      write_offset, f_info, bytes_written); | ||||
|       }, | ||||
|       true); | ||||
|   return (res == 0) ? static_cast<int>(bytes_written) : res; | ||||
|   | ||||
| @@ -55,7 +55,8 @@ fuse_drive::fuse_drive(app_config &config, lock_data &lock_data, | ||||
|     : fuse_drive_base(config), lock_data_(lock_data), provider_(provider) {} | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
| api_error fuse_drive::chflags_impl(std::string api_path, uint32_t flags) { | ||||
| auto fuse_drive::chflags_impl(std::string api_path, uint32_t flags) | ||||
|     -> api_error { | ||||
|   return check_and_perform(api_path, X_OK, [&](api_meta_map &) -> api_error { | ||||
|     return provider_.set_item_meta(api_path, META_OSXFLAGS, | ||||
|                                    std::to_string(flags)); | ||||
| @@ -65,8 +66,7 @@ api_error fuse_drive::chflags_impl(std::string api_path, uint32_t flags) { | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_drive::chmod_impl(std::string api_path, mode_t mode, | ||||
|                             struct fuse_file_info * /*file_info*/) | ||||
|     -> api_error { | ||||
|                             struct fuse_file_info * /*f_info*/) -> api_error { | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
| auto fuse_drive::chmod_impl(std::string api_path, mode_t mode) -> api_error { | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
| @@ -82,8 +82,7 @@ auto fuse_drive::chmod_impl(std::string api_path, mode_t mode) -> api_error { | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid, | ||||
|                             struct fuse_file_info * /*file_info*/) | ||||
|     -> api_error { | ||||
|                             struct fuse_file_info * /*f_info*/) -> api_error { | ||||
| #else | ||||
| auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) | ||||
|     -> api_error { | ||||
| @@ -125,16 +124,16 @@ auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) | ||||
| } | ||||
|  | ||||
| auto fuse_drive::create_impl(std::string api_path, mode_t mode, | ||||
|                              struct fuse_file_info *file_info) -> api_error { | ||||
|   file_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE); | ||||
|                              struct fuse_file_info *f_info) -> api_error { | ||||
|   f_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE); | ||||
|  | ||||
|   auto is_append_op = ((file_info->flags & O_APPEND) == O_APPEND); | ||||
|   auto is_create_op = ((file_info->flags & O_CREAT) == O_CREAT); | ||||
|   auto is_directory_op = ((file_info->flags & O_DIRECTORY) == O_DIRECTORY); | ||||
|   auto is_exclusive = ((file_info->flags & O_EXCL) == O_EXCL); | ||||
|   auto is_read_write_op = ((file_info->flags & O_RDWR) == O_RDWR); | ||||
|   auto is_truncate_op = ((file_info->flags & O_TRUNC) == O_TRUNC); | ||||
|   auto is_write_only_op = ((file_info->flags & O_WRONLY) == O_WRONLY); | ||||
|   auto is_append_op = ((f_info->flags & O_APPEND) == O_APPEND); | ||||
|   auto is_create_op = ((f_info->flags & O_CREAT) == O_CREAT); | ||||
|   auto is_directory_op = ((f_info->flags & O_DIRECTORY) == O_DIRECTORY); | ||||
|   auto is_exclusive = ((f_info->flags & O_EXCL) == O_EXCL); | ||||
|   auto is_read_write_op = ((f_info->flags & O_RDWR) == O_RDWR); | ||||
|   auto is_truncate_op = ((f_info->flags & O_TRUNC) == O_TRUNC); | ||||
|   auto is_write_only_op = ((f_info->flags & O_WRONLY) == O_WRONLY); | ||||
|  | ||||
|   if (is_create_op && is_append_op && is_truncate_op) { | ||||
|     return api_error::invalid_operation; | ||||
| @@ -214,7 +213,7 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode, | ||||
|     if (is_create_op) { | ||||
|       auto now = utils::time::get_time_now(); | ||||
| #if defined(__APPLE__) | ||||
|       auto osx_flags = static_cast<std::uint32_t>(file_info->flags); | ||||
|       auto osx_flags = static_cast<std::uint32_t>(f_info->flags); | ||||
| #else  // !defined(__APPLE__) | ||||
|       auto osx_flags = 0U; | ||||
| #endif // defined(__APPLE__) | ||||
| @@ -226,12 +225,12 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode, | ||||
|                                {utils::create_uuid_string()}), | ||||
|           get_effective_uid(), now); | ||||
|  | ||||
|       res = fm_->create(api_path, meta, file_info->flags, handle, open_file); | ||||
|       res = fm_->create(api_path, meta, f_info->flags, handle, open_file); | ||||
|       if ((res != api_error::item_exists) && (res != api_error::success)) { | ||||
|         return res; | ||||
|       } | ||||
|     } else { | ||||
|       res = fm_->open(api_path, is_directory_op, file_info->flags, handle, | ||||
|       res = fm_->open(api_path, is_directory_op, f_info->flags, handle, | ||||
|                       open_file); | ||||
|       if (res != api_error::success) { | ||||
|         return res; | ||||
| @@ -239,17 +238,17 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode, | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   file_info->fh = handle; | ||||
|   f_info->fh = handle; | ||||
|   if (is_truncate_op) { | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|     res = truncate_impl(api_path, 0, file_info); | ||||
|     res = truncate_impl(api_path, 0, f_info); | ||||
|     if (res != api_error::success) { | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|     res = ftruncate_impl(api_path, 0, file_info); | ||||
|     res = ftruncate_impl(api_path, 0, f_info); | ||||
|     if (res != api_error::success) { | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|       fm_->close(handle); | ||||
|       file_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE); | ||||
|       f_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE); | ||||
|       errno = std::abs(utils::from_api_error(res)); | ||||
|       return res; | ||||
|     } | ||||
| @@ -318,19 +317,19 @@ void fuse_drive::destroy_impl(void *ptr) { | ||||
|  | ||||
| auto fuse_drive::fallocate_impl(std::string /*api_path*/, int mode, | ||||
|                                 off_t offset, off_t length, | ||||
|                                 struct fuse_file_info *file_info) -> api_error { | ||||
|                                 struct fuse_file_info *f_info) -> api_error { | ||||
|   std::shared_ptr<i_open_file> open_file; | ||||
|   if (not fm_->get_open_file(file_info->fh, true, open_file)) { | ||||
|   if (not fm_->get_open_file(f_info->fh, true, open_file)) { | ||||
|     return api_error::invalid_handle; | ||||
|   } | ||||
|  | ||||
|   auto res = check_writeable(open_file->get_open_data(file_info->fh), | ||||
|   auto res = check_writeable(open_file->get_open_data(f_info->fh), | ||||
|                              api_error::invalid_handle); | ||||
|   if (res != api_error::success) { | ||||
|     return res; | ||||
|   } | ||||
|  | ||||
|   res = check_open_flags(open_file->get_open_data(file_info->fh), | ||||
|   res = check_open_flags(open_file->get_open_data(f_info->fh), | ||||
|                          O_WRONLY | O_APPEND, api_error::invalid_handle); | ||||
|   if (res != api_error::success) { | ||||
|     return res; | ||||
| @@ -376,10 +375,10 @@ auto fuse_drive::fallocate_impl(std::string /*api_path*/, int mode, | ||||
|       static_cast<std::uint64_t>(offset + length), allocator); | ||||
| } | ||||
|  | ||||
| auto fuse_drive::fgetattr_impl(std::string api_path, struct stat *unix_st, | ||||
|                                struct fuse_file_info *file_info) -> api_error { | ||||
| auto fuse_drive::fgetattr_impl(std::string api_path, struct stat *u_stat, | ||||
|                                struct fuse_file_info *f_info) -> api_error { | ||||
|   std::shared_ptr<i_open_file> open_file; | ||||
|   if (not fm_->get_open_file(file_info->fh, false, open_file)) { | ||||
|   if (not fm_->get_open_file(f_info->fh, false, open_file)) { | ||||
|     return api_error::invalid_handle; | ||||
|   } | ||||
|  | ||||
| @@ -390,17 +389,16 @@ auto fuse_drive::fgetattr_impl(std::string api_path, struct stat *unix_st, | ||||
|   } | ||||
|  | ||||
|   fuse_drive_base::populate_stat(api_path, open_file->get_file_size(), meta, | ||||
|                                  open_file->is_directory(), provider_, unix_st); | ||||
|                                  open_file->is_directory(), provider_, u_stat); | ||||
|  | ||||
|   return api_error::success; | ||||
| } | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
| auto fuse_drive::fsetattr_x_impl(std::string api_path, struct setattr_x *attr, | ||||
|                                  struct fuse_file_info *file_info) | ||||
|     -> api_error { | ||||
|                                  struct fuse_file_info *f_info) -> api_error { | ||||
|   std::shared_ptr<i_open_file> f; | ||||
|   if (not fm_->get_open_file(file_info->fh, false, f)) { | ||||
|   if (not fm_->get_open_file(f_info->fh, false, f)) { | ||||
|     return api_error::invalid_handle; | ||||
|   } | ||||
|  | ||||
| @@ -409,9 +407,9 @@ auto fuse_drive::fsetattr_x_impl(std::string api_path, struct setattr_x *attr, | ||||
| #endif // __APPLE__ | ||||
|  | ||||
| auto fuse_drive::fsync_impl(std::string /*api_path*/, int datasync, | ||||
|                             struct fuse_file_info *file_info) -> api_error { | ||||
|                             struct fuse_file_info *f_info) -> api_error { | ||||
|   std::shared_ptr<i_open_file> open_file; | ||||
|   if (not fm_->get_open_file(file_info->fh, false, open_file)) { | ||||
|   if (not fm_->get_open_file(f_info->fh, false, open_file)) { | ||||
|     return api_error::invalid_handle; | ||||
|   } | ||||
|  | ||||
| @@ -430,15 +428,15 @@ auto fuse_drive::fsync_impl(std::string /*api_path*/, int datasync, | ||||
| } | ||||
|  | ||||
| #if FUSE_USE_VERSION < 30 | ||||
| api_error fuse_drive::ftruncate_impl(std::string /*api_path*/, off_t size, | ||||
|                                      struct fuse_file_info *file_info) { | ||||
| auto fuse_drive::ftruncate_impl(std::string /*api_path*/, off_t size, | ||||
|                                 struct fuse_file_info *f_info) -> api_error { | ||||
|   std::shared_ptr<i_open_file> f; | ||||
|   if (not fm_->get_open_file(file_info->fh, true, f)) { | ||||
|   if (not fm_->get_open_file(f_info->fh, true, f)) { | ||||
|     return api_error::invalid_handle; | ||||
|   } | ||||
|  | ||||
|   auto res = check_writeable(f->get_open_data(file_info->fh), | ||||
|                              api_error::invalid_handle); | ||||
|   auto res = | ||||
|       check_writeable(f->get_open_data(f_info->fh), api_error::invalid_handle); | ||||
|   if (res != api_error::success) { | ||||
|     return res; | ||||
|   } | ||||
| @@ -498,11 +496,10 @@ auto fuse_drive::get_item_meta(const std::string &api_path, | ||||
| } | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st, | ||||
|                               struct fuse_file_info * /*file_info*/) | ||||
|     -> api_error { | ||||
| auto fuse_drive::getattr_impl(std::string api_path, struct stat *u_stat, | ||||
|                               struct fuse_file_info * /*f_info*/) -> api_error { | ||||
| #else | ||||
| auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) | ||||
| auto fuse_drive::getattr_impl(std::string api_path, struct stat *u_stat) | ||||
|     -> api_error { | ||||
| #endif | ||||
|   auto parent = utils::path::get_parent_api_path(api_path); | ||||
| @@ -520,7 +517,7 @@ auto fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) | ||||
|  | ||||
|   fuse_drive_base::populate_stat( | ||||
|       api_path, utils::string::to_uint64(meta[META_SIZE]), meta, | ||||
|       utils::string::to_bool(meta[META_DIRECTORY]), provider_, unix_st); | ||||
|       utils::string::to_bool(meta[META_DIRECTORY]), provider_, u_stat); | ||||
|  | ||||
|   return api_error::success; | ||||
| } | ||||
| @@ -572,7 +569,7 @@ auto fuse_drive::getxtimes_impl(std::string api_path, struct timespec *bkuptime, | ||||
| auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) | ||||
|     -> void * { | ||||
| #else | ||||
| void *fuse_drive::init_impl(struct fuse_conn_info *conn) { | ||||
| auto fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * { | ||||
| #endif | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -687,18 +684,18 @@ void fuse_drive::notify_fuse_main_exit(int &ret) { | ||||
|   console_consumer_.reset(); | ||||
| } | ||||
|  | ||||
| auto fuse_drive::open_impl(std::string api_path, | ||||
|                            struct fuse_file_info *file_info) -> api_error { | ||||
| auto fuse_drive::open_impl(std::string api_path, struct fuse_file_info *f_info) | ||||
|     -> api_error { | ||||
|  | ||||
|   file_info->flags &= (~O_CREAT); | ||||
|   return create_impl(api_path, 0, file_info); | ||||
|   f_info->flags &= (~O_CREAT); | ||||
|   return create_impl(api_path, 0, f_info); | ||||
| } | ||||
|  | ||||
| auto fuse_drive::opendir_impl(std::string api_path, | ||||
|                               struct fuse_file_info *file_info) -> api_error { | ||||
|   file_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE); | ||||
|                               struct fuse_file_info *f_info) -> api_error { | ||||
|   f_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE); | ||||
|  | ||||
|   auto mask = (O_RDONLY != (file_info->flags & O_ACCMODE) ? W_OK : R_OK) | X_OK; | ||||
|   auto mask = (O_RDONLY != (f_info->flags & O_ACCMODE) ? W_OK : R_OK) | X_OK; | ||||
|   auto res = check_access(api_path, mask); | ||||
|   if (res != api_error::success) { | ||||
|     return res; | ||||
| @@ -718,8 +715,8 @@ auto fuse_drive::opendir_impl(std::string api_path, | ||||
|     return api_error::directory_not_found; | ||||
|   } | ||||
|  | ||||
|   if ((file_info->flags & O_APPEND) == O_APPEND || | ||||
|       (file_info->flags & O_EXCL) == O_EXCL) { | ||||
|   if ((f_info->flags & O_APPEND) == O_APPEND || | ||||
|       (f_info->flags & O_EXCL) == O_EXCL) { | ||||
|     return api_error::directory_exists; | ||||
|   } | ||||
|  | ||||
| @@ -730,24 +727,24 @@ auto fuse_drive::opendir_impl(std::string api_path, | ||||
|   } | ||||
|  | ||||
|   auto iter = std::make_shared<directory_iterator>(std::move(list)); | ||||
|   file_info->fh = fm_->get_next_handle(); | ||||
|   directory_cache_->set_directory(api_path, file_info->fh, iter); | ||||
|   f_info->fh = fm_->get_next_handle(); | ||||
|   directory_cache_->set_directory(api_path, f_info->fh, iter); | ||||
|  | ||||
|   return api_error::success; | ||||
| } | ||||
|  | ||||
| auto fuse_drive::read_impl(std::string api_path, char *buffer, size_t read_size, | ||||
|                            off_t read_offset, struct fuse_file_info *file_info, | ||||
|                            off_t read_offset, struct fuse_file_info *f_info, | ||||
|                            std::size_t &bytes_read) -> api_error { | ||||
|   std::shared_ptr<i_open_file> open_file; | ||||
|   if (not fm_->get_open_file(file_info->fh, false, open_file)) { | ||||
|   if (not fm_->get_open_file(f_info->fh, false, open_file)) { | ||||
|     return api_error::item_not_found; | ||||
|   } | ||||
|   if (open_file->is_directory()) { | ||||
|     return api_error::directory_exists; | ||||
|   } | ||||
|  | ||||
|   auto res = check_readable(open_file->get_open_data(file_info->fh), | ||||
|   auto res = check_readable(open_file->get_open_data(f_info->fh), | ||||
|                             api_error::invalid_handle); | ||||
|   if (res != api_error::success) { | ||||
|     return res; | ||||
| @@ -769,19 +766,19 @@ auto fuse_drive::read_impl(std::string api_path, char *buffer, size_t read_size, | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_drive::readdir_impl(std::string api_path, void *buf, | ||||
|                               fuse_fill_dir_t fuse_fill_dir, off_t offset, | ||||
|                               struct fuse_file_info *file_info, | ||||
|                               struct fuse_file_info *f_info, | ||||
|                               fuse_readdir_flags /*flags*/) -> api_error { | ||||
| #else | ||||
| auto fuse_drive::readdir_impl(std::string api_path, void *buf, | ||||
|                               fuse_fill_dir_t fuse_fill_dir, off_t offset, | ||||
|                               struct fuse_file_info *file_info) -> api_error { | ||||
|                               struct fuse_file_info *f_info) -> api_error { | ||||
| #endif | ||||
|   auto res = check_access(api_path, X_OK); | ||||
|   if (res != api_error::success) { | ||||
|     return res; | ||||
|   } | ||||
|  | ||||
|   auto iter = directory_cache_->get_directory(file_info->fh); | ||||
|   auto iter = directory_cache_->get_directory(f_info->fh); | ||||
|   if (iter == nullptr) { | ||||
|     return api_error::invalid_handle; | ||||
|   } | ||||
| @@ -792,9 +789,9 @@ auto fuse_drive::readdir_impl(std::string api_path, void *buf, | ||||
|              static_cast<remote::file_offset>(offset++), fuse_fill_dir, buf, | ||||
|              [this](const std::string &cur_api_path, | ||||
|                     std::uint64_t cur_file_size, const api_meta_map &meta, | ||||
|                     bool directory, struct stat *unix_st) { | ||||
|                     bool directory, struct stat *u_stat) { | ||||
|                fuse_drive_base::populate_stat(cur_api_path, cur_file_size, meta, | ||||
|                                               directory, provider_, unix_st); | ||||
|                                               directory, provider_, u_stat); | ||||
|              }) == 0) | ||||
|             ? api_error::success | ||||
|             : api_error::os_error; | ||||
| @@ -809,20 +806,19 @@ auto fuse_drive::readdir_impl(std::string api_path, void *buf, | ||||
| } | ||||
|  | ||||
| auto fuse_drive::release_impl(std::string /*api_path*/, | ||||
|                               struct fuse_file_info *file_info) -> api_error { | ||||
|   fm_->close(file_info->fh); | ||||
|                               struct fuse_file_info *f_info) -> api_error { | ||||
|   fm_->close(f_info->fh); | ||||
|   return api_error::success; | ||||
| } | ||||
|  | ||||
| auto fuse_drive::releasedir_impl(std::string /*api_path*/, | ||||
|                                  struct fuse_file_info *file_info) | ||||
|     -> api_error { | ||||
|   auto iter = directory_cache_->get_directory(file_info->fh); | ||||
|                                  struct fuse_file_info *f_info) -> api_error { | ||||
|   auto iter = directory_cache_->get_directory(f_info->fh); | ||||
|   if (iter == nullptr) { | ||||
|     return api_error::invalid_handle; | ||||
|   } | ||||
|  | ||||
|   directory_cache_->remove_directory(file_info->fh); | ||||
|   directory_cache_->remove_directory(f_info->fh); | ||||
|   return api_error::success; | ||||
| } | ||||
|  | ||||
| @@ -1302,7 +1298,7 @@ auto fuse_drive::statfs_impl(std::string /*api_path*/, struct statvfs *stbuf) | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_drive::truncate_impl(std::string api_path, off_t size, | ||||
|                                struct fuse_file_info * /*file_info*/) | ||||
|                                struct fuse_file_info * /*f_info*/) | ||||
|     -> api_error { | ||||
| #else | ||||
| auto fuse_drive::truncate_impl(std::string api_path, off_t size) -> api_error { | ||||
| @@ -1362,8 +1358,7 @@ auto fuse_drive::unlink_impl(std::string api_path) -> api_error { | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2], | ||||
|                               struct fuse_file_info * /*file_info*/) | ||||
|     -> api_error { | ||||
|                               struct fuse_file_info * /*f_info*/) -> api_error { | ||||
| #else | ||||
| auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2]) | ||||
|     -> api_error { | ||||
| @@ -1409,11 +1404,10 @@ auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2]) | ||||
| auto fuse_drive::write_impl(std::string /*api_path*/ | ||||
|                             , | ||||
|                             const char *buffer, size_t write_size, | ||||
|                             off_t write_offset, | ||||
|                             struct fuse_file_info *file_info, | ||||
|                             off_t write_offset, struct fuse_file_info *f_info, | ||||
|                             std::size_t &bytes_written) -> api_error { | ||||
|   std::shared_ptr<i_open_file> open_file; | ||||
|   if (not fm_->get_open_file(file_info->fh, true, open_file)) { | ||||
|   if (not fm_->get_open_file(f_info->fh, true, open_file)) { | ||||
|     return api_error::item_not_found; | ||||
|   } | ||||
|  | ||||
| @@ -1421,14 +1415,14 @@ auto fuse_drive::write_impl(std::string /*api_path*/ | ||||
|     return api_error::directory_exists; | ||||
|   } | ||||
|  | ||||
|   auto res = check_writeable(open_file->get_open_data(file_info->fh), | ||||
|   auto res = check_writeable(open_file->get_open_data(f_info->fh), | ||||
|                              api_error::invalid_handle); | ||||
|   if (res != api_error::success) { | ||||
|     return res; | ||||
|   } | ||||
|  | ||||
|   if (write_size > 0) { | ||||
|     if ((open_file->get_open_data(file_info->fh) & O_APPEND) != 0) { | ||||
|     if ((open_file->get_open_data(f_info->fh) & O_APPEND) != 0) { | ||||
|       write_offset = static_cast<off_t>(open_file->get_file_size()); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -315,43 +315,43 @@ auto fuse_drive_base::parse_xattr_parameters(const char *name, | ||||
| void fuse_drive_base::populate_stat(const std::string &api_path, | ||||
|                                     std::uint64_t size_or_count, | ||||
|                                     const api_meta_map &meta, bool directory, | ||||
|                                     i_provider &provider, struct stat *st) { | ||||
|   std::memset(st, 0, sizeof(struct stat)); | ||||
|   st->st_nlink = static_cast<nlink_t>( | ||||
|                                     i_provider &provider, struct stat *u_stat) { | ||||
|   std::memset(u_stat, 0, sizeof(struct stat)); | ||||
|   u_stat->st_nlink = static_cast<nlink_t>( | ||||
|       directory ? 2 + (size_or_count == 0U | ||||
|                            ? provider.get_directory_item_count(api_path) | ||||
|                            : size_or_count) | ||||
|                 : 1); | ||||
|   if (directory) { | ||||
|     st->st_blocks = 0; | ||||
|     u_stat->st_blocks = 0; | ||||
|   } else { | ||||
|     st->st_size = static_cast<off_t>(size_or_count); | ||||
|     u_stat->st_size = static_cast<off_t>(size_or_count); | ||||
|     static const auto block_size_stat = static_cast<std::uint64_t>(512U); | ||||
|     static const auto block_size = static_cast<std::uint64_t>(4096U); | ||||
|     auto size = utils::divide_with_ceiling( | ||||
|                     static_cast<std::uint64_t>(st->st_size), block_size) * | ||||
|                     static_cast<std::uint64_t>(u_stat->st_size), block_size) * | ||||
|                 block_size; | ||||
|     st->st_blocks = static_cast<blkcnt_t>( | ||||
|     u_stat->st_blocks = static_cast<blkcnt_t>( | ||||
|         std::max(block_size / block_size_stat, | ||||
|                  utils::divide_with_ceiling(size, block_size_stat))); | ||||
|   } | ||||
|   st->st_gid = get_gid_from_meta(meta); | ||||
|   st->st_mode = (directory ? S_IFDIR : S_IFREG) | get_mode_from_meta(meta); | ||||
|   st->st_uid = get_uid_from_meta(meta); | ||||
|   u_stat->st_gid = get_gid_from_meta(meta); | ||||
|   u_stat->st_mode = (directory ? S_IFDIR : S_IFREG) | get_mode_from_meta(meta); | ||||
|   u_stat->st_uid = get_uid_from_meta(meta); | ||||
| #if defined(__APPLE__) | ||||
|   st->st_blksize = 0; | ||||
|   st->st_flags = get_flags_from_meta(meta); | ||||
|   u_stat->st_blksize = 0; | ||||
|   u_stat->st_flags = get_flags_from_meta(meta); | ||||
|  | ||||
|   set_timespec_from_meta(meta, META_MODIFIED, st->st_mtimespec); | ||||
|   set_timespec_from_meta(meta, META_CREATION, st->st_birthtimespec); | ||||
|   set_timespec_from_meta(meta, META_CHANGED, st->st_ctimespec); | ||||
|   set_timespec_from_meta(meta, META_ACCESSED, st->st_atimespec); | ||||
|   set_timespec_from_meta(meta, META_MODIFIED, u_stat->st_mtimespec); | ||||
|   set_timespec_from_meta(meta, META_CREATION, u_stat->st_birthtimespec); | ||||
|   set_timespec_from_meta(meta, META_CHANGED, u_stat->st_ctimespec); | ||||
|   set_timespec_from_meta(meta, META_ACCESSED, u_stat->st_atimespec); | ||||
| #else  // !defined(__APPLE__) | ||||
|   st->st_blksize = 4096; | ||||
|   u_stat->st_blksize = 4096; | ||||
|  | ||||
|   set_timespec_from_meta(meta, META_MODIFIED, st->st_mtim); | ||||
|   set_timespec_from_meta(meta, META_CREATION, st->st_ctim); | ||||
|   set_timespec_from_meta(meta, META_ACCESSED, st->st_atim); | ||||
|   set_timespec_from_meta(meta, META_MODIFIED, u_stat->st_mtim); | ||||
|   set_timespec_from_meta(meta, META_CREATION, u_stat->st_ctim); | ||||
|   set_timespec_from_meta(meta, META_ACCESSED, u_stat->st_atim); | ||||
| #endif // defined(__APPLE__) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -107,7 +107,7 @@ std::int32_t &mode, const remote::file_offset &offset, const remote::file_offset | ||||
|   return packetClient_.send(function_name, request, service_flags); | ||||
| }*/ | ||||
|  | ||||
| auto remote_client::fuse_fgetattr(const char *path, remote::stat &st, | ||||
| auto remote_client::fuse_fgetattr(const char *path, remote::stat &r_stat, | ||||
|                                   bool &directory, | ||||
|                                   const remote::file_handle &handle) | ||||
|     -> packet::error_type { | ||||
| @@ -124,7 +124,7 @@ auto remote_client::fuse_fgetattr(const char *path, remote::stat &st, | ||||
|   auto ret = | ||||
|       packet_client_.send(function_name, request, response, service_flags); | ||||
|   if (ret == 0) { | ||||
|     if ((ret = response.decode(st)) == 0) { | ||||
|     if ((ret = response.decode(r_stat)) == 0) { | ||||
|       std::uint8_t d{}; | ||||
|       if ((ret = response.decode(d)) == 0) { | ||||
|         directory = static_cast<bool>(d); | ||||
| @@ -179,7 +179,7 @@ auto remote_client::fuse_ftruncate(const char *path, | ||||
|   return packet_client_.send(function_name, request, service_flags); | ||||
| } | ||||
|  | ||||
| auto remote_client::fuse_getattr(const char *path, remote::stat &st, | ||||
| auto remote_client::fuse_getattr(const char *path, remote::stat &r_stat, | ||||
|                                  bool &directory) -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -193,7 +193,7 @@ auto remote_client::fuse_getattr(const char *path, remote::stat &st, | ||||
|   auto ret = | ||||
|       packet_client_.send(function_name, request, response, service_flags); | ||||
|   if (ret == 0) { | ||||
|     if ((ret = response.decode(st)) == 0) { | ||||
|     if ((ret = response.decode(r_stat)) == 0) { | ||||
|       std::uint8_t d = 0; | ||||
|       if ((ret = response.decode(d)) == 0) { | ||||
|         directory = static_cast<bool>(d); | ||||
| @@ -607,7 +607,7 @@ request.encode(flags); request.encode(position); | ||||
| }*/ | ||||
|  | ||||
| auto remote_client::fuse_statfs(const char *path, std::uint64_t frsize, | ||||
|                                 remote::statfs &st) -> packet::error_type { | ||||
|                                 remote::statfs &r_stat) -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   packet request; | ||||
| @@ -619,14 +619,15 @@ auto remote_client::fuse_statfs(const char *path, std::uint64_t frsize, | ||||
|   auto ret = | ||||
|       packet_client_.send(function_name, request, response, service_flags); | ||||
|   if (ret == 0) { | ||||
|     ret = response.decode(st); | ||||
|     ret = response.decode(r_stat); | ||||
|   } | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| auto remote_client::fuse_statfs_x(const char *path, std::uint64_t bsize, | ||||
|                                   remote::statfs_x &st) -> packet::error_type { | ||||
|                                   remote::statfs_x &r_stat) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   packet request; | ||||
| @@ -638,7 +639,7 @@ auto remote_client::fuse_statfs_x(const char *path, std::uint64_t bsize, | ||||
|   auto ret = | ||||
|       packet_client_.send(function_name, request, response, service_flags); | ||||
|   if (ret == 0) { | ||||
|     ret = response.decode(st); | ||||
|     ret = response.decode(r_stat); | ||||
|   } | ||||
|  | ||||
|   return ret; | ||||
|   | ||||
| @@ -19,7 +19,6 @@ | ||||
|   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|   SOFTWARE. | ||||
| */ | ||||
| #include <memory> | ||||
| #if !defined(_WIN32) | ||||
|  | ||||
| #include "drives/fuse/remotefuse/remote_fuse_drive.hpp" | ||||
| @@ -122,8 +121,7 @@ void remote_fuse_drive::destroy_impl(void *ptr) { | ||||
|   fuse_base::destroy_impl(ptr); | ||||
| } | ||||
|  | ||||
| auto remote_fuse_drive::fgetattr_impl(std::string api_path, | ||||
|                                       struct stat *unix_st, | ||||
| auto remote_fuse_drive::fgetattr_impl(std::string api_path, struct stat *u_stat, | ||||
|                                       struct fuse_file_info *f_info) | ||||
|     -> api_error { | ||||
|   remote::stat r_stat{}; | ||||
| @@ -132,7 +130,7 @@ auto remote_fuse_drive::fgetattr_impl(std::string api_path, | ||||
|   auto res = remote_instance_->fuse_fgetattr(api_path.c_str(), r_stat, | ||||
|                                              directory, f_info->fh); | ||||
|   if (res == 0) { | ||||
|     populate_stat(r_stat, directory, *unix_st); | ||||
|     populate_stat(r_stat, directory, *u_stat); | ||||
|   } | ||||
|  | ||||
|   return utils::to_api_error(res); | ||||
| @@ -182,11 +180,11 @@ auto remote_fuse_drive::ftruncate_impl(std::string api_path, off_t size, | ||||
| #endif // FUSE_USE_VERSION < 30 | ||||
|  | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
| auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st, | ||||
| auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *u_stat, | ||||
|                                      struct fuse_file_info * /*f_info*/) | ||||
|     -> api_error { | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
| auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) | ||||
| auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *u_stat) | ||||
|     -> api_error { | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
|   bool directory = false; | ||||
| @@ -195,7 +193,7 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) | ||||
|   auto res = | ||||
|       remote_instance_->fuse_getattr(api_path.c_str(), r_stat, directory); | ||||
|   if (res == 0) { | ||||
|     populate_stat(r_stat, directory, *unix_st); | ||||
|     populate_stat(r_stat, directory, *u_stat); | ||||
|   } | ||||
|  | ||||
|   return utils::to_api_error(res); | ||||
| @@ -310,54 +308,53 @@ auto remote_fuse_drive::opendir_impl(std::string api_path, | ||||
| } | ||||
|  | ||||
| void remote_fuse_drive::populate_stat(const remote::stat &r_stat, | ||||
|                                       bool directory, struct stat &unix_st) { | ||||
|   std::memset(&unix_st, 0, sizeof(struct stat)); | ||||
|   unix_st.st_blksize = | ||||
|       static_cast<decltype(unix_st.st_blksize)>(r_stat.st_blksize); | ||||
|   unix_st.st_blocks = | ||||
|       static_cast<decltype(unix_st.st_blocks)>(r_stat.st_blocks); | ||||
|   unix_st.st_gid = r_stat.st_gid; | ||||
|   unix_st.st_mode = (directory ? S_IFDIR : S_IFREG) | r_stat.st_mode; | ||||
|   unix_st.st_nlink = r_stat.st_nlink; | ||||
|   unix_st.st_size = static_cast<decltype(unix_st.st_size)>(r_stat.st_size); | ||||
|   unix_st.st_uid = r_stat.st_uid; | ||||
|                                       bool directory, struct stat &u_stat) { | ||||
|   std::memset(&u_stat, 0, sizeof(struct stat)); | ||||
|   u_stat.st_blksize = | ||||
|       static_cast<decltype(u_stat.st_blksize)>(r_stat.st_blksize); | ||||
|   u_stat.st_blocks = static_cast<decltype(u_stat.st_blocks)>(r_stat.st_blocks); | ||||
|   u_stat.st_gid = r_stat.st_gid; | ||||
|   u_stat.st_mode = (directory ? S_IFDIR : S_IFREG) | r_stat.st_mode; | ||||
|   u_stat.st_nlink = r_stat.st_nlink; | ||||
|   u_stat.st_size = static_cast<decltype(u_stat.st_size)>(r_stat.st_size); | ||||
|   u_stat.st_uid = r_stat.st_uid; | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
|   unix_st.st_atimespec.tv_nsec = | ||||
|   u_stat.st_atimespec.tv_nsec = | ||||
|       r_stat.st_atimespec % utils::time::NANOS_PER_SECOND; | ||||
|   unix_st.st_atimespec.tv_sec = | ||||
|   u_stat.st_atimespec.tv_sec = | ||||
|       r_stat.st_atimespec / utils::time::NANOS_PER_SECOND; | ||||
|  | ||||
|   unix_st.st_birthtimespec.tv_nsec = | ||||
|   u_stat.st_birthtimespec.tv_nsec = | ||||
|       r_stat.st_birthtimespec % utils::time::NANOS_PER_SECOND; | ||||
|   unix_st.st_birthtimespec.tv_sec = | ||||
|   u_stat.st_birthtimespec.tv_sec = | ||||
|       r_stat.st_birthtimespec / utils::time::NANOS_PER_SECOND; | ||||
|  | ||||
|   unix_st.st_ctimespec.tv_nsec = | ||||
|   u_stat.st_ctimespec.tv_nsec = | ||||
|       r_stat.st_ctimespec % utils::time::NANOS_PER_SECOND; | ||||
|   unix_st.st_ctimespec.tv_sec = | ||||
|   u_stat.st_ctimespec.tv_sec = | ||||
|       r_stat.st_ctimespec / utils::time::NANOS_PER_SECOND; | ||||
|  | ||||
|   unix_st.st_mtimespec.tv_nsec = | ||||
|   u_stat.st_mtimespec.tv_nsec = | ||||
|       r_stat.st_mtimespec % utils::time::NANOS_PER_SECOND; | ||||
|   unix_st.st_mtimespec.tv_sec = | ||||
|   u_stat.st_mtimespec.tv_sec = | ||||
|       r_stat.st_mtimespec / utils::time::NANOS_PER_SECOND; | ||||
|  | ||||
|   unix_st.st_flags = r_stat.st_flags; | ||||
|   u_stat.st_flags = r_stat.st_flags; | ||||
| #else  // !defined(__APPLE__) | ||||
|   unix_st.st_atim.tv_nsec = static_cast<suseconds_t>( | ||||
|   u_stat.st_atim.tv_nsec = static_cast<suseconds_t>( | ||||
|       r_stat.st_atimespec % utils::time::NANOS_PER_SECOND); | ||||
|   unix_st.st_atim.tv_sec = static_cast<suseconds_t>( | ||||
|   u_stat.st_atim.tv_sec = static_cast<suseconds_t>( | ||||
|       r_stat.st_atimespec / utils::time::NANOS_PER_SECOND); | ||||
|  | ||||
|   unix_st.st_ctim.tv_nsec = static_cast<suseconds_t>( | ||||
|   u_stat.st_ctim.tv_nsec = static_cast<suseconds_t>( | ||||
|       r_stat.st_ctimespec % utils::time::NANOS_PER_SECOND); | ||||
|   unix_st.st_ctim.tv_sec = static_cast<suseconds_t>( | ||||
|   u_stat.st_ctim.tv_sec = static_cast<suseconds_t>( | ||||
|       r_stat.st_ctimespec / utils::time::NANOS_PER_SECOND); | ||||
|  | ||||
|   unix_st.st_mtim.tv_nsec = static_cast<suseconds_t>( | ||||
|   u_stat.st_mtim.tv_nsec = static_cast<suseconds_t>( | ||||
|       r_stat.st_mtimespec % utils::time::NANOS_PER_SECOND); | ||||
|   unix_st.st_mtim.tv_sec = static_cast<suseconds_t>( | ||||
|   u_stat.st_mtim.tv_sec = static_cast<suseconds_t>( | ||||
|       r_stat.st_mtimespec / utils::time::NANOS_PER_SECOND); | ||||
| #endif // defined(__APPLE__) | ||||
| } | ||||
| @@ -404,7 +401,7 @@ auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf, | ||||
|       std::memset(p_stat.get(), 0, sizeof(struct stat)); | ||||
|       if (item_path == ".") { | ||||
| #if FUSE_USE_VERSION >= 30 | ||||
|         stat_res = getattr_impl(api_path, p_stat.get(), f_info); | ||||
|         stat_res = getattr_impl(api_path, p_stat.get()); | ||||
| #else  // FUSE_USE_VERSION < 30 | ||||
|         stat_res = getattr_impl(api_path, p_stat.get()); | ||||
| #endif // FUSE_USE_VERSION >= 30 | ||||
| @@ -538,17 +535,18 @@ api_error remote_fuse_drive::statfs_x_impl(std::string api_path, | ||||
|                                            struct statfs *stbuf) { | ||||
|   auto res = statfs(config_.get_data_directory().c_str(), stbuf); | ||||
|   if (res == 0) { | ||||
|     remote::statfs_x r{}; | ||||
|     if ((res = remote_instance_->fuse_statfs_x(api_path.c_str(), stbuf->f_bsize, | ||||
|                                                r)) == 0) { | ||||
|       stbuf->f_blocks = r.f_blocks; | ||||
|       stbuf->f_bavail = r.f_bavail; | ||||
|       stbuf->f_bfree = r.f_bfree; | ||||
|       stbuf->f_ffree = r.f_ffree; | ||||
|       stbuf->f_files = r.f_files; | ||||
|     remote::statfs_x r_stat{}; | ||||
|     res = remote_instance_->fuse_statfs_x(api_path.c_str(), stbuf->f_bsize, | ||||
|                                           r_stat); | ||||
|     if (res == 0) { | ||||
|       stbuf->f_blocks = r_stat.f_blocks; | ||||
|       stbuf->f_bavail = r_stat.f_bavail; | ||||
|       stbuf->f_bfree = r_stat.f_bfree; | ||||
|       stbuf->f_ffree = r_stat.f_ffree; | ||||
|       stbuf->f_files = r_stat.f_files; | ||||
|       stbuf->f_owner = getuid(); | ||||
|       strncpy(&stbuf->f_mntonname[0U], get_mount_location().c_str(), MNAMELEN); | ||||
|       strncpy(&stbuf->f_mntfromname[0U], &r.f_mntfromname[0U], MNAMELEN); | ||||
|       strncpy(&stbuf->f_mntfromname[0U], &r_stat.f_mntfromname[0U], MNAMELEN); | ||||
|     } | ||||
|   } else { | ||||
|     res = -errno; | ||||
|   | ||||
| @@ -80,7 +80,7 @@ auto remote_server::get_next_handle() -> std::uint64_t { | ||||
| } | ||||
|  | ||||
| auto remote_server::populate_file_info(const std::string &api_path, | ||||
|                                        remote::file_info &file_info) | ||||
|                                        remote::file_info &r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -97,7 +97,7 @@ auto remote_server::populate_file_info(const std::string &api_path, | ||||
|  | ||||
|     auto attributes = utils::string::to_uint32(meta_attributes); | ||||
|     auto file_size = directory ? 0U : drive_.get_file_size(api_path); | ||||
|     populate_file_info(api_path, file_size, attributes, file_info); | ||||
|     populate_file_info(api_path, file_size, attributes, r_info); | ||||
|     return STATUS_SUCCESS; | ||||
|   } | ||||
|  | ||||
| @@ -107,7 +107,7 @@ auto remote_server::populate_file_info(const std::string &api_path, | ||||
| void remote_server::populate_file_info(const std::string &api_path, | ||||
|                                        const UINT64 &file_size, | ||||
|                                        const UINT32 &attributes, | ||||
|                                        remote::file_info &file_info) { | ||||
|                                        remote::file_info &r_info) { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   api_meta_map meta{}; | ||||
| @@ -116,79 +116,76 @@ void remote_server::populate_file_info(const std::string &api_path, | ||||
|     utils::error::raise_api_path_error(function_name, api_path, res, | ||||
|                                        "get item meta failed"); | ||||
|   } | ||||
|   file_info.AllocationSize = | ||||
|   r_info.AllocationSize = | ||||
|       utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) * | ||||
|       WINFSP_ALLOCATION_UNIT; | ||||
|   file_info.ChangeTime = utils::time::unix_time_to_windows_time( | ||||
|   r_info.ChangeTime = utils::time::unix_time_to_windows_time( | ||||
|       utils::string::to_uint64(empty_as_zero(meta[META_MODIFIED]))); | ||||
|   file_info.CreationTime = utils::time::unix_time_to_windows_time( | ||||
|   r_info.CreationTime = utils::time::unix_time_to_windows_time( | ||||
|       utils::string::to_uint64(empty_as_zero(meta[META_CREATION]))); | ||||
|   file_info.EaSize = 0; | ||||
|   file_info.FileAttributes = attributes; | ||||
|   file_info.FileSize = file_size; | ||||
|   file_info.HardLinks = 0; | ||||
|   file_info.IndexNumber = 0; | ||||
|   file_info.LastAccessTime = utils::time::unix_time_to_windows_time( | ||||
|   r_info.EaSize = 0; | ||||
|   r_info.FileAttributes = attributes; | ||||
|   r_info.FileSize = file_size; | ||||
|   r_info.HardLinks = 0; | ||||
|   r_info.IndexNumber = 0; | ||||
|   r_info.LastAccessTime = utils::time::unix_time_to_windows_time( | ||||
|       utils::string::to_uint64(empty_as_zero(meta[META_ACCESSED]))); | ||||
|   file_info.LastWriteTime = utils::time::unix_time_to_windows_time( | ||||
|   r_info.LastWriteTime = utils::time::unix_time_to_windows_time( | ||||
|       utils::string::to_uint64(empty_as_zero(meta[META_WRITTEN]))); | ||||
|   if (meta[META_WRITTEN].empty() || (meta[META_WRITTEN] == "0") || | ||||
|       (meta[META_WRITTEN] == "116444736000000000")) { | ||||
|     drive_.set_item_meta(api_path, META_WRITTEN, meta[META_MODIFIED]); | ||||
|     file_info.LastWriteTime = file_info.ChangeTime; | ||||
|     r_info.LastWriteTime = r_info.ChangeTime; | ||||
|   } | ||||
|   file_info.ReparseTag = 0; | ||||
|   r_info.ReparseTag = 0; | ||||
| } | ||||
|  | ||||
| void remote_server::populate_stat(const struct stat64 &unix_st, | ||||
| void remote_server::populate_stat(const struct stat64 &u_stat, | ||||
|                                   remote::stat &r_stat) { | ||||
|   r_stat = {}; | ||||
|  | ||||
| #if defined(__APPLE__) | ||||
|   r_stat.st_flags = unix_st.st_flags; | ||||
|   r_stat.st_flags = u_stat.st_flags; | ||||
|  | ||||
|   r_stat.st_atimespec = | ||||
|       unix_st.st_atimespec.tv_nsec + | ||||
|       (unix_st.st_atimespec.tv_sec * utils::time::NANOS_PER_SECOND); | ||||
|       u_stat.st_atimespec.tv_nsec + | ||||
|       (u_stat.st_atimespec.tv_sec * utils::time::NANOS_PER_SECOND); | ||||
|   r_stat.st_birthtimespec = | ||||
|       unix_st.st_birthtimespec.tv_nsec + | ||||
|       (unix_st.st_birthtimespec.tv_sec * utils::time::NANOS_PER_SECOND); | ||||
|       u_stat.st_birthtimespec.tv_nsec + | ||||
|       (u_stat.st_birthtimespec.tv_sec * utils::time::NANOS_PER_SECOND); | ||||
|   r_stat.st_ctimespec = | ||||
|       unix_st.st_ctimespec.tv_nsec + | ||||
|       (unix_st.st_ctimespec.tv_sec * utils::time::NANOS_PER_SECOND); | ||||
|       u_stat.st_ctimespec.tv_nsec + | ||||
|       (u_stat.st_ctimespec.tv_sec * utils::time::NANOS_PER_SECOND); | ||||
|   r_stat.st_mtimespec = | ||||
|       unix_st.st_mtimespec.tv_nsec + | ||||
|       (unix_st.st_mtimespec.tv_sec * utils::time::NANOS_PER_SECOND); | ||||
|       u_stat.st_mtimespec.tv_nsec + | ||||
|       (u_stat.st_mtimespec.tv_sec * utils::time::NANOS_PER_SECOND); | ||||
| #else  // !defined(__APPLE__) | ||||
|   r_stat.st_flags = 0; | ||||
|  | ||||
|   r_stat.st_atimespec = | ||||
|       static_cast<remote::file_time>(unix_st.st_atim.tv_nsec) + | ||||
|       (static_cast<remote::file_time>(unix_st.st_atim.tv_sec) * | ||||
|        utils::time::NANOS_PER_SECOND); | ||||
|   r_stat.st_atimespec = static_cast<remote::file_time>(u_stat.st_atim.tv_nsec) + | ||||
|                         (static_cast<remote::file_time>(u_stat.st_atim.tv_sec) * | ||||
|                          utils::time::NANOS_PER_SECOND); | ||||
|  | ||||
|   r_stat.st_birthtimespec = | ||||
|       static_cast<remote::file_time>(unix_st.st_ctim.tv_nsec) + | ||||
|       (static_cast<remote::file_time>(unix_st.st_ctim.tv_sec) * | ||||
|       static_cast<remote::file_time>(u_stat.st_ctim.tv_nsec) + | ||||
|       (static_cast<remote::file_time>(u_stat.st_ctim.tv_sec) * | ||||
|        utils::time::NANOS_PER_SECOND); | ||||
|  | ||||
|   r_stat.st_ctimespec = | ||||
|       static_cast<remote::file_time>(unix_st.st_ctim.tv_nsec) + | ||||
|       (static_cast<remote::file_time>(unix_st.st_ctim.tv_sec) * | ||||
|        utils::time::NANOS_PER_SECOND); | ||||
|   r_stat.st_ctimespec = static_cast<remote::file_time>(u_stat.st_ctim.tv_nsec) + | ||||
|                         (static_cast<remote::file_time>(u_stat.st_ctim.tv_sec) * | ||||
|                          utils::time::NANOS_PER_SECOND); | ||||
|  | ||||
|   r_stat.st_mtimespec = | ||||
|       static_cast<remote::file_time>(unix_st.st_mtim.tv_nsec) + | ||||
|       (static_cast<remote::file_time>(unix_st.st_mtim.tv_sec) * | ||||
|        utils::time::NANOS_PER_SECOND); | ||||
|   r_stat.st_mtimespec = static_cast<remote::file_time>(u_stat.st_mtim.tv_nsec) + | ||||
|                         (static_cast<remote::file_time>(u_stat.st_mtim.tv_sec) * | ||||
|                          utils::time::NANOS_PER_SECOND); | ||||
| #endif // defined(__APPLE__) | ||||
|   r_stat.st_blksize = static_cast<remote::block_size>(unix_st.st_blksize); | ||||
|   r_stat.st_blocks = static_cast<remote::block_count>(unix_st.st_blocks); | ||||
|   r_stat.st_gid = unix_st.st_gid; | ||||
|   r_stat.st_mode = static_cast<remote::file_mode>(unix_st.st_mode); | ||||
|   r_stat.st_nlink = static_cast<remote::file_nlink>(unix_st.st_nlink); | ||||
|   r_stat.st_size = static_cast<remote::file_size>(unix_st.st_size); | ||||
|   r_stat.st_uid = unix_st.st_uid; | ||||
|   r_stat.st_blksize = static_cast<remote::block_size>(u_stat.st_blksize); | ||||
|   r_stat.st_blocks = static_cast<remote::block_count>(u_stat.st_blocks); | ||||
|   r_stat.st_gid = u_stat.st_gid; | ||||
|   r_stat.st_mode = static_cast<remote::file_mode>(u_stat.st_mode); | ||||
|   r_stat.st_nlink = static_cast<remote::file_nlink>(u_stat.st_nlink); | ||||
|   r_stat.st_size = static_cast<remote::file_size>(u_stat.st_size); | ||||
|   r_stat.st_uid = u_stat.st_uid; | ||||
| } | ||||
|  | ||||
| auto remote_server::fuse_access(const char *path, const std::int32_t &mask) | ||||
| @@ -329,10 +326,10 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, | ||||
|   auto res = has_open_info(static_cast<native_handle>(handle), EBADF); | ||||
|   if (res == 0) { | ||||
|     directory = utils::file::directory(file_path).exists(); | ||||
|     struct stat64 unix_st{}; | ||||
|     res = fstat64(static_cast<native_handle>(handle), &unix_st); | ||||
|     struct stat64 u_stat{}; | ||||
|     res = fstat64(static_cast<native_handle>(handle), &u_stat); | ||||
|     if (res == 0) { | ||||
|       populate_stat(unix_st, r_stat); | ||||
|       populate_stat(u_stat, r_stat); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -491,10 +488,10 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_stat, | ||||
|  | ||||
|   directory = utils::file::directory(file_path).exists(); | ||||
|  | ||||
|   struct stat64 unix_st{}; | ||||
|   auto res = stat64(file_path.c_str(), &unix_st); | ||||
|   struct stat64 u_stat{}; | ||||
|   auto res = stat64(file_path.c_str(), &u_stat); | ||||
|   if (res == 0) { | ||||
|     populate_stat(unix_st, r_stat); | ||||
|     populate_stat(u_stat, r_stat); | ||||
|   } | ||||
|  | ||||
|   auto ret = ((res < 0) ? -errno : 0); | ||||
| @@ -1118,7 +1115,7 @@ auto remote_server::winfsp_close(PVOID file_desc) -> packet::error_type { | ||||
| auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|                                   UINT32 granted_access, UINT32 attributes, | ||||
|                                   UINT64 /*allocation_size*/, PVOID *file_desc, | ||||
|                                   remote::file_info *file_info, | ||||
|                                   remote::file_info *r_info, | ||||
|                                   std::string &normalized_name, BOOLEAN &exists) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
| @@ -1157,15 +1154,15 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|       drive_.set_item_meta(construct_api_path(file_path), META_ATTRIBUTES, | ||||
|                            std::to_string(attributes)); | ||||
|       set_open_info(res, open_info{ | ||||
|                              "", | ||||
|                              nullptr, | ||||
|                              {}, | ||||
|                              file_path, | ||||
|                              .client_id = "", | ||||
|                              .directory_buffer = nullptr, | ||||
|                              .handles = {}, | ||||
|                              .path = file_path, | ||||
|                          }); | ||||
|  | ||||
|       auto api_path = utils::path::create_api_path(relative_path); | ||||
|       normalized_name = utils::string::replace_copy(api_path, '/', '\\'); | ||||
|       populate_file_info(api_path, 0, attributes, *file_info); | ||||
|       populate_file_info(api_path, 0, attributes, *r_info); | ||||
|     } | ||||
|  | ||||
|     ret = static_cast<packet::error_type>( | ||||
| @@ -1176,7 +1173,7 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
| auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1189,7 +1186,7 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
|                     utils::unix_error_to_windows(errno)) | ||||
|               : populate_file_info(construct_api_path(get_open_file_path( | ||||
|                                        static_cast<native_handle>(handle))), | ||||
|                                    *file_info); | ||||
|                                    *r_info); | ||||
|   } | ||||
|  | ||||
|   RAISE_REMOTE_FUSE_SERVER_EVENT( | ||||
| @@ -1199,7 +1196,7 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
| } | ||||
|  | ||||
| auto remote_server::winfsp_get_file_info(PVOID file_desc, | ||||
|                                          remote::file_info *file_info) | ||||
|                                          remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1209,7 +1206,7 @@ auto remote_server::winfsp_get_file_info(PVOID file_desc, | ||||
|   if (ret == STATUS_SUCCESS) { | ||||
|     ret = populate_file_info(construct_api_path(get_open_file_path( | ||||
|                                  static_cast<native_handle>(handle))), | ||||
|                              *file_info); | ||||
|                              *r_info); | ||||
|   } | ||||
|  | ||||
|   RAISE_REMOTE_FUSE_SERVER_EVENT( | ||||
| @@ -1229,10 +1226,10 @@ auto remote_server::winfsp_get_security_by_name( | ||||
|   if (utils::file::file(file_path).exists() || | ||||
|       (utils::file::directory(file_path).exists())) { | ||||
|     if (attributes) { | ||||
|       remote::file_info file_info{}; | ||||
|       if ((ret = populate_file_info(construct_api_path(file_path), | ||||
|                                     file_info)) == STATUS_SUCCESS) { | ||||
|         *attributes = file_info.FileAttributes; | ||||
|       remote::file_info r_info{}; | ||||
|       if ((ret = populate_file_info(construct_api_path(file_path), r_info)) == | ||||
|           STATUS_SUCCESS) { | ||||
|         *attributes = r_info.FileAttributes; | ||||
|       } | ||||
|     } | ||||
|   } else { | ||||
| @@ -1265,7 +1262,7 @@ auto remote_server::winfsp_mounted(const std::wstring &location) | ||||
|  | ||||
| auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|                                 UINT32 granted_access, PVOID *file_desc, | ||||
|                                 remote::file_info *file_info, | ||||
|                                 remote::file_info *r_info, | ||||
|                                 std::string &normalized_name) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
| @@ -1286,15 +1283,15 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|   if (res >= 0) { | ||||
|     *file_desc = reinterpret_cast<PVOID>(res); | ||||
|     set_open_info(res, open_info{ | ||||
|                            "", | ||||
|                            nullptr, | ||||
|                            {}, | ||||
|                            file_path, | ||||
|                            .client_id = "", | ||||
|                            .directory_buffer = nullptr, | ||||
|                            .handles = {}, | ||||
|                            .path = file_path, | ||||
|                        }); | ||||
|  | ||||
|     auto api_path = utils::path::create_api_path(relative_path); | ||||
|     normalized_name = utils::string::replace_copy(api_path, '/', '\\'); | ||||
|     res = populate_file_info(api_path, *file_info); | ||||
|     res = populate_file_info(api_path, *r_info); | ||||
|     if (res != STATUS_SUCCESS) { | ||||
|       utils::error::raise_error(function_name, | ||||
|                                 "populate file info failed|err|" + | ||||
| @@ -1311,7 +1308,7 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
| auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|                                      BOOLEAN replace_attributes, | ||||
|                                      UINT64 /*allocation_size*/, | ||||
|                                      remote::file_info *file_info) | ||||
|                                      remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1352,7 +1349,7 @@ auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|       } | ||||
|       ret = populate_file_info(construct_api_path(get_open_file_path( | ||||
|                                    static_cast<native_handle>(handle))), | ||||
|                                *file_info); | ||||
|                                *r_info); | ||||
|     } else { | ||||
|       ret = | ||||
|           static_cast<packet::error_type>(utils::unix_error_to_windows(errno)); | ||||
| @@ -1479,7 +1476,7 @@ auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, | ||||
| auto remote_server::winfsp_set_basic_info( | ||||
|     PVOID file_desc, UINT32 attributes, UINT64 creation_time, | ||||
|     UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, | ||||
|     remote::file_info *file_info) -> packet::error_type { | ||||
|     remote::file_info *r_info) -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   auto handle = reinterpret_cast<remote::file_handle>(file_desc); | ||||
| @@ -1533,7 +1530,7 @@ auto remote_server::winfsp_set_basic_info( | ||||
|           std::to_string(utils::time::windows_time_to_unix_time(change_time))); | ||||
|     } | ||||
|  | ||||
|     ret = populate_file_info(api_path, *file_info); | ||||
|     ret = populate_file_info(api_path, *r_info); | ||||
|   } | ||||
|  | ||||
|   RAISE_REMOTE_FUSE_SERVER_EVENT( | ||||
| @@ -1544,7 +1541,7 @@ auto remote_server::winfsp_set_basic_info( | ||||
|  | ||||
| auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|                                          BOOLEAN set_allocation_size, | ||||
|                                          remote::file_info *file_info) | ||||
|                                          remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1562,7 +1559,7 @@ auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|     if (ret == 0) { | ||||
|       ret = populate_file_info(construct_api_path(get_open_file_path( | ||||
|                                    static_cast<native_handle>(handle))), | ||||
|                                *file_info); | ||||
|                                *r_info); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -1585,7 +1582,7 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|                                  UINT32 length, BOOLEAN write_to_end, | ||||
|                                  BOOLEAN constrained_io, | ||||
|                                  PUINT32 bytes_transferred, | ||||
|                                  remote::file_info *file_info) | ||||
|                                  remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1620,7 +1617,7 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|           *bytes_transferred = static_cast<UINT32>(res); | ||||
|           ret = populate_file_info(construct_api_path(get_open_file_path( | ||||
|                                        static_cast<native_handle>(handle))), | ||||
|                                    *file_info); | ||||
|                                    *r_info); | ||||
|         } else { | ||||
|           ret = static_cast<packet::error_type>( | ||||
|               utils::unix_error_to_windows(errno)); | ||||
|   | ||||
| @@ -172,7 +172,7 @@ auto remote_client::winfsp_close(PVOID file_desc) -> packet::error_type { | ||||
| auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|                                   UINT32 granted_access, UINT32 attributes, | ||||
|                                   UINT64 allocation_size, PVOID *file_desc, | ||||
|                                   remote::file_info *file_info, | ||||
|                                   remote::file_info *r_info, | ||||
|                                   std::string &normalized_name, BOOLEAN &exists) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
| @@ -192,7 +192,7 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|   if (ret == STATUS_SUCCESS) { | ||||
|     HANDLE handle{}; | ||||
|     DECODE_OR_IGNORE(&response, handle); | ||||
|     DECODE_OR_IGNORE(&response, *file_info); | ||||
|     DECODE_OR_IGNORE(&response, *r_info); | ||||
|     DECODE_OR_IGNORE(&response, normalized_name); | ||||
|     DECODE_OR_IGNORE(&response, exists); | ||||
|  | ||||
| @@ -200,10 +200,10 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|       *file_desc = reinterpret_cast<PVOID>(handle); | ||||
|       set_open_info(to_handle(*file_desc), | ||||
|                     open_info{ | ||||
|                         "", | ||||
|                         nullptr, | ||||
|                         {}, | ||||
|                         utils::string::to_utf8(file_name), | ||||
|                         .client_id = "", | ||||
|                         .directory_buffer = nullptr, | ||||
|                         .handles = {}, | ||||
|                         .path = utils::string::to_utf8(file_name), | ||||
|                     }); | ||||
|     } | ||||
|   } | ||||
| @@ -211,7 +211,7 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| auto remote_client::winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
| auto remote_client::winfsp_flush(PVOID file_desc, remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -223,7 +223,7 @@ auto remote_client::winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
|   auto ret{ | ||||
|       packet_client_.send(function_name, request, response, service_flags), | ||||
|   }; | ||||
|   DECODE_OR_IGNORE(&response, *file_info); | ||||
|   DECODE_OR_IGNORE(&response, *r_info); | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
| @@ -241,7 +241,7 @@ auto remote_client::winfsp_get_dir_buffer([[maybe_unused]] PVOID file_desc, | ||||
| } | ||||
|  | ||||
| auto remote_client::winfsp_get_file_info(PVOID file_desc, | ||||
|                                          remote::file_info *file_info) | ||||
|                                          remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -253,7 +253,7 @@ auto remote_client::winfsp_get_file_info(PVOID file_desc, | ||||
|   auto ret{ | ||||
|       packet_client_.send(function_name, request, response, service_flags), | ||||
|   }; | ||||
|   DECODE_OR_IGNORE(&response, *file_info); | ||||
|   DECODE_OR_IGNORE(&response, *r_info); | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
| @@ -332,7 +332,7 @@ auto remote_client::winfsp_mounted(const std::wstring &location) | ||||
|  | ||||
| auto remote_client::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|                                 UINT32 granted_access, PVOID *file_desc, | ||||
|                                 remote::file_info *file_info, | ||||
|                                 remote::file_info *r_info, | ||||
|                                 std::string &normalized_name) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
| @@ -350,7 +350,7 @@ auto remote_client::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|   if (ret == STATUS_SUCCESS) { | ||||
|     HANDLE handle{}; | ||||
|     DECODE_OR_IGNORE(&response, handle); | ||||
|     DECODE_OR_IGNORE(&response, *file_info); | ||||
|     DECODE_OR_IGNORE(&response, *r_info); | ||||
|     DECODE_OR_IGNORE(&response, normalized_name); | ||||
|  | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
| @@ -371,7 +371,7 @@ auto remote_client::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
| auto remote_client::winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|                                      BOOLEAN replace_attributes, | ||||
|                                      UINT64 allocation_size, | ||||
|                                      remote::file_info *file_info) | ||||
|                                      remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -386,7 +386,7 @@ auto remote_client::winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|   auto ret{ | ||||
|       packet_client_.send(function_name, request, response, service_flags), | ||||
|   }; | ||||
|   DECODE_OR_IGNORE(&response, *file_info); | ||||
|   DECODE_OR_IGNORE(&response, *r_info); | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
| @@ -457,7 +457,7 @@ auto remote_client::winfsp_rename(PVOID file_desc, PWSTR file_name, | ||||
| auto remote_client::winfsp_set_basic_info( | ||||
|     PVOID file_desc, UINT32 attributes, UINT64 creation_time, | ||||
|     UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, | ||||
|     remote::file_info *file_info) -> packet::error_type { | ||||
|     remote::file_info *r_info) -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   packet request; | ||||
| @@ -473,14 +473,14 @@ auto remote_client::winfsp_set_basic_info( | ||||
|   auto ret{ | ||||
|       packet_client_.send(function_name, request, response, service_flags), | ||||
|   }; | ||||
|   DECODE_OR_IGNORE(&response, *file_info); | ||||
|   DECODE_OR_IGNORE(&response, *r_info); | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| auto remote_client::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|                                          BOOLEAN set_allocation_size, | ||||
|                                          remote::file_info *file_info) | ||||
|                                          remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -494,7 +494,7 @@ auto remote_client::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|   auto ret{ | ||||
|       packet_client_.send(function_name, request, response, service_flags), | ||||
|   }; | ||||
|   DECODE_OR_IGNORE(&response, *file_info); | ||||
|   DECODE_OR_IGNORE(&response, *r_info); | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
| @@ -525,7 +525,7 @@ auto remote_client::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|                                  UINT32 length, BOOLEAN write_to_end, | ||||
|                                  BOOLEAN constrained_io, | ||||
|                                  PUINT32 bytes_transferred, | ||||
|                                  remote::file_info *file_info) | ||||
|                                  remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -547,7 +547,7 @@ auto remote_client::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|       packet_client_.send(function_name, request, response, service_flags), | ||||
|   }; | ||||
|   DECODE_OR_IGNORE(&response, *bytes_transferred); | ||||
|   DECODE_OR_IGNORE(&response, *file_info); | ||||
|   DECODE_OR_IGNORE(&response, *r_info); | ||||
|  | ||||
|   return ret; | ||||
| } | ||||
|   | ||||
| @@ -70,30 +70,30 @@ auto remote_server::construct_path(std::string path) -> std::string { | ||||
| } | ||||
|  | ||||
| auto remote_server::populate_file_info(const std::string &api_path, | ||||
|                                        remote::file_info &file_info) | ||||
|                                        remote::file_info &r_info) | ||||
|     -> packet::error_type { | ||||
|   return (drive_.populate_file_info(api_path, file_info) == api_error::success) | ||||
|   return (drive_.populate_file_info(api_path, &r_info) == api_error::success) | ||||
|              ? STATUS_SUCCESS | ||||
|              : STATUS_OBJECT_NAME_NOT_FOUND; | ||||
| } | ||||
|  | ||||
| void remote_server::populate_stat(const char *path, bool directory, | ||||
|                                   remote::stat &r_stat, | ||||
|                                   const struct _stat64 &unix_st) { | ||||
|                                   const struct _stat64 &u_stat) { | ||||
|   r_stat.st_nlink = static_cast<remote::file_nlink>( | ||||
|       directory ? 2 + drive_.get_directory_item_count( | ||||
|                           utils::path::create_api_path(path)) | ||||
|                 : 1); | ||||
|   r_stat.st_atimespec = | ||||
|       utils::time::windows_time_t_to_unix_time(unix_st.st_atime); | ||||
|       utils::time::windows_time_t_to_unix_time(u_stat.st_atime); | ||||
|   r_stat.st_birthtimespec = | ||||
|       utils::time::windows_time_t_to_unix_time(unix_st.st_ctime); | ||||
|       utils::time::windows_time_t_to_unix_time(u_stat.st_ctime); | ||||
|   r_stat.st_ctimespec = | ||||
|       utils::time::windows_time_t_to_unix_time(unix_st.st_ctime); | ||||
|       utils::time::windows_time_t_to_unix_time(u_stat.st_ctime); | ||||
|   r_stat.st_mtimespec = | ||||
|       utils::time::windows_time_t_to_unix_time(unix_st.st_mtime); | ||||
|   r_stat.st_size = static_cast<remote::file_size>(unix_st.st_size); | ||||
|   r_stat.st_mode = unix_st.st_mode; | ||||
|       utils::time::windows_time_t_to_unix_time(u_stat.st_mtime); | ||||
|   r_stat.st_size = static_cast<remote::file_size>(u_stat.st_size); | ||||
|   r_stat.st_mode = u_stat.st_mode; | ||||
| } | ||||
|  | ||||
| // FUSE Layer | ||||
| @@ -188,10 +188,10 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, | ||||
|   }; | ||||
|   if (res == 0) { | ||||
|     directory = utils::file::directory(file_path).exists(); | ||||
|     struct _stat64 unix_st{}; | ||||
|     res = _fstat64(static_cast<int>(handle), &unix_st); | ||||
|     struct _stat64 u_stat{}; | ||||
|     res = _fstat64(static_cast<int>(handle), &u_stat); | ||||
|     if (res == 0) { | ||||
|       populate_stat(path, directory, r_stat, unix_st); | ||||
|       populate_stat(path, directory, r_stat, u_stat); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -275,11 +275,11 @@ auto remote_server::fuse_ftruncate(const char *path, | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| auto remote_server::fuse_getattr(const char *path, remote::stat &r_st, | ||||
| auto remote_server::fuse_getattr(const char *path, remote::stat &r_stat, | ||||
|                                  bool &directory) -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   r_st = {}; | ||||
|   r_stat = {}; | ||||
|  | ||||
|   auto file_path = construct_path(path); | ||||
|  | ||||
| @@ -290,7 +290,7 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_st, | ||||
|       _stat64(file_path.c_str(), &st1), | ||||
|   }; | ||||
|   if (res == 0) { | ||||
|     populate_stat(path, directory, r_st, st1); | ||||
|     populate_stat(path, directory, r_stat, st1); | ||||
|   } | ||||
|  | ||||
|   auto ret = ((res < 0) ? -errno : 0); | ||||
| @@ -966,7 +966,7 @@ auto remote_server::winfsp_close(PVOID file_desc) -> packet::error_type { | ||||
| auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|                                   UINT32 granted_access, UINT32 attributes, | ||||
|                                   UINT64 /*allocation_size*/, PVOID *file_desc, | ||||
|                                   remote::file_info *file_info, | ||||
|                                   remote::file_info *r_info, | ||||
|                                   std::string &normalized_name, BOOLEAN &exists) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
| @@ -1006,17 +1006,16 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, | ||||
|                               }); | ||||
|   } | ||||
|  | ||||
|   auto ret = | ||||
|       (handle == INVALID_HANDLE_VALUE) | ||||
|           ? FspNtStatusFromWin32(::GetLastError()) | ||||
|           : populate_file_info(construct_api_path(get_open_file_path(handle)), | ||||
|                                *file_info); | ||||
|   auto ret = (handle == INVALID_HANDLE_VALUE) | ||||
|                  ? FspNtStatusFromWin32(::GetLastError()) | ||||
|                  : populate_file_info( | ||||
|                        construct_api_path(get_open_file_path(handle)), *r_info); | ||||
|   RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, | ||||
|                                    utils::string::to_utf8(file_path), ret); | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
| auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1027,7 +1026,7 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
|                                      : FspNtStatusFromWin32(::GetLastError()); | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       ret = populate_file_info(construct_api_path(get_open_file_path(handle)), | ||||
|                                *file_info); | ||||
|                                *r_info); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -1037,7 +1036,7 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) | ||||
| } | ||||
|  | ||||
| auto remote_server::winfsp_get_file_info(PVOID file_desc, | ||||
|                                          remote::file_info *file_info) | ||||
|                                          remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1045,7 +1044,7 @@ auto remote_server::winfsp_get_file_info(PVOID file_desc, | ||||
|   auto ret = has_open_info(handle, STATUS_INVALID_HANDLE); | ||||
|   if (ret == STATUS_SUCCESS) { | ||||
|     ret = populate_file_info(construct_api_path(get_open_file_path(handle)), | ||||
|                              *file_info); | ||||
|                              *r_info); | ||||
|   } | ||||
|   RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, get_open_file_path(file_desc), | ||||
|                                    ret); | ||||
| @@ -1117,7 +1116,7 @@ auto remote_server::winfsp_mounted(const std::wstring &location) | ||||
|  | ||||
| auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|                                 UINT32 granted_access, PVOID *file_desc, | ||||
|                                 remote::file_info *file_info, | ||||
|                                 remote::file_info *r_info, | ||||
|                                 std::string &normalized_name) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
| @@ -1145,11 +1144,10 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
|                               }); | ||||
|   } | ||||
|  | ||||
|   auto ret = | ||||
|       (handle == INVALID_HANDLE_VALUE) | ||||
|           ? FspNtStatusFromWin32(::GetLastError()) | ||||
|           : populate_file_info(construct_api_path(get_open_file_path(handle)), | ||||
|                                *file_info); | ||||
|   auto ret = (handle == INVALID_HANDLE_VALUE) | ||||
|                  ? FspNtStatusFromWin32(::GetLastError()) | ||||
|                  : populate_file_info( | ||||
|                        construct_api_path(get_open_file_path(handle)), *r_info); | ||||
|   RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, | ||||
|                                    utils::string::to_utf8(file_path), ret); | ||||
|   return ret; | ||||
| @@ -1158,7 +1156,7 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, | ||||
| auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|                                      BOOLEAN replace_attributes, | ||||
|                                      UINT64 /*allocation_size*/, | ||||
|                                      remote::file_info *file_info) | ||||
|                                      remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1187,13 +1185,12 @@ auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, | ||||
|  | ||||
|     if (ret == STATUS_SUCCESS) { | ||||
|       FILE_ALLOCATION_INFO allocationInfo{}; | ||||
|       ret = | ||||
|           ::SetFileInformationByHandle(handle, FileAllocationInfo, | ||||
|                                        &allocationInfo, | ||||
|                                        sizeof(FILE_ALLOCATION_INFO)) != 0 | ||||
|               ? populate_file_info( | ||||
|                     construct_api_path(get_open_file_path(handle)), *file_info) | ||||
|               : FspNtStatusFromWin32(::GetLastError()); | ||||
|       ret = ::SetFileInformationByHandle(handle, FileAllocationInfo, | ||||
|                                          &allocationInfo, | ||||
|                                          sizeof(FILE_ALLOCATION_INFO)) != 0 | ||||
|                 ? populate_file_info( | ||||
|                       construct_api_path(get_open_file_path(handle)), *r_info) | ||||
|                 : FspNtStatusFromWin32(::GetLastError()); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -1285,7 +1282,7 @@ auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, | ||||
| auto remote_server::winfsp_set_basic_info( | ||||
|     PVOID file_desc, UINT32 attributes, UINT64 creation_time, | ||||
|     UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time, | ||||
|     remote::file_info *file_info) -> packet::error_type { | ||||
|     remote::file_info *r_info) -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   auto *handle = reinterpret_cast<HANDLE>(file_desc); | ||||
| @@ -1307,7 +1304,7 @@ auto remote_server::winfsp_set_basic_info( | ||||
|     ret = ::SetFileInformationByHandle(handle, FileBasicInfo, &basic_info, | ||||
|                                        sizeof(FILE_BASIC_INFO)) != 0 | ||||
|               ? populate_file_info( | ||||
|                     construct_api_path(get_open_file_path(handle)), *file_info) | ||||
|                     construct_api_path(get_open_file_path(handle)), *r_info) | ||||
|               : FspNtStatusFromWin32(::GetLastError()); | ||||
|   } | ||||
|   RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, get_open_file_path(file_desc), | ||||
| @@ -1317,7 +1314,7 @@ auto remote_server::winfsp_set_basic_info( | ||||
|  | ||||
| auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|                                          BOOLEAN set_allocation_size, | ||||
|                                          remote::file_info *file_info) | ||||
|                                          remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1343,7 +1340,7 @@ auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, | ||||
|  | ||||
|     ret = (ret == STATUS_SUCCESS) | ||||
|               ? populate_file_info( | ||||
|                     construct_api_path(get_open_file_path(handle)), *file_info) | ||||
|                     construct_api_path(get_open_file_path(handle)), *r_info) | ||||
|               : ret; | ||||
|   } | ||||
|  | ||||
| @@ -1365,7 +1362,7 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|                                  UINT32 length, BOOLEAN /*write_to_end*/, | ||||
|                                  BOOLEAN constrained_io, | ||||
|                                  PUINT32 bytes_transferred, | ||||
|                                  remote::file_info *file_info) | ||||
|                                  remote::file_info *r_info) | ||||
|     -> packet::error_type { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
| @@ -1397,13 +1394,12 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, | ||||
|                           reinterpret_cast<LPDWORD>(bytes_transferred), | ||||
|                           &overlapped) != 0 | ||||
|                   ? populate_file_info( | ||||
|                         construct_api_path(get_open_file_path(handle)), | ||||
|                         *file_info) | ||||
|                         construct_api_path(get_open_file_path(handle)), *r_info) | ||||
|                   : FspNtStatusFromWin32(::GetLastError()); | ||||
|       } | ||||
|     } else { | ||||
|       ret = populate_file_info(construct_api_path(get_open_file_path(handle)), | ||||
|                                *file_info); | ||||
|                                *r_info); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -131,14 +131,14 @@ auto remote_winfsp_drive::Create(PWSTR file_name, UINT32 create_options, | ||||
|                                  UINT64 allocation_size, PVOID * /*file_node*/, | ||||
|                                  PVOID *file_desc, OpenFileInfo *ofi) | ||||
|     -> NTSTATUS { | ||||
|   remote::file_info f_info{}; | ||||
|   remote::file_info r_info{}; | ||||
|   std::string normalized_name; | ||||
|   BOOLEAN exists{0}; | ||||
|   auto ret = remote_instance_->winfsp_create( | ||||
|       file_name, create_options, granted_access, attributes, allocation_size, | ||||
|       file_desc, &f_info, normalized_name, exists); | ||||
|       file_desc, &r_info, normalized_name, exists); | ||||
|   if (ret == STATUS_SUCCESS) { | ||||
|     set_file_info(ofi->FileInfo, f_info); | ||||
|     set_file_info(ofi->FileInfo, r_info); | ||||
|     auto file_path = utils::string::from_utf8(normalized_name); | ||||
|     wcsncpy(ofi->NormalizedName, file_path.data(), wcslen(file_path.c_str())); | ||||
|     ofi->NormalizedNameSize = | ||||
| @@ -152,18 +152,18 @@ auto remote_winfsp_drive::Create(PWSTR file_name, UINT32 create_options, | ||||
| } | ||||
|  | ||||
| auto remote_winfsp_drive::Flush(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                 FileInfo *file_info) -> NTSTATUS { | ||||
|   remote::file_info fi{}; | ||||
|   auto ret = remote_instance_->winfsp_flush(file_desc, &fi); | ||||
|   set_file_info(*file_info, fi); | ||||
|                                 FileInfo *f_info) -> NTSTATUS { | ||||
|   remote::file_info r_info{}; | ||||
|   auto ret = remote_instance_->winfsp_flush(file_desc, &r_info); | ||||
|   set_file_info(*f_info, r_info); | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| auto remote_winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                       FileInfo *file_info) -> NTSTATUS { | ||||
|   remote::file_info fi{}; | ||||
|   auto ret = remote_instance_->winfsp_get_file_info(file_desc, &fi); | ||||
|   set_file_info(*file_info, fi); | ||||
|                                       FileInfo *f_info) -> NTSTATUS { | ||||
|   remote::file_info r_info{}; | ||||
|   auto ret = remote_instance_->winfsp_get_file_info(file_desc, &r_info); | ||||
|   set_file_info(*f_info, r_info); | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| @@ -300,13 +300,13 @@ auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options, | ||||
|                                UINT32 granted_access, PVOID * /*file_node*/, | ||||
|                                PVOID *file_desc, OpenFileInfo *ofi) | ||||
|     -> NTSTATUS { | ||||
|   remote::file_info fi{}; | ||||
|   remote::file_info r_info{}; | ||||
|   std::string normalize_name; | ||||
|   auto ret = | ||||
|       remote_instance_->winfsp_open(file_name, create_options, granted_access, | ||||
|                                     file_desc, &fi, normalize_name); | ||||
|                                     file_desc, &r_info, normalize_name); | ||||
|   if (ret == STATUS_SUCCESS) { | ||||
|     set_file_info(ofi->FileInfo, fi); | ||||
|     set_file_info(ofi->FileInfo, r_info); | ||||
|     auto file_path = utils::string::from_utf8(normalize_name); | ||||
|     wcsncpy(ofi->NormalizedName, file_path.data(), wcslen(file_path.c_str())); | ||||
|     ofi->NormalizedNameSize = | ||||
| @@ -319,31 +319,31 @@ auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options, | ||||
| auto remote_winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                     UINT32 attributes, | ||||
|                                     BOOLEAN replace_attributes, | ||||
|                                     UINT64 allocation_size, FileInfo *file_info) | ||||
|                                     UINT64 allocation_size, FileInfo *f_info) | ||||
|     -> NTSTATUS { | ||||
|   remote::file_info info{}; | ||||
|   remote::file_info r_info{}; | ||||
|   auto ret = remote_instance_->winfsp_overwrite( | ||||
|       file_desc, attributes, replace_attributes, allocation_size, &info); | ||||
|   set_file_info(*file_info, info); | ||||
|       file_desc, attributes, replace_attributes, allocation_size, &r_info); | ||||
|   set_file_info(*f_info, r_info); | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| void remote_winfsp_drive::populate_file_info(const json &item, | ||||
|                                              FSP_FSCTL_FILE_INFO &file_info) { | ||||
|                                              FSP_FSCTL_FILE_INFO &f_info) { | ||||
|   auto dir_item = item.get<directory_item>(); | ||||
|   file_info.FileSize = dir_item.directory ? 0 : dir_item.size; | ||||
|   file_info.AllocationSize = | ||||
|       utils::divide_with_ceiling(file_info.FileSize, WINFSP_ALLOCATION_UNIT) * | ||||
|   f_info.FileSize = dir_item.directory ? 0 : dir_item.size; | ||||
|   f_info.AllocationSize = | ||||
|       utils::divide_with_ceiling(f_info.FileSize, WINFSP_ALLOCATION_UNIT) * | ||||
|       WINFSP_ALLOCATION_UNIT; | ||||
|   file_info.ChangeTime = utils::get_changed_time_from_meta(dir_item.meta); | ||||
|   file_info.CreationTime = utils::get_creation_time_from_meta(dir_item.meta); | ||||
|   file_info.FileAttributes = utils::get_attributes_from_meta(dir_item.meta); | ||||
|   file_info.HardLinks = 0; | ||||
|   file_info.IndexNumber = 0; | ||||
|   file_info.LastAccessTime = utils::get_accessed_time_from_meta(dir_item.meta); | ||||
|   file_info.LastWriteTime = utils::get_written_time_from_meta(dir_item.meta); | ||||
|   file_info.ReparseTag = 0; | ||||
|   file_info.EaSize = 0; | ||||
|   f_info.ChangeTime = utils::get_changed_time_from_meta(dir_item.meta); | ||||
|   f_info.CreationTime = utils::get_creation_time_from_meta(dir_item.meta); | ||||
|   f_info.FileAttributes = utils::get_attributes_from_meta(dir_item.meta); | ||||
|   f_info.HardLinks = 0; | ||||
|   f_info.IndexNumber = 0; | ||||
|   f_info.LastAccessTime = utils::get_accessed_time_from_meta(dir_item.meta); | ||||
|   f_info.LastWriteTime = utils::get_written_time_from_meta(dir_item.meta); | ||||
|   f_info.ReparseTag = 0; | ||||
|   f_info.EaSize = 0; | ||||
| } | ||||
|  | ||||
| auto remote_winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, | ||||
| @@ -443,39 +443,39 @@ auto remote_winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                        UINT32 attributes, UINT64 creation_time, | ||||
|                                        UINT64 last_access_time, | ||||
|                                        UINT64 last_write_time, | ||||
|                                        UINT64 change_time, FileInfo *file_info) | ||||
|                                        UINT64 change_time, FileInfo *f_info) | ||||
|     -> NTSTATUS { | ||||
|   remote::file_info f_info{}; | ||||
|   remote::file_info r_info{}; | ||||
|   auto ret = remote_instance_->winfsp_set_basic_info( | ||||
|       file_desc, attributes, creation_time, last_access_time, last_write_time, | ||||
|       change_time, &f_info); | ||||
|   set_file_info(*file_info, f_info); | ||||
|       change_time, &r_info); | ||||
|   set_file_info(*f_info, r_info); | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| void remote_winfsp_drive::set_file_info(FileInfo &dest, | ||||
|                                         const remote::file_info &src) { | ||||
|   dest.FileAttributes = src.FileAttributes; | ||||
|   dest.ReparseTag = src.ReparseTag; | ||||
|   dest.AllocationSize = src.AllocationSize; | ||||
|   dest.FileSize = src.FileSize; | ||||
|   dest.CreationTime = src.CreationTime; | ||||
|   dest.LastAccessTime = src.LastAccessTime; | ||||
|   dest.LastWriteTime = src.LastWriteTime; | ||||
|   dest.ChangeTime = src.ChangeTime; | ||||
|   dest.IndexNumber = src.IndexNumber; | ||||
|   dest.HardLinks = src.HardLinks; | ||||
|   dest.EaSize = src.EaSize; | ||||
| void remote_winfsp_drive::set_file_info(FileInfo &f_info, | ||||
|                                         const remote::file_info &r_info) { | ||||
|   f_info.FileAttributes = r_info.FileAttributes; | ||||
|   f_info.ReparseTag = r_info.ReparseTag; | ||||
|   f_info.AllocationSize = r_info.AllocationSize; | ||||
|   f_info.FileSize = r_info.FileSize; | ||||
|   f_info.CreationTime = r_info.CreationTime; | ||||
|   f_info.LastAccessTime = r_info.LastAccessTime; | ||||
|   f_info.LastWriteTime = r_info.LastWriteTime; | ||||
|   f_info.ChangeTime = r_info.ChangeTime; | ||||
|   f_info.IndexNumber = r_info.IndexNumber; | ||||
|   f_info.HardLinks = r_info.HardLinks; | ||||
|   f_info.EaSize = r_info.EaSize; | ||||
| } | ||||
|  | ||||
| auto remote_winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                       UINT64 new_size, | ||||
|                                       BOOLEAN set_allocation_size, | ||||
|                                       FileInfo *file_info) -> NTSTATUS { | ||||
|   remote::file_info fi{}; | ||||
|   auto ret = remote_instance_->winfsp_set_file_size(file_desc, new_size, | ||||
|                                                     set_allocation_size, &fi); | ||||
|   set_file_info(*file_info, fi); | ||||
|                                       FileInfo *f_info) -> NTSTATUS { | ||||
|   remote::file_info r_info{}; | ||||
|   auto ret = remote_instance_->winfsp_set_file_size( | ||||
|       file_desc, new_size, set_allocation_size, &r_info); | ||||
|   set_file_info(*f_info, r_info); | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| @@ -495,13 +495,13 @@ VOID remote_winfsp_drive::Unmounted(PVOID host) { | ||||
| auto remote_winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                 PVOID buffer, UINT64 offset, ULONG length, | ||||
|                                 BOOLEAN write_to_end, BOOLEAN constrained_io, | ||||
|                                 PULONG bytes_transferred, FileInfo *file_info) | ||||
|                                 PULONG bytes_transferred, FileInfo *f_info) | ||||
|     -> NTSTATUS { | ||||
|   remote::file_info fi{}; | ||||
|   remote::file_info r_info{}; | ||||
|   auto ret = remote_instance_->winfsp_write( | ||||
|       file_desc, buffer, offset, length, write_to_end, constrained_io, | ||||
|       reinterpret_cast<PUINT32>(bytes_transferred), &fi); | ||||
|   set_file_info(*file_info, fi); | ||||
|       reinterpret_cast<PUINT32>(bytes_transferred), &r_info); | ||||
|   set_file_info(*f_info, r_info); | ||||
|   return ret; | ||||
| } | ||||
| } // namespace repertory::remote_winfsp | ||||
|   | ||||
| @@ -70,14 +70,14 @@ winfsp_drive::winfsp_service::winfsp_service( | ||||
|  | ||||
| auto winfsp_drive::handle_error(std::string_view function_name, | ||||
|                                 const std::string &api_path, api_error error, | ||||
|                                 FileInfo *file_info, std::uint64_t file_size, | ||||
|                                 FileInfo *f_info, std::uint64_t file_size, | ||||
|                                 bool raise_on_failure_only) const -> NTSTATUS { | ||||
|   auto ret = utils::from_api_error(error); | ||||
|   if (not raise_on_failure_only) { | ||||
|     RAISE_WINFSP_EVENT(function_name, api_path, ret); | ||||
|   } | ||||
|  | ||||
|   if (file_info == nullptr) { | ||||
|   if (f_info == nullptr) { | ||||
|     return ret; | ||||
|   } | ||||
|  | ||||
| @@ -86,7 +86,7 @@ auto winfsp_drive::handle_error(std::string_view function_name, | ||||
|     return ret; | ||||
|   } | ||||
|  | ||||
|   populate_file_info(file_size, meta, *file_info); | ||||
|   populate_file_info(file_size, meta, *f_info); | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| @@ -371,15 +371,15 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options, | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| auto winfsp_drive::Flush(PVOID /*file_node*/, PVOID file_desc, | ||||
|                          FileInfo *file_info) -> NTSTATUS { | ||||
| auto winfsp_drive::Flush(PVOID /*file_node*/, PVOID file_desc, FileInfo *f_info) | ||||
|     -> NTSTATUS { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   std::string api_path; | ||||
|   std::shared_ptr<i_open_file> file; | ||||
|   const auto handle_error = [this, &api_path, &file, | ||||
|                              &file_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, file_info, | ||||
|                              &f_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, f_info, | ||||
|                               file ? file->get_file_size() : 0U); | ||||
|   }; | ||||
|  | ||||
| @@ -418,14 +418,14 @@ auto winfsp_drive::get_directory_items(const std::string &api_path) const | ||||
| } | ||||
|  | ||||
| auto winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                FileInfo *file_info) -> NTSTATUS { | ||||
|                                FileInfo *f_info) -> NTSTATUS { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   std::string api_path; | ||||
|   std::shared_ptr<i_open_file> file; | ||||
|   const auto handle_error = [this, &api_path, &file, | ||||
|                              &file_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, file_info, | ||||
|                              &f_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, f_info, | ||||
|                               file ? file->get_file_size() : 0U); | ||||
|   }; | ||||
|  | ||||
| @@ -733,15 +733,15 @@ auto winfsp_drive::Open(PWSTR file_name, UINT32 create_options, | ||||
|  | ||||
| auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc, | ||||
|                              UINT32 attributes, BOOLEAN replace_attributes, | ||||
|                              UINT64 /*allocation_size*/, FileInfo *file_info) | ||||
|                              UINT64 /*allocation_size*/, FileInfo *f_info) | ||||
|     -> NTSTATUS { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   std::string api_path; | ||||
|   std::shared_ptr<i_open_file> file; | ||||
|   const auto handle_error = [this, &api_path, &file, | ||||
|                              &file_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, file_info, | ||||
|                              &f_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, f_info, | ||||
|                               file ? file->get_file_size() : 0U); | ||||
|   }; | ||||
|  | ||||
| @@ -808,14 +808,14 @@ void winfsp_drive::populate_file_info(const std::string &api_path, | ||||
| } | ||||
|  | ||||
| auto winfsp_drive::populate_file_info(const std::string &api_path, | ||||
|                                       remote::file_info &file_info) const | ||||
|                                       remote::file_info &r_info) const | ||||
|     -> api_error { | ||||
|   api_meta_map meta{}; | ||||
|   auto ret = provider_.get_item_meta(api_path, meta); | ||||
|   if (ret == api_error::success) { | ||||
|     FSP_FSCTL_FILE_INFO info{}; | ||||
|     populate_file_info(utils::string::to_uint64(meta[META_SIZE]), meta, info); | ||||
|     set_file_info(file_info, info); | ||||
|     set_file_info(r_info, info); | ||||
|   } | ||||
|  | ||||
|   return ret; | ||||
| @@ -823,20 +823,20 @@ auto winfsp_drive::populate_file_info(const std::string &api_path, | ||||
|  | ||||
| void winfsp_drive::populate_file_info(std::uint64_t file_size, | ||||
|                                       api_meta_map meta, | ||||
|                                       FSP_FSCTL_FILE_INFO &file_info) const { | ||||
|   file_info.FileSize = file_size; | ||||
|   file_info.AllocationSize = | ||||
|                                       FSP_FSCTL_FILE_INFO &f_info) const { | ||||
|   f_info.FileSize = file_size; | ||||
|   f_info.AllocationSize = | ||||
|       utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) * | ||||
|       WINFSP_ALLOCATION_UNIT; | ||||
|   file_info.ChangeTime = utils::get_changed_time_from_meta(meta); | ||||
|   file_info.CreationTime = utils::get_creation_time_from_meta(meta); | ||||
|   file_info.FileAttributes = utils::get_attributes_from_meta(meta); | ||||
|   file_info.HardLinks = 0; | ||||
|   file_info.IndexNumber = 0; | ||||
|   file_info.LastAccessTime = utils::get_accessed_time_from_meta(meta); | ||||
|   file_info.LastWriteTime = utils::get_written_time_from_meta(meta); | ||||
|   file_info.ReparseTag = 0; | ||||
|   file_info.EaSize = 0; | ||||
|   f_info.ChangeTime = utils::get_changed_time_from_meta(meta); | ||||
|   f_info.CreationTime = utils::get_creation_time_from_meta(meta); | ||||
|   f_info.FileAttributes = utils::get_attributes_from_meta(meta); | ||||
|   f_info.HardLinks = 0; | ||||
|   f_info.IndexNumber = 0; | ||||
|   f_info.LastAccessTime = utils::get_accessed_time_from_meta(meta); | ||||
|   f_info.LastWriteTime = utils::get_written_time_from_meta(meta); | ||||
|   f_info.ReparseTag = 0; | ||||
|   f_info.EaSize = 0; | ||||
| } | ||||
|  | ||||
| auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer, | ||||
| @@ -1060,15 +1060,15 @@ auto winfsp_drive::Rename(PVOID /*file_node*/, PVOID /*file_desc*/, | ||||
| auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                 UINT32 attributes, UINT64 creation_time, | ||||
|                                 UINT64 last_access_time, UINT64 last_write_time, | ||||
|                                 UINT64 change_time, FileInfo *file_info) | ||||
|                                 UINT64 change_time, FileInfo *f_info) | ||||
|     -> NTSTATUS { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   std::string api_path; | ||||
|   std::shared_ptr<i_open_file> file; | ||||
|   const auto handle_error = [this, &api_path, &file, | ||||
|                              &file_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, file_info, | ||||
|                              &f_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, f_info, | ||||
|                               file ? file->get_file_size() : 0U); | ||||
|   }; | ||||
|  | ||||
| @@ -1110,31 +1110,31 @@ auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc, | ||||
|   return handle_error(provider_.set_item_meta(api_path, meta)); | ||||
| } | ||||
|  | ||||
| void winfsp_drive::set_file_info(remote::file_info &dest, | ||||
|                                  const FSP_FSCTL_FILE_INFO &src) { | ||||
|   dest.FileAttributes = src.FileAttributes; | ||||
|   dest.ReparseTag = src.ReparseTag; | ||||
|   dest.AllocationSize = src.AllocationSize; | ||||
|   dest.FileSize = src.FileSize; | ||||
|   dest.CreationTime = src.CreationTime; | ||||
|   dest.LastAccessTime = src.LastAccessTime; | ||||
|   dest.LastWriteTime = src.LastWriteTime; | ||||
|   dest.ChangeTime = src.ChangeTime; | ||||
|   dest.IndexNumber = src.IndexNumber; | ||||
|   dest.HardLinks = src.HardLinks; | ||||
|   dest.EaSize = src.EaSize; | ||||
| void winfsp_drive::set_file_info(remote::f_info &r_info, | ||||
|                                  const FSP_FSCTL_FILE_INFO &f_info) { | ||||
|   r_info.FileAttributes = f_info.FileAttributes; | ||||
|   r_info.ReparseTag = f_info.ReparseTag; | ||||
|   r_info.AllocationSize = f_info.AllocationSize; | ||||
|   r_info.FileSize = f_info.FileSize; | ||||
|   r_info.CreationTime = f_info.CreationTime; | ||||
|   r_info.LastAccessTime = f_info.LastAccessTime; | ||||
|   r_info.LastWriteTime = f_info.LastWriteTime; | ||||
|   r_info.ChangeTime = f_info.ChangeTime; | ||||
|   r_info.IndexNumber = f_info.IndexNumber; | ||||
|   r_info.HardLinks = f_info.HardLinks; | ||||
|   r_info.EaSize = f_info.EaSize; | ||||
| } | ||||
|  | ||||
| auto winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc, | ||||
|                                UINT64 new_size, BOOLEAN set_allocation_size, | ||||
|                                FileInfo *file_info) -> NTSTATUS { | ||||
|                                FileInfo *f_info) -> NTSTATUS { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   std::string api_path; | ||||
|   std::shared_ptr<i_open_file> file; | ||||
|   const auto handle_error = [this, &api_path, &file, | ||||
|                              &file_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, file_info, | ||||
|                              &f_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, f_info, | ||||
|                               file ? file->get_file_size() : 0U); | ||||
|   }; | ||||
|  | ||||
| @@ -1233,7 +1233,7 @@ VOID winfsp_drive::Unmounted(PVOID host) { | ||||
| auto winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc, PVOID buffer, | ||||
|                          UINT64 offset, ULONG length, BOOLEAN write_to_end, | ||||
|                          BOOLEAN constrained_io, PULONG bytes_transferred, | ||||
|                          FileInfo *file_info) -> NTSTATUS { | ||||
|                          FileInfo *f_info) -> NTSTATUS { | ||||
|   REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|   *bytes_transferred = 0U; | ||||
| @@ -1241,8 +1241,8 @@ auto winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc, PVOID buffer, | ||||
|   std::string api_path; | ||||
|   std::shared_ptr<i_open_file> file; | ||||
|   const auto handle_error = [this, &api_path, &file, | ||||
|                              &file_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, file_info, | ||||
|                              &f_info](api_error error) -> NTSTATUS { | ||||
|     return this->handle_error(function_name, api_path, error, f_info, | ||||
|                               file ? file->get_file_size() : 0U, true); | ||||
|   }; | ||||
|  | ||||
|   | ||||
| @@ -101,17 +101,18 @@ auto get_directory_files(std::string_view path, bool oldest_first, | ||||
|  | ||||
|     const auto add_to_lookup = [&](const std::string &lookup_path) { | ||||
|       if (lookup.find(lookup_path) == lookup.end()) { | ||||
|         struct stat st {}; | ||||
|         stat(lookup_path.c_str(), &st); | ||||
|         struct stat u_stat{}; | ||||
|         stat(lookup_path.c_str(), &u_stat); | ||||
| #if defined(__APPLE__) | ||||
|         lookup[lookup_path] = | ||||
|             (static_cast<std::uint64_t>(st.st_mtimespec.tv_sec) * | ||||
|             (static_cast<std::uint64_t>(u_stat.st_mtimespec.tv_sec) * | ||||
|              utils::time::NANOS_PER_SECOND) + | ||||
|             static_cast<std::uint64_t>(st.st_mtimespec.tv_nsec); | ||||
|             static_cast<std::uint64_t>(u_stat.st_mtimespec.tv_nsec); | ||||
| #else  // !defined(__APPLE__) | ||||
|         lookup[lookup_path] = (static_cast<std::uint64_t>(st.st_mtim.tv_sec) * | ||||
|                                utils::time::NANOS_PER_SECOND) + | ||||
|                               static_cast<std::uint64_t>(st.st_mtim.tv_nsec); | ||||
|         lookup[lookup_path] = | ||||
|             (static_cast<std::uint64_t>(u_stat.st_mtim.tv_sec) * | ||||
|              utils::time::NANOS_PER_SECOND) + | ||||
|             static_cast<std::uint64_t>(u_stat.st_mtim.tv_nsec); | ||||
| #endif // defined(__APPLE__) | ||||
|       } | ||||
|     }; | ||||
| @@ -130,12 +131,12 @@ auto get_directory_files(std::string_view path, bool oldest_first, | ||||
| auto read_file_lines(const std::string &path) -> std::vector<std::string> { | ||||
|   std::vector<std::string> ret; | ||||
|   if (utils::file::file(path).exists()) { | ||||
|     std::ifstream fs(path); | ||||
|     std::ifstream stream(path); | ||||
|     std::string current_line; | ||||
|     while (not fs.eof() && std::getline(fs, current_line)) { | ||||
|     while (not stream.eof() && std::getline(stream, current_line)) { | ||||
|       ret.emplace_back(utils::string::right_trim(current_line, '\r')); | ||||
|     } | ||||
|     fs.close(); | ||||
|     stream.close(); | ||||
|   } | ||||
|  | ||||
|   return ret; | ||||
| @@ -159,10 +160,11 @@ auto reset_modified_time(const std::string &path) -> bool { | ||||
|     } | ||||
|   } | ||||
| #else  // !defined(_WIN32) | ||||
|   auto fd = open(path.c_str(), O_RDWR); | ||||
|   if ((ret = (fd != -1))) { | ||||
|     ret = futimens(fd, nullptr) == 0; | ||||
|     close(fd); | ||||
|   auto desc = open(path.c_str(), O_RDWR); | ||||
|   ret = (desc != -1); | ||||
|   if (ret) { | ||||
|     ret = futimens(desc, nullptr) == 0; | ||||
|     close(desc); | ||||
|   } | ||||
| #endif // defined(_WIN32) | ||||
|  | ||||
|   | ||||
| @@ -762,34 +762,11 @@ auto handlers::launch_process(provider_type prov, std::string_view name, | ||||
|     } | ||||
|     exec_args.push_back(nullptr); | ||||
|  | ||||
|     auto pid = fork(); | ||||
|     if (pid < 0) { | ||||
|       exit(1); | ||||
|     } | ||||
|  | ||||
|     if (pid == 0) { | ||||
|       signal(SIGCHLD, SIG_DFL); | ||||
|  | ||||
|       if (setsid() < 0) { | ||||
|         exit(1); | ||||
|       } | ||||
|  | ||||
|       close(STDIN_FILENO); | ||||
|       close(STDOUT_FILENO); | ||||
|       close(STDERR_FILENO); | ||||
|  | ||||
|       if (open("/dev/null", O_RDONLY) != 0 || | ||||
|           open("/dev/null", O_WRONLY) != 1 || | ||||
|           open("/dev/null", O_WRONLY) != 2) { | ||||
|         exit(1); | ||||
|       } | ||||
|  | ||||
|     exit(utils::create_daemon([&]() -> int { | ||||
|       chdir(utils::path::get_parent_path(repertory_binary_).c_str()); | ||||
|       execvp(exec_args.at(0U), const_cast<char *const *>(exec_args.data())); | ||||
|       exit(1); | ||||
|     } else { | ||||
|       signal(SIGCHLD, SIG_IGN); | ||||
|     } | ||||
|       return execvp(exec_args.at(0U), | ||||
|                     const_cast<char *const *>(exec_args.data())); | ||||
|     })); | ||||
| #endif // defined(_WIN32) | ||||
|  | ||||
|     return {}; | ||||
|   | ||||
| @@ -298,10 +298,10 @@ public: | ||||
|     EXPECT_TRUE(utils::file::file(file_path).exists()); | ||||
|     EXPECT_FALSE(utils::file::directory(file_path).exists()); | ||||
|  | ||||
|     struct stat64 unix_st{}; | ||||
|     EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||
|     EXPECT_EQ(getgid(), unix_st.st_gid); | ||||
|     EXPECT_EQ(getuid(), unix_st.st_uid); | ||||
|     struct stat64 u_stat{}; | ||||
|     EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat)); | ||||
|     EXPECT_EQ(getgid(), u_stat.st_gid); | ||||
|     EXPECT_EQ(getuid(), u_stat.st_uid); | ||||
|  | ||||
|     return file_path; | ||||
|   } | ||||
| @@ -322,10 +322,10 @@ public: | ||||
|     EXPECT_EQ(0U, utils::file::directory(dir_path).count(true)); | ||||
|     EXPECT_FALSE(utils::file::file(dir_path).exists()); | ||||
|  | ||||
|     struct stat64 unix_st{}; | ||||
|     EXPECT_EQ(0, stat64(dir_path.c_str(), &unix_st)); | ||||
|     EXPECT_EQ(getgid(), unix_st.st_gid); | ||||
|     EXPECT_EQ(getuid(), unix_st.st_uid); | ||||
|     struct stat64 u_stat{}; | ||||
|     EXPECT_EQ(0, stat64(dir_path.c_str(), &u_stat)); | ||||
|     EXPECT_EQ(getgid(), u_stat.st_gid); | ||||
|     EXPECT_EQ(getuid(), u_stat.st_uid); | ||||
|  | ||||
|     return dir_path; | ||||
|   } | ||||
|   | ||||
| @@ -42,8 +42,9 @@ private: | ||||
|   std::string mount_location_; | ||||
|  | ||||
| public: | ||||
|   [[nodiscard]] auto get_directory_item_count( | ||||
|       const std::string & /*api_path*/) const -> std::uint64_t override { | ||||
|   [[nodiscard]] auto | ||||
|   get_directory_item_count(const std::string & /*api_path*/) const | ||||
|       -> std::uint64_t override { | ||||
|     return 1; | ||||
|   } | ||||
|  | ||||
| @@ -84,10 +85,10 @@ public: | ||||
|     return api_error::error; | ||||
|   } | ||||
|  | ||||
|   auto | ||||
|   get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes, | ||||
|                        PSECURITY_DESCRIPTOR descriptor, | ||||
|                        std::uint64_t *descriptor_size) -> NTSTATUS override { | ||||
|   auto get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes, | ||||
|                             PSECURITY_DESCRIPTOR descriptor, | ||||
|                             std::uint64_t *descriptor_size) | ||||
|       -> NTSTATUS override { | ||||
|     auto ret = STATUS_SUCCESS; | ||||
|  | ||||
|     if (attributes != nullptr) { | ||||
| @@ -134,9 +135,9 @@ public: | ||||
|     volume_label = "TestVolumeLabel"; | ||||
|   } | ||||
|  | ||||
|   auto | ||||
|   populate_file_info(const std::string &api_path, | ||||
|                      remote::file_info &file_info) const -> api_error override { | ||||
|   auto populate_file_info(const std::string &api_path, | ||||
|                           remote::file_info &r_info) const | ||||
|       -> api_error override { | ||||
|     auto file_path = utils::path::combine(mount_location_, {api_path}); | ||||
|     auto directory = utils::file::directory(file_path).exists(); | ||||
|     auto attributes = | ||||
| @@ -155,21 +156,20 @@ public: | ||||
|         return api_error::os_error; | ||||
|       } | ||||
|  | ||||
|       file_info.FileSize = opt_size.value(); | ||||
|       r_info.FileSize = opt_size.value(); | ||||
|     } | ||||
|  | ||||
|     file_info.AllocationSize = | ||||
|     r_info.AllocationSize = | ||||
|         directory ? 0 | ||||
|                   : utils::divide_with_ceiling(file_info.FileSize, | ||||
|                   : utils::divide_with_ceiling(r_info.FileSize, | ||||
|                                                WINFSP_ALLOCATION_UNIT) * | ||||
|                         WINFSP_ALLOCATION_UNIT; | ||||
|     file_info.FileAttributes = basic_info.FileAttributes; | ||||
|     file_info.ChangeTime = static_cast<UINT64>(basic_info.ChangeTime.QuadPart); | ||||
|     file_info.CreationTime = | ||||
|         static_cast<UINT64>(basic_info.CreationTime.QuadPart); | ||||
|     file_info.LastAccessTime = | ||||
|     r_info.FileAttributes = basic_info.FileAttributes; | ||||
|     r_info.ChangeTime = static_cast<UINT64>(basic_info.ChangeTime.QuadPart); | ||||
|     r_info.CreationTime = static_cast<UINT64>(basic_info.CreationTime.QuadPart); | ||||
|     r_info.LastAccessTime = | ||||
|         static_cast<UINT64>(basic_info.LastAccessTime.QuadPart); | ||||
|     file_info.LastWriteTime = | ||||
|     r_info.LastWriteTime = | ||||
|         static_cast<UINT64>(basic_info.LastWriteTime.QuadPart); | ||||
|     ::CloseHandle(handle); | ||||
|     return api_error::success; | ||||
|   | ||||
| @@ -43,10 +43,10 @@ TYPED_TEST(fuse_test, chmod_can_chmod_if_owner) { | ||||
|   EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR)); | ||||
|   std::this_thread::sleep_for(SLEEP_SECONDS); | ||||
|  | ||||
|   struct stat64 unix_st{}; | ||||
|   stat64(file_path.c_str(), &unix_st); | ||||
|   struct stat64 u_stat{}; | ||||
|   stat64(file_path.c_str(), &u_stat); | ||||
|   EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR), | ||||
|             ACCESSPERMS & unix_st.st_mode); | ||||
|             ACCESSPERMS & u_stat.st_mode); | ||||
|  | ||||
|   this->unlink_file_and_test(file_path); | ||||
| } | ||||
| @@ -69,9 +69,9 @@ TYPED_TEST(fuse_test, chmod_can_not_chmod_setgid_if_not_root) { | ||||
|   EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID)); | ||||
|   std::this_thread::sleep_for(SLEEP_SECONDS); | ||||
|  | ||||
|   struct stat64 unix_st{}; | ||||
|   stat64(file_path.c_str(), &unix_st); | ||||
|   EXPECT_EQ(0, S_ISGID & unix_st.st_mode); | ||||
|   struct stat64 u_stat{}; | ||||
|   stat64(file_path.c_str(), &u_stat); | ||||
|   EXPECT_EQ(0, S_ISGID & u_stat.st_mode); | ||||
| #else  // !defined(__APPLE__) | ||||
|   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID)); | ||||
|   EXPECT_EQ(EPERM, errno); | ||||
| @@ -88,9 +88,9 @@ TYPED_TEST(fuse_test, chmod_can_not_chmod_setuid_if_not_root) { | ||||
|   EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID)); | ||||
|   std::this_thread::sleep_for(SLEEP_SECONDS); | ||||
|  | ||||
|   struct stat64 unix_st{}; | ||||
|   stat64(file_path.c_str(), &unix_st); | ||||
|   EXPECT_EQ(0, S_ISUID & unix_st.st_mode); | ||||
|   struct stat64 u_stat{}; | ||||
|   stat64(file_path.c_str(), &u_stat); | ||||
|   EXPECT_EQ(0, S_ISUID & u_stat.st_mode); | ||||
| #else  // !defined(__APPLE__) | ||||
|   EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID)); | ||||
|   EXPECT_EQ(EPERM, errno); | ||||
|   | ||||
| @@ -31,16 +31,16 @@ TYPED_TEST(fuse_test, | ||||
|   std::string file_name{"chown_test"}; | ||||
|   auto file_path = this->create_file_and_test(file_name); | ||||
|  | ||||
|   struct stat64 unix_st {}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||
|   struct stat64 u_stat{}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat)); | ||||
|  | ||||
|   EXPECT_EQ(0, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid())); | ||||
|   std::this_thread::sleep_for(SLEEP_SECONDS); | ||||
|  | ||||
|   struct stat64 unix_st2 {}; | ||||
|   stat64(file_path.c_str(), &unix_st2); | ||||
|   EXPECT_EQ(getgid(), unix_st2.st_gid); | ||||
|   EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); | ||||
|   struct stat64 u_stat2{}; | ||||
|   stat64(file_path.c_str(), &u_stat2); | ||||
|   EXPECT_EQ(getgid(), u_stat2.st_gid); | ||||
|   EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid); | ||||
|  | ||||
|   this->unlink_file_and_test(file_path); | ||||
| } | ||||
| @@ -51,16 +51,16 @@ TYPED_TEST( | ||||
|   std::string file_name{"chown_test"}; | ||||
|   auto file_path = this->create_file_and_test(file_name); | ||||
|  | ||||
|   struct stat64 unix_st {}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||
|   struct stat64 u_stat{}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat)); | ||||
|  | ||||
|   EXPECT_EQ(0, chown(file_path.c_str(), getuid(), getgid())); | ||||
|   std::this_thread::sleep_for(SLEEP_SECONDS); | ||||
|  | ||||
|   struct stat64 unix_st2 {}; | ||||
|   stat64(file_path.c_str(), &unix_st2); | ||||
|   EXPECT_EQ(getgid(), unix_st2.st_gid); | ||||
|   EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); | ||||
|   struct stat64 u_stat2{}; | ||||
|   stat64(file_path.c_str(), &u_stat2); | ||||
|   EXPECT_EQ(getgid(), u_stat2.st_gid); | ||||
|   EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid); | ||||
|  | ||||
|   this->unlink_file_and_test(file_path); | ||||
| } | ||||
| @@ -70,16 +70,16 @@ TYPED_TEST(fuse_test, | ||||
|   std::string file_name{"chown_test"}; | ||||
|   auto file_path = this->create_file_and_test(file_name); | ||||
|  | ||||
|   struct stat64 unix_st {}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||
|   struct stat64 u_stat{}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat)); | ||||
|  | ||||
|   EXPECT_EQ(-1, chown(file_path.c_str(), static_cast<uid_t>(-1), 0)); | ||||
|   EXPECT_EQ(EPERM, errno); | ||||
|  | ||||
|   struct stat64 unix_st2 {}; | ||||
|   stat64(file_path.c_str(), &unix_st2); | ||||
|   EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid); | ||||
|   EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); | ||||
|   struct stat64 u_stat2{}; | ||||
|   stat64(file_path.c_str(), &u_stat2); | ||||
|   EXPECT_EQ(u_stat.st_gid, u_stat2.st_gid); | ||||
|   EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid); | ||||
|  | ||||
|   this->unlink_file_and_test(file_path); | ||||
| } | ||||
| @@ -88,16 +88,16 @@ TYPED_TEST(fuse_test, chown_can_not_chown_group_if_not_the_owner) { | ||||
|   std::string file_name{"chown_test"}; | ||||
|   auto file_path = this->create_root_file(file_name); | ||||
|  | ||||
|   struct stat64 unix_st {}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||
|   struct stat64 u_stat{}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat)); | ||||
|  | ||||
|   EXPECT_EQ(-1, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid())); | ||||
|   EXPECT_EQ(EPERM, errno); | ||||
|  | ||||
|   struct stat64 unix_st2 {}; | ||||
|   stat64(file_path.c_str(), &unix_st2); | ||||
|   EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid); | ||||
|   EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); | ||||
|   struct stat64 u_stat2{}; | ||||
|   stat64(file_path.c_str(), &u_stat2); | ||||
|   EXPECT_EQ(u_stat.st_gid, u_stat2.st_gid); | ||||
|   EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid); | ||||
|  | ||||
|   this->unlink_root_file(file_path); | ||||
| } | ||||
| @@ -106,16 +106,16 @@ TYPED_TEST(fuse_test, chown_can_not_chown_user_if_not_root) { | ||||
|   std::string file_name{"chown_test"}; | ||||
|   auto file_path = this->create_file_and_test(file_name); | ||||
|  | ||||
|   struct stat64 unix_st {}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||
|   struct stat64 u_stat{}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat)); | ||||
|  | ||||
|   EXPECT_EQ(-1, chown(file_path.c_str(), 0, static_cast<gid_t>(-1))); | ||||
|   EXPECT_EQ(EPERM, errno); | ||||
|  | ||||
|   struct stat64 unix_st2 {}; | ||||
|   stat64(file_path.c_str(), &unix_st2); | ||||
|   EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid); | ||||
|   EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); | ||||
|   struct stat64 u_stat2{}; | ||||
|   stat64(file_path.c_str(), &u_stat2); | ||||
|   EXPECT_EQ(u_stat.st_gid, u_stat2.st_gid); | ||||
|   EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid); | ||||
|  | ||||
|   this->unlink_file_and_test(file_path); | ||||
| } | ||||
|   | ||||
| @@ -41,9 +41,9 @@ TYPED_TEST(fuse_test, create_can_create_directory_with_specific_perms) { | ||||
|   std::string dir_name{"create_test"}; | ||||
|   auto dir_path = this->create_directory_and_test(dir_name, S_IRUSR); | ||||
|  | ||||
|   struct stat64 unix_st{}; | ||||
|   EXPECT_EQ(0, stat64(dir_path.c_str(), &unix_st)); | ||||
|   EXPECT_EQ(S_IRUSR, unix_st.st_mode & ACCESSPERMS); | ||||
|   struct stat64 u_stat{}; | ||||
|   EXPECT_EQ(0, stat64(dir_path.c_str(), &u_stat)); | ||||
|   EXPECT_EQ(S_IRUSR, u_stat.st_mode & ACCESSPERMS); | ||||
|  | ||||
|   this->rmdir_and_test(dir_path); | ||||
| } | ||||
| @@ -52,9 +52,9 @@ TYPED_TEST(fuse_test, create_can_create_file_with_specific_perms) { | ||||
|   std::string file_name{"create_test"}; | ||||
|   auto file_path = this->create_file_and_test(file_name, S_IRUSR); | ||||
|  | ||||
|   struct stat64 unix_st{}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); | ||||
|   EXPECT_EQ(S_IRUSR, unix_st.st_mode & ACCESSPERMS); | ||||
|   struct stat64 u_stat{}; | ||||
|   EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat)); | ||||
|   EXPECT_EQ(S_IRUSR, u_stat.st_mode & ACCESSPERMS); | ||||
|  | ||||
|   this->unlink_file_and_test(file_path); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user