refactor
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
BlockStorage/repertory_mac/pipeline/head This commit looks good

This commit is contained in:
2025-08-04 22:15:23 -05:00
parent efafa6bf68
commit 957a9f9c15
34 changed files with 959 additions and 971 deletions

View File

@@ -100,6 +100,7 @@ endforeach
endfunction endfunction
eventlib eventlib
expect_streq expect_streq
fallocate
fallocate_impl fallocate_impl
fext fext
fgetattr fgetattr

View File

@@ -52,7 +52,8 @@ private:
protected: protected:
bool atime_enabled_{true}; bool atime_enabled_{true};
bool console_enabled_{false}; bool console_enabled_{true};
bool foreground_{false};
std::optional<gid_t> forced_gid_; std::optional<gid_t> forced_gid_;
std::optional<uid_t> forced_uid_; std::optional<uid_t> forced_uid_;
std::optional<mode_t> forced_umask_; std::optional<mode_t> forced_umask_;
@@ -95,50 +96,51 @@ private:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] static auto chmod_(const char *path, mode_t mode, [[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 #else // FUSE_USE_VERSION < 30
[[nodiscard]] static auto chmod_(const char *path, mode_t mode) -> int; [[nodiscard]] static auto chmod_(const char *path, mode_t mode) -> int;
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid, [[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 #else // FUSE_USE_VERSION < 30
[[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid) [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid)
-> int; -> int;
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
[[nodiscard]] static auto create_(const char *path, mode_t mode, [[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); static void destroy_(void *ptr);
[[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset, [[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset,
off_t length, struct fuse_file_info *fi) off_t length,
-> int; struct fuse_file_info *f_info) -> int;
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
[[nodiscard]] static auto fgetattr_(const char *path, struct stat *st, [[nodiscard]] static auto fgetattr_(const char *path, struct stat *u_stat,
struct fuse_file_info *fi) -> int; struct fuse_file_info *f_info) -> int;
#endif // FUSE_USE_VERSION < 30 #endif // FUSE_USE_VERSION < 30
#if defined(__APPLE__) #if defined(__APPLE__)
[[nodiscard]] static auto fsetattr_x_(const char *path, [[nodiscard]] static auto fsetattr_x_(const char *path,
struct setattr_x *attr, struct setattr_x *attr,
struct fuse_file_info *fi) -> int; struct fuse_file_info *f_info) -> int;
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
[[nodiscard]] static auto fsync_(const char *path, int datasync, [[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, [[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 #if FUSE_USE_VERSION >= 30
[[nodiscard]] static auto getattr_(const char *path, struct stat *st, [[nodiscard]] static auto getattr_(const char *path, struct stat *u_stat,
struct fuse_file_info *fi) -> int; struct fuse_file_info *f_info) -> int;
#else // FUSE_USE_VERSION < 30 #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 #endif // FUSE_USE_VERSION >= 30
#if defined(__APPLE__) #if defined(__APPLE__)
@@ -156,33 +158,34 @@ private:
[[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int; [[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int;
[[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi) [[nodiscard]] static auto open_(const char *path,
-> int; struct fuse_file_info *f_info) -> int;
[[nodiscard]] static auto opendir_(const char *path, [[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, [[nodiscard]] static auto read_(const char *path, char *buffer,
size_t read_size, off_t read_offset, 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 #if FUSE_USE_VERSION >= 30
[[nodiscard]] static auto readdir_(const char *path, void *buf, [[nodiscard]] static auto readdir_(const char *path, void *buf,
fuse_fill_dir_t fuse_fill_dir, 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; fuse_readdir_flags flags) -> int;
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] static auto readdir_(const char *path, void *buf, [[nodiscard]] static auto readdir_(const char *path, void *buf,
fuse_fill_dir_t fuse_fill_dir, fuse_fill_dir_t fuse_fill_dir,
off_t offset, struct fuse_file_info *fi) off_t offset,
-> int; struct fuse_file_info *f_info) -> int;
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
[[nodiscard]] static auto release_(const char *path, [[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, [[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 #if FUSE_USE_VERSION >= 30
[[nodiscard]] static auto rename_(const char *from, const char *to, [[nodiscard]] static auto rename_(const char *from, const char *to,
@@ -248,7 +251,7 @@ private:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] static auto truncate_(const char *path, off_t size, [[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 #else // FUSE_USE_VERSION < 30
[[nodiscard]] static auto truncate_(const char *path, off_t size) -> int; [[nodiscard]] static auto truncate_(const char *path, off_t size) -> int;
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
@@ -258,7 +261,7 @@ private:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] static auto utimens_(const char *path, [[nodiscard]] static auto utimens_(const char *path,
const struct timespec tv[2], const struct timespec tv[2],
struct fuse_file_info *fi) -> int; struct fuse_file_info *f_info) -> int;
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] static auto utimens_(const char *path, [[nodiscard]] static auto utimens_(const char *path,
const struct timespec tv[2]) -> int; const struct timespec tv[2]) -> int;
@@ -266,7 +269,7 @@ private:
[[nodiscard]] static auto write_(const char *path, const char *buffer, [[nodiscard]] static auto write_(const char *path, const char *buffer,
size_t write_size, off_t write_offset, size_t write_size, off_t write_offset,
struct fuse_file_info *fi) -> int; struct fuse_file_info *f_info) -> int;
protected: protected:
[[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/) [[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/)
@@ -284,11 +287,11 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/,
mode_t /*mode*/, mode_t /*mode*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else //FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/,
mode_t /*mode*/) -> api_error { mode_t /*mode*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
@@ -298,11 +301,11 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/,
gid_t /*gid*/, gid_t /*gid*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; 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*/, [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/,
gid_t /*gid*/) -> api_error { gid_t /*gid*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
@@ -311,7 +314,7 @@ protected:
[[nodiscard]] virtual auto create_impl(std::string /*api_path*/, [[nodiscard]] virtual auto create_impl(std::string /*api_path*/,
mode_t /*mode*/, mode_t /*mode*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@@ -320,14 +323,14 @@ protected:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/, 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 { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/, [[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/,
struct stat * /*st*/, struct stat * /*u_stat*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@@ -335,7 +338,7 @@ protected:
#if defined(__APPLE__) #if defined(__APPLE__)
[[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/, [[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/,
struct setattr_x * /*attr*/, struct setattr_x * /*attr*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@@ -343,7 +346,7 @@ protected:
[[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/, [[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/,
int /*datasync*/, int /*datasync*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@@ -351,7 +354,7 @@ protected:
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
[[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/, [[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/,
off_t /*size*/, off_t /*size*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@@ -359,14 +362,15 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, [[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/,
struct stat * /*st*/, struct stat * /*u_stat*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, [[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; return api_error::not_implemented;
} }
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
@@ -383,7 +387,7 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
-> void *; -> void *;
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
virtual auto init_impl(struct fuse_conn_info *conn) -> void *; virtual auto init_impl(struct fuse_conn_info *conn) -> void *;
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
@@ -393,20 +397,20 @@ protected:
} }
[[nodiscard]] virtual auto open_impl(std::string /*api_path*/, [[nodiscard]] virtual auto open_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/, [[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
read_impl(std::string /*api_path*/, char * /*buffer*/, size_t /*read_size*/, 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 { std::size_t & /*bytes_read*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@@ -415,27 +419,27 @@ protected:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
readdir_impl(std::string /*api_path*/, void * /*buf*/, readdir_impl(std::string /*api_path*/, void * /*buf*/,
fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, 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 { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
readdir_impl(std::string /*api_path*/, void * /*buf*/, readdir_impl(std::string /*api_path*/, void * /*buf*/,
fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, 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; return api_error::not_implemented;
} }
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto release_impl(std::string /*api_path*/, [[nodiscard]] virtual auto release_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
[[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/, [[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
@@ -446,7 +450,7 @@ protected:
unsigned int /*flags*/) -> api_error { unsigned int /*flags*/) -> api_error {
return api_error::not_implemented; 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*/, [[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/,
std::string /*to_api_path*/) std::string /*to_api_path*/)
-> api_error { -> api_error {
@@ -551,11 +555,11 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/,
off_t /*size*/, off_t /*size*/,
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/,
off_t /*size*/) -> api_error { off_t /*size*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
@@ -570,11 +574,11 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/,
const struct timespec /*tv*/[2], const struct timespec /*tv*/[2],
struct fuse_file_info * /*fi*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/,
const struct timespec /*tv*/[2]) const struct timespec /*tv*/[2])
-> api_error { -> api_error {
@@ -585,8 +589,8 @@ protected:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
write_impl(std::string /*api_path*/, const char * /*buffer*/, write_impl(std::string /*api_path*/, const char * /*buffer*/,
size_t /*write_size*/, off_t /*write_offset*/, size_t /*write_size*/, off_t /*write_offset*/,
struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/) struct fuse_file_info * /*f_info*/,
-> api_error { std::size_t & /*bytes_written*/) -> api_error {
return api_error::not_implemented; return api_error::not_implemented;
} }

View File

@@ -79,7 +79,7 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode, [[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; -> api_error override;
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode) [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode)
@@ -88,7 +88,7 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid, [[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; -> api_error override;
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid) [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid)
@@ -96,43 +96,43 @@ protected:
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
[[nodiscard]] auto create_impl(std::string api_path, mode_t mode, [[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; -> api_error override;
void destroy_impl(void *ptr) override; void destroy_impl(void *ptr) override;
[[nodiscard]] auto fallocate_impl(std::string api_path, int mode, [[nodiscard]] auto fallocate_impl(std::string api_path, int mode,
off_t offset, off_t length, off_t offset, off_t length,
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
[[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *unix_st, [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *u_stat,
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
#if defined(__APPLE__) #if defined(__APPLE__)
[[nodiscard]] auto fsetattr_x_impl(std::string api_path, [[nodiscard]] auto fsetattr_x_impl(std::string api_path,
struct setattr_x *attr, struct setattr_x *attr,
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
[[nodiscard]] auto fsync_impl(std::string api_path, int datasync, [[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; -> api_error override;
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
[[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size, [[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; -> api_error override;
#endif // FUSE_USE_VERSION < 30 #endif // FUSE_USE_VERSION < 30
#if FUSE_USE_VERSION >= 30 #if 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,
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
#else // FUSE_USE_VERSION < 30 #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; -> api_error override;
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
@@ -156,37 +156,37 @@ protected:
void notify_fuse_main_exit(int &ret) override; void notify_fuse_main_exit(int &ret) override;
[[nodiscard]] auto open_impl(std::string api_path, [[nodiscard]] auto open_impl(std::string api_path,
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
[[nodiscard]] auto opendir_impl(std::string api_path, [[nodiscard]] auto opendir_impl(std::string api_path,
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
[[nodiscard]] auto read_impl(std::string api_path, char *buffer, [[nodiscard]] auto read_impl(std::string api_path, char *buffer,
size_t read_size, off_t read_offset, 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; std::size_t &bytes_read) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto readdir_impl(std::string api_path, void *buf, [[nodiscard]] auto readdir_impl(std::string api_path, void *buf,
fuse_fill_dir_t fuse_fill_dir, off_t offset, 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) fuse_readdir_flags flags)
-> api_error override; -> api_error override;
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] auto readdir_impl(std::string api_path, void *buf, [[nodiscard]] auto readdir_impl(std::string api_path, void *buf,
fuse_fill_dir_t fuse_fill_dir, off_t offset, 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; -> api_error override;
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
[[nodiscard]] auto release_impl(std::string api_path, [[nodiscard]] auto release_impl(std::string api_path,
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
[[nodiscard]] auto releasedir_impl(std::string api_path, [[nodiscard]] auto releasedir_impl(std::string api_path,
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
@@ -262,7 +262,7 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto truncate_impl(std::string api_path, off_t size, [[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; -> api_error override;
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] auto truncate_impl(std::string api_path, off_t size) [[nodiscard]] auto truncate_impl(std::string api_path, off_t size)
@@ -274,7 +274,7 @@ protected:
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto utimens_impl(std::string api_path, [[nodiscard]] auto utimens_impl(std::string api_path,
const struct timespec tv[2], const struct timespec tv[2],
struct fuse_file_info *file_info) struct fuse_file_info *f_info)
-> api_error override; -> api_error override;
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
[[nodiscard]] auto utimens_impl(std::string api_path, [[nodiscard]] auto utimens_impl(std::string api_path,
@@ -284,7 +284,7 @@ protected:
[[nodiscard]] auto write_impl(std::string api_path, const char *buffer, [[nodiscard]] auto write_impl(std::string api_path, const char *buffer,
size_t write_size, off_t write_offset, 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) std::size_t &bytes_written)
-> api_error override; -> api_error override;

View File

@@ -121,7 +121,7 @@ protected:
static void populate_stat(const std::string &api_path, static void populate_stat(const std::string &api_path,
std::uint64_t size_or_count, std::uint64_t size_or_count,
const api_meta_map &meta, bool directory, 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, static void set_timespec_from_meta(const api_meta_map &meta,
const std::string &name, const std::string &name,

View File

@@ -65,7 +65,7 @@ public:
&handle) override ;*/ &handle) override ;*/
[[nodiscard]] auto [[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) const remote::file_handle &handle)
-> packet::error_type override; -> packet::error_type override;
@@ -83,7 +83,7 @@ public:
const remote::file_handle &handle) const remote::file_handle &handle)
-> packet::error_type override; -> 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) bool &directory)
-> packet::error_type override; -> packet::error_type override;
@@ -176,11 +176,11 @@ public:
std::int32_t &flags, std::uint32_t position) override ;*/ std::int32_t &flags, std::uint32_t position) override ;*/
[[nodiscard]] auto [[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; -> packet::error_type override;
[[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize, [[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; -> packet::error_type override;
[[nodiscard]] auto fuse_truncate(const char *path, [[nodiscard]] auto fuse_truncate(const char *path,

View File

@@ -25,7 +25,6 @@
#include "drives/fuse/fuse_base.hpp" #include "drives/fuse/fuse_base.hpp"
#include "drives/fuse/remotefuse/i_remote_instance.hpp" #include "drives/fuse/remotefuse/i_remote_instance.hpp"
#include "events/event_system.hpp"
namespace repertory { namespace repertory {
class app_config; class app_config;
@@ -40,6 +39,11 @@ public:
remote_fuse_drive(app_config &config, remote_instance_factory factory, remote_fuse_drive(app_config &config, remote_instance_factory factory,
lock_data &lock) lock_data &lock)
: fuse_base(config), factory_(std::move(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; ~remote_fuse_drive() override = default;
@@ -54,95 +58,97 @@ private:
private: private:
static void populate_stat(const remote::stat &r_stat, bool directory, static void populate_stat(const remote::stat &r_stat, bool directory,
struct stat &unix_st); struct stat &u_stat);
protected: protected:
[[nodiscard]] auto access_impl(std::string api_path, [[nodiscard]] auto access_impl(std::string api_path, int mask)
int mask) -> api_error override; -> api_error override;
#if defined(__APPLE__) #if defined(__APPLE__)
[[nodiscard]] auto chflags_impl(std::string api_path, [[nodiscard]] auto chflags_impl(std::string api_path, uint32_t flags)
uint32_t flags) -> api_error override; -> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode,
chmod_impl(std::string api_path, mode_t mode, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#else #else
[[nodiscard]] auto chmod_impl(std::string api_path, [[nodiscard]] auto chmod_impl(std::string api_path, mode_t mode)
mode_t mode) -> api_error override; -> api_error override;
#endif #endif
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid,
chown_impl(std::string api_path, uid_t uid, gid_t gid, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#else #else
[[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, [[nodiscard]] auto chown_impl(std::string api_path, uid_t uid, gid_t gid)
gid_t gid) -> api_error override; -> api_error override;
#endif #endif
[[nodiscard]] auto [[nodiscard]] auto create_impl(std::string api_path, mode_t mode,
create_impl(std::string api_path, mode_t mode, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
void destroy_impl(void * /*ptr*/) override; void destroy_impl(void * /*ptr*/) override;
[[nodiscard]] auto [[nodiscard]] auto fgetattr_impl(std::string api_path, struct stat *u_stat,
fgetattr_impl(std::string api_path, struct stat *unix_st, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#if defined(__APPLE__) #if defined(__APPLE__)
[[nodiscard]] auto [[nodiscard]] auto fsetattr_x_impl(std::string api_path,
fsetattr_x_impl(std::string api_path, struct setattr_x *attr, struct setattr_x *attr,
struct fuse_file_info *f_info) -> api_error override; struct fuse_file_info *f_info)
-> api_error override;
#endif // __APPLE__ #endif // __APPLE__
[[nodiscard]] auto [[nodiscard]] auto fsync_impl(std::string api_path, int datasync,
fsync_impl(std::string api_path, int datasync, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
[[nodiscard]] auto [[nodiscard]] auto ftruncate_impl(std::string api_path, off_t size,
ftruncate_impl(std::string api_path, off_t size, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#endif #endif
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat,
getattr_impl(std::string api_path, struct stat *unix_st, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#else #else
[[nodiscard]] auto getattr_impl(std::string api_path, [[nodiscard]] auto getattr_impl(std::string api_path, struct stat *u_stat)
struct stat *unix_st) -> api_error override; -> api_error override;
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)
[[nodiscard]] auto [[nodiscard]] auto getxtimes_impl(std::string api_path,
getxtimes_impl(std::string api_path, struct timespec *bkuptime, struct timespec *bkuptime,
struct timespec *crtime) -> api_error override; struct timespec *crtime)
-> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto init_impl(struct fuse_conn_info *conn, auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
struct fuse_config *cfg) -> void * override; -> void * override;
#else #else
auto init_impl(struct fuse_conn_info *conn) -> void * override; auto init_impl(struct fuse_conn_info *conn) -> void * override;
#endif #endif
[[nodiscard]] auto mkdir_impl(std::string api_path, [[nodiscard]] auto mkdir_impl(std::string api_path, mode_t mode)
mode_t mode) -> api_error override; -> api_error override;
void notify_fuse_main_exit(int &ret) override; void notify_fuse_main_exit(int &ret) override;
[[nodiscard]] auto [[nodiscard]] auto open_impl(std::string api_path,
open_impl(std::string api_path, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto opendir_impl(std::string api_path,
opendir_impl(std::string api_path, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
[[nodiscard]] auto read_impl(std::string api_path, char *buffer, [[nodiscard]] auto read_impl(std::string api_path, char *buffer,
size_t read_size, off_t read_offset, size_t read_size, off_t read_offset,
@@ -150,29 +156,30 @@ protected:
std::size_t &bytes_read) -> api_error override; std::size_t &bytes_read) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto [[nodiscard]] auto readdir_impl(std::string api_path, void *buf,
readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, fuse_fill_dir_t fuse_fill_dir, off_t offset,
off_t offset, struct fuse_file_info *f_info, struct fuse_file_info *f_info,
fuse_readdir_flags flags) -> api_error override; fuse_readdir_flags flags)
-> api_error override;
#else #else
[[nodiscard]] auto [[nodiscard]] auto readdir_impl(std::string api_path, void *buf,
readdir_impl(std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir, fuse_fill_dir_t fuse_fill_dir, off_t offset,
off_t offset, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#endif #endif
[[nodiscard]] auto [[nodiscard]] auto release_impl(std::string api_path,
release_impl(std::string api_path, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto releasedir_impl(std::string api_path,
releasedir_impl(std::string api_path, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto rename_impl(std::string from_api_path, [[nodiscard]] auto rename_impl(std::string from_api_path,
std::string to_api_path, std::string to_api_path, unsigned int flags)
unsigned int flags) -> api_error override; -> api_error override;
#else #else
[[nodiscard]] auto rename_impl(std::string from_api_path, [[nodiscard]] auto rename_impl(std::string from_api_path,
std::string to_api_path) -> api_error override; std::string to_api_path) -> api_error override;
@@ -181,58 +188,60 @@ protected:
[[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override; [[nodiscard]] auto rmdir_impl(std::string api_path) -> api_error override;
#if defined(__APPLE__) #if defined(__APPLE__)
[[nodiscard]] auto [[nodiscard]] auto setattr_x_impl(std::string api_path,
setattr_x_impl(std::string api_path, struct setattr_x *attr)
struct setattr_x *attr) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto setbkuptime_impl(std::string api_path,
setbkuptime_impl(std::string api_path, const struct timespec *bkuptime)
const struct timespec *bkuptime) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto setchgtime_impl(std::string api_path,
setchgtime_impl(std::string api_path, const struct timespec *chgtime)
const struct timespec *chgtime) -> api_error override; -> api_error override;
[[nodiscard]] auto [[nodiscard]] auto setcrtime_impl(std::string api_path,
setcrtime_impl(std::string api_path, const struct timespec *crtime)
const struct timespec *crtime) -> api_error override; -> api_error override;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto setvolname_impl(const char *volname)
setvolname_impl(const char *volname) -> api_error override; -> api_error override;
[[nodiscard]] auto statfs_x_impl(std::string api_path, [[nodiscard]] auto statfs_x_impl(std::string api_path, struct statfs *stbuf)
struct statfs *stbuf) -> api_error override; -> api_error override;
#else // __APPLE__ #else // __APPLE__
[[nodiscard]] auto statfs_impl(std::string api_path, [[nodiscard]] auto statfs_impl(std::string api_path, struct statvfs *stbuf)
struct statvfs *stbuf) -> api_error override; -> api_error override;
#endif // __APPLE__ #endif // __APPLE__
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto [[nodiscard]] auto truncate_impl(std::string api_path, off_t size,
truncate_impl(std::string api_path, off_t size, struct fuse_file_info *f_info)
struct fuse_file_info *f_info) -> api_error override; -> api_error override;
#else #else
[[nodiscard]] auto truncate_impl(std::string api_path, [[nodiscard]] auto truncate_impl(std::string api_path, off_t size)
off_t size) -> api_error override; -> api_error override;
#endif #endif
[[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override; [[nodiscard]] auto unlink_impl(std::string api_path) -> api_error override;
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
[[nodiscard]] auto [[nodiscard]] auto utimens_impl(std::string api_path,
utimens_impl(std::string api_path, const struct timespec tv[2], const struct timespec tv[2],
struct fuse_file_info *f_info) -> api_error override; struct fuse_file_info *f_info)
-> api_error override;
#else #else
[[nodiscard]] auto [[nodiscard]] auto utimens_impl(std::string api_path,
utimens_impl(std::string api_path, const struct timespec tv[2])
const struct timespec tv[2]) -> api_error override; -> api_error override;
#endif #endif
[[nodiscard]] auto [[nodiscard]] auto write_impl(std::string api_path, const char *buffer,
write_impl(std::string api_path, const char *buffer, size_t write_size, size_t write_size, off_t write_offset,
off_t write_offset, struct fuse_file_info *f_info, struct fuse_file_info *f_info,
std::size_t &bytes_written) -> api_error override; std::size_t &bytes_written)
-> api_error override;
}; };
} // namespace remote_fuse } // namespace remote_fuse
} // namespace repertory } // namespace repertory

View File

@@ -50,14 +50,13 @@ private:
[[nodiscard]] auto get_next_handle() -> std::uint64_t; [[nodiscard]] auto get_next_handle() -> std::uint64_t;
[[nodiscard]] auto populate_file_info(const std::string &api_path, [[nodiscard]] auto populate_file_info(const std::string &api_path,
remote::file_info &file_info) remote::file_info &r_info)
-> packet::error_type; -> packet::error_type;
void populate_file_info(const std::string &api_path, const UINT64 &file_size, void populate_file_info(const std::string &api_path, const UINT64 &file_size,
const UINT32 &attributes, const UINT32 &attributes, remote::file_info &r_info);
remote::file_info &file_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, [[nodiscard]] auto update_to_windows_format(const std::string &root_api_path,
json &item) -> json &; json &item) -> json &;
@@ -264,14 +263,14 @@ public:
[[nodiscard]] auto [[nodiscard]] auto
winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
UINT32 attributes, UINT64 /*allocation_size*/, PVOID *file_desc, 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; 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; -> packet::error_type override;
[[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto [[nodiscard]] auto
@@ -290,14 +289,14 @@ public:
[[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc, UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name) std::string &normalized_name)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, BOOLEAN replace_attributes,
UINT64 /*allocation_size*/, UINT64 /*allocation_size*/,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
@@ -316,11 +315,11 @@ public:
[[nodiscard]] auto winfsp_set_basic_info( [[nodiscard]] auto winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_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, [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_unmounted(const std::wstring &location) [[nodiscard]] auto winfsp_unmounted(const std::wstring &location)
@@ -329,7 +328,7 @@ public:
[[nodiscard]] auto [[nodiscard]] auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io, 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; -> packet::error_type override;
}; };
} // namespace remote_fuse } // namespace remote_fuse

View File

@@ -660,13 +660,13 @@ private:
remote::group_id gid{}; remote::group_id gid{};
DECODE_OR_RETURN(request, gid); DECODE_OR_RETURN(request, gid);
remote::stat st{}; remote::stat r_stat{};
bool directory = false; 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) { if (ret == 0) {
st.st_uid = uid; r_stat.st_uid = uid;
st.st_gid = gid; r_stat.st_gid = gid;
response.encode(st); response.encode(r_stat);
response.encode(static_cast<std::uint8_t>(directory)); response.encode(static_cast<std::uint8_t>(directory));
} }
@@ -733,13 +733,13 @@ private:
remote::group_id gid; remote::group_id gid;
DECODE_OR_RETURN(request, gid); DECODE_OR_RETURN(request, gid);
remote::stat st{}; remote::stat r_stat{};
bool directory = false; 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) { if (ret == 0) {
st.st_uid = uid; r_stat.st_uid = uid;
st.st_gid = gid; r_stat.st_gid = gid;
response.encode(st); response.encode(r_stat);
response.encode(static_cast<std::uint8_t>(directory)); response.encode(static_cast<std::uint8_t>(directory));
} }
return ret; return ret;
@@ -997,10 +997,10 @@ private:
std::uint64_t frsize{}; std::uint64_t frsize{};
DECODE_OR_RETURN(request, frsize); DECODE_OR_RETURN(request, frsize);
remote::statfs st{}; remote::statfs r_stat{};
ret = this->fuse_statfs(path.data(), frsize, st); ret = this->fuse_statfs(path.data(), frsize, r_stat);
if (ret == 0) { if (ret == 0) {
response.encode(st); response.encode(r_stat);
} }
return ret; return ret;
@@ -1016,10 +1016,10 @@ private:
std::uint64_t bsize{}; std::uint64_t bsize{};
DECODE_OR_RETURN(request, bsize); DECODE_OR_RETURN(request, bsize);
remote::statfs_x st{}; remote::statfs_x r_stat{};
ret = this->fuse_statfs_x(path.data(), bsize, st); ret = this->fuse_statfs_x(path.data(), bsize, r_stat);
if (ret == 0) { if (ret == 0) {
response.encode(st); response.encode(r_stat);
} }
return ret; return ret;
} }
@@ -1261,12 +1261,12 @@ private:
DECODE_OR_RETURN(request, allocation_size); DECODE_OR_RETURN(request, allocation_size);
BOOLEAN exists{0}; BOOLEAN exists{0};
remote::file_info file_info{}; remote::file_info r_info{};
std::string normalized_name; std::string normalized_name;
PVOID file_desc{}; PVOID file_desc{};
ret = this->winfsp_create(file_name.data(), create_options, granted_access, ret = this->winfsp_create(file_name.data(), create_options, granted_access,
attributes, allocation_size, &file_desc, attributes, allocation_size, &file_desc, &r_info,
&file_info, normalized_name, exists); normalized_name, exists);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
if (exists == 0U) { if (exists == 0U) {
#if defined(_WIN32) #if defined(_WIN32)
@@ -1279,7 +1279,7 @@ private:
} }
response.encode(file_desc); response.encode(file_desc);
response.encode(file_info); response.encode(r_info);
response.encode(normalized_name); response.encode(normalized_name);
response.encode(exists); response.encode(exists);
} }
@@ -1294,10 +1294,10 @@ private:
HANDLE file_desc{}; HANDLE file_desc{};
DECODE_OR_RETURN(request, file_desc); DECODE_OR_RETURN(request, file_desc);
remote::file_info file_info{}; remote::file_info r_info{};
ret = this->winfsp_flush(file_desc, &file_info); ret = this->winfsp_flush(file_desc, &r_info);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
response.encode(file_info); response.encode(r_info);
} }
return ret; return ret;
@@ -1311,10 +1311,10 @@ private:
HANDLE file_desc{}; HANDLE file_desc{};
DECODE_OR_RETURN(request, file_desc); DECODE_OR_RETURN(request, file_desc);
remote::file_info file_info{}; remote::file_info r_info{};
ret = this->winfsp_get_file_info(file_desc, &file_info); ret = this->winfsp_get_file_info(file_desc, &r_info);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
response.encode(file_info); response.encode(r_info);
} }
return ret; return ret;
} }
@@ -1394,11 +1394,11 @@ private:
UINT32 granted_access{}; UINT32 granted_access{};
DECODE_OR_RETURN(request, granted_access); DECODE_OR_RETURN(request, granted_access);
remote::file_info file_info{}; remote::file_info r_info{};
std::string normalized_name; std::string normalized_name;
PVOID file_desc{}; PVOID file_desc{};
ret = this->winfsp_open(file_name.data(), create_options, granted_access, 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 (ret == STATUS_SUCCESS) {
#if defined(_WIN32) #if defined(_WIN32)
this->set_client_id(file_desc, client_id); this->set_client_id(file_desc, client_id);
@@ -1408,7 +1408,7 @@ private:
client_id); client_id);
#endif // defined(_WIN32) #endif // defined(_WIN32)
response.encode(file_desc); response.encode(file_desc);
response.encode(file_info); response.encode(r_info);
response.encode(normalized_name); response.encode(normalized_name);
} }
@@ -1431,11 +1431,11 @@ private:
UINT64 allocation_size{}; UINT64 allocation_size{};
DECODE_OR_RETURN(request, 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, ret = this->winfsp_overwrite(file_desc, attributes, replace_attributes,
allocation_size, &file_info); allocation_size, &r_info);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
response.encode(file_info); response.encode(r_info);
} }
return ret; return ret;
} }
@@ -1536,12 +1536,12 @@ private:
UINT64 change_time{}; UINT64 change_time{};
DECODE_OR_RETURN(request, 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, ret = this->winfsp_set_basic_info(file_desc, attributes, creation_time,
last_access_time, last_write_time, last_access_time, last_write_time,
change_time, &file_info); change_time, &r_info);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
response.encode(file_info); response.encode(r_info);
} }
return ret; return ret;
} }
@@ -1560,11 +1560,11 @@ private:
BOOLEAN set_allocation_size{}; BOOLEAN set_allocation_size{};
DECODE_OR_RETURN(request, 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, ret = this->winfsp_set_file_size(file_desc, new_size, set_allocation_size,
&file_info); &r_info);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
response.encode(file_info); response.encode(r_info);
} }
return ret; return ret;
} }
@@ -1601,12 +1601,12 @@ private:
auto *buffer = request->current_pointer(); auto *buffer = request->current_pointer();
UINT32 bytes_transferred{0U}; 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, 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) { if (ret == STATUS_SUCCESS) {
response.encode(bytes_transferred); response.encode(bytes_transferred);
response.encode(file_info); response.encode(r_info);
} }
return ret; return ret;
} }

View File

@@ -66,7 +66,7 @@ public:
std::string &volume_label) const = 0; std::string &volume_label) const = 0;
[[nodiscard]] virtual auto populate_file_info(const std::string &api_path, [[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; -> api_error = 0;
}; };
} // namespace repertory } // namespace repertory

View File

@@ -42,19 +42,19 @@ public:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
UINT32 file_attributes, UINT64 allocation_size, 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) std::string &normalized_name, BOOLEAN &exists)
-> packet::error_type = 0; -> packet::error_type = 0;
[[nodiscard]] virtual auto winfsp_flush(PVOID file_desc, [[nodiscard]] virtual auto winfsp_flush(PVOID file_desc,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type = 0; -> packet::error_type = 0;
[[nodiscard]] virtual auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) [[nodiscard]] virtual auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type = 0; -> packet::error_type = 0;
[[nodiscard]] virtual auto winfsp_get_file_info(PVOID file_desc, [[nodiscard]] virtual auto winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type = 0; -> packet::error_type = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
@@ -73,13 +73,13 @@ public:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access, 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; std::string &normalized_name) -> packet::error_type = 0;
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
winfsp_overwrite(PVOID file_desc, UINT32 file_attributes, winfsp_overwrite(PVOID file_desc, UINT32 file_attributes,
BOOLEAN replace_file_attributes, UINT64 allocation_size, 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, [[nodiscard]] virtual auto winfsp_read(PVOID file_desc, PVOID buffer,
UINT64 offset, UINT32 length, UINT64 offset, UINT32 length,
@@ -100,12 +100,11 @@ public:
winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes, winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes,
UINT64 creation_time, UINT64 last_access_time, UINT64 creation_time, UINT64 last_access_time,
UINT64 last_write_time, UINT64 change_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, [[nodiscard]] virtual auto
UINT64 new_size, winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, BOOLEAN set_allocation_size, remote::file_info *r_info)
remote::file_info *file_info)
-> packet::error_type = 0; -> packet::error_type = 0;
[[nodiscard]] virtual auto winfsp_unmounted(const std::wstring &location) [[nodiscard]] virtual auto winfsp_unmounted(const std::wstring &location)
@@ -114,7 +113,7 @@ public:
[[nodiscard]] virtual auto [[nodiscard]] virtual auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io, 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; -> packet::error_type = 0;
}; };

View File

@@ -76,17 +76,17 @@ public:
[[nodiscard]] auto [[nodiscard]] auto
winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
UINT32 attributes, UINT64 allocation_size, PVOID *file_desc, 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; 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; -> packet::error_type override;
[[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) [[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_get_security_by_name( [[nodiscard]] auto winfsp_get_security_by_name(
@@ -103,14 +103,14 @@ public:
[[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc, UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name) std::string &normalized_name)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, BOOLEAN replace_attributes,
UINT64 allocation_size, UINT64 allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
@@ -129,11 +129,11 @@ public:
[[nodiscard]] auto winfsp_set_basic_info( [[nodiscard]] auto winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_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, [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_unmounted(const std::wstring &location) [[nodiscard]] auto winfsp_unmounted(const std::wstring &location)
@@ -142,7 +142,7 @@ public:
[[nodiscard]] auto [[nodiscard]] auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io, 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; -> packet::error_type override;
}; };
} // namespace remote_winfsp } // namespace remote_winfsp

View File

@@ -50,11 +50,11 @@ private:
[[nodiscard]] auto get_next_handle() -> std::uint64_t; [[nodiscard]] auto get_next_handle() -> std::uint64_t;
[[nodiscard]] auto populate_file_info(const std::string &api_path, [[nodiscard]] auto populate_file_info(const std::string &api_path,
remote::file_info &file_info) remote::file_info &r_info)
-> packet::error_type; -> packet::error_type;
void populate_stat(const char *path, bool directory, remote::stat &r_stat, void populate_stat(const char *path, bool directory, remote::stat &r_stat,
const struct _stat64 &unix_st); const struct _stat64 &u_stat);
public: public:
// FUSE Layer // FUSE Layer
@@ -249,17 +249,17 @@ public:
[[nodiscard]] auto [[nodiscard]] auto
winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
UINT32 attributes, UINT64 allocation_size, PVOID *file_desc, 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; 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; -> packet::error_type override;
[[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr) [[nodiscard]] auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_get_file_info(PVOID file_desc, [[nodiscard]] auto winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_get_security_by_name( [[nodiscard]] auto winfsp_get_security_by_name(
@@ -276,14 +276,14 @@ public:
[[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options, [[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc, UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name) std::string &normalized_name)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes, [[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, BOOLEAN replace_attributes,
UINT64 allocation_size, UINT64 allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, [[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
@@ -302,11 +302,11 @@ public:
[[nodiscard]] auto winfsp_set_basic_info( [[nodiscard]] auto winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_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, [[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type override; -> packet::error_type override;
[[nodiscard]] auto winfsp_unmounted(const std::wstring &location) [[nodiscard]] auto winfsp_unmounted(const std::wstring &location)
@@ -315,7 +315,7 @@ public:
[[nodiscard]] auto [[nodiscard]] auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io, 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; -> packet::error_type override;
}; };
} // namespace remote_winfsp } // namespace remote_winfsp

View File

@@ -70,9 +70,9 @@ private:
std::string mount_location_; std::string mount_location_;
private: 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: public:
auto CanDelete(PVOID file_node, PVOID file_desc, PWSTR file_name) 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, UINT64 allocation_size, PVOID *file_node, PVOID *file_desc,
OpenFileInfo *ofi) -> NTSTATUS override; 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; -> 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; -> NTSTATUS override;
auto GetSecurityByName(PWSTR file_name, PUINT32 attributes, auto GetSecurityByName(PWSTR file_name, PUINT32 attributes,
@@ -112,7 +112,7 @@ public:
auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes, auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size, 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, auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset,
ULONG length, PULONG bytes_transferred) -> NTSTATUS override; ULONG length, PULONG bytes_transferred) -> NTSTATUS override;
@@ -128,18 +128,17 @@ public:
auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes, auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes,
UINT64 creation_time, UINT64 last_access_time, UINT64 creation_time, UINT64 last_access_time,
UINT64 last_write_time, UINT64 change_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, 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; -> NTSTATUS override;
VOID Unmounted(PVOID host) override; VOID Unmounted(PVOID host) override;
auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset,
ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io,
PULONG bytes_transferred, FileInfo *file_info) PULONG bytes_transferred, FileInfo *f_info) -> NTSTATUS override;
-> NTSTATUS override;
void shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); } void shutdown() { ::GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); }

View File

@@ -78,7 +78,7 @@ private:
private: private:
[[nodiscard]] auto handle_error(std::string_view function_name, [[nodiscard]] auto handle_error(std::string_view function_name,
const std::string &api_path, api_error error, 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 bool raise_on_failure_only = false) const
-> NTSTATUS; -> NTSTATUS;
@@ -92,8 +92,8 @@ private:
void populate_file_info(std::uint64_t file_size, api_meta_map meta, void populate_file_info(std::uint64_t file_size, api_meta_map meta,
FSP_FSCTL_FILE_INFO &fi) const; FSP_FSCTL_FILE_INFO &fi) const;
static void set_file_info(remote::file_info &dest, static void set_file_info(remote::file_info &r_info,
const FSP_FSCTL_FILE_INFO &src); const FSP_FSCTL_FILE_INFO &f_info);
void stop_all(); void stop_all();
@@ -111,7 +111,7 @@ public:
UINT64 allocation_size, PVOID *file_node, PVOID *file_desc, UINT64 allocation_size, PVOID *file_node, PVOID *file_desc,
OpenFileInfo *ofi) -> NTSTATUS override; 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; -> NTSTATUS override;
[[nodiscard]] auto get_directory_item_count(const std::string &api_path) const [[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 [[nodiscard]] auto get_directory_items(const std::string &api_path) const
-> directory_item_list override; -> 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; -> NTSTATUS override;
[[nodiscard]] auto get_file_size(const std::string &api_path) const [[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, auto Overwrite(PVOID file_node, PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size, 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, [[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; -> api_error override;
auto Read(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, 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, auto SetBasicInfo(PVOID file_node, PVOID file_desc, UINT32 attributes,
UINT64 creation_time, UINT64 last_access_time, UINT64 creation_time, UINT64 last_access_time,
UINT64 last_write_time, UINT64 change_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, 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; -> NTSTATUS override;
VOID Unmounted(PVOID host) override; VOID Unmounted(PVOID host) override;
auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset, auto Write(PVOID file_node, PVOID file_desc, PVOID buffer, UINT64 offset,
ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io, ULONG length, BOOLEAN write_to_end, BOOLEAN constrained_io,
PULONG bytes_transferred, FileInfo *file_info) PULONG bytes_transferred, FileInfo *f_info) -> NTSTATUS override;
-> NTSTATUS override;
void shutdown(); void shutdown();

View File

@@ -120,13 +120,13 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int {
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi) auto fuse_base::chmod_(const char *path, mode_t mode,
-> int { struct fuse_file_info *f_info) -> int {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #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 #if FUSE_USE_VERSION >= 30
auto fuse_base::chown_(const char *path, uid_t uid, gid_t gid, 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #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 #endif // FUSE_USE_VERSION >= 30
auto fuse_base::create_(const char *path, mode_t mode, 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 */) { void fuse_base::destroy_impl(void * /* ptr */) {
if (not console_enabled_) { if (not foreground_) {
repertory::project_cleanup(); repertory::project_cleanup();
} }
} }
@@ -222,8 +222,8 @@ auto fuse_base::execute_callback(
std::string_view function_name, const char *path, std::string_view function_name, const char *path,
const std::function<api_error(std::string api_path)> &cb, const std::function<api_error(std::string api_path)> &cb,
bool disable_logging) -> int { bool disable_logging) -> int {
const auto api_path = utils::path::create_api_path(path ? path : ""); auto api_path = utils::path::create_api_path(path ? path : "");
const auto res = utils::from_api_error(cb(api_path)); auto res = utils::from_api_error(cb(api_path));
raise_fuse_event(function_name, api_path, res, disable_logging); raise_fuse_event(function_name, api_path, res, disable_logging);
return res; 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, 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { function_name, path, [&](std::string api_path) -> api_error {
return instance().fallocate_impl(std::move(api_path), mode, offset, return instance().fallocate_impl(std::move(api_path), mode, offset,
length, fi); length, f_info);
}); });
} }
#if FUSE_USE_VERSION < 30 #if FUSE_USE_VERSION < 30
auto fuse_base::fgetattr_(const char *path, struct stat *st, auto fuse_base::fgetattr_(const char *path, struct stat *u_stat,
struct fuse_file_info *fi) -> int { struct fuse_file_info *f_info) -> int {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #endif // FUSE_USE_VERSION < 30
#if defined(__APPLE__) #if defined(__APPLE__)
auto fuse_base::fsetattr_x_(const char *path, struct setattr_x *attr, 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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__) #endif // defined(__APPLE__)
auto fuse_base::fsync_(const char *path, int datasync, 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #if FUSE_USE_VERSION < 30
auto fuse_base::ftruncate_(const char *path, off_t size, 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #endif // FUSE_USE_VERSION < 30
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_base::getattr_(const char *path, struct stat *st, auto fuse_base::getattr_(const char *path, struct stat *u_stat,
struct fuse_file_info *fi) -> int { struct fuse_file_info *f_info) -> int {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #endif // FUSE_USE_VERSION >= 30
@@ -378,7 +378,7 @@ auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * {
return this; 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"); utils::error::raise_error(function_name, "failed to initialize repertory");
event_system::instance().raise<unmount_requested>(function_name); event_system::instance().raise<unmount_requested>(function_name);
repertory::project_cleanup(); 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 fuse_base::mount(std::vector<std::string> args) -> int {
auto ret = parse_args(args); auto res = parse_args(args);
if (ret == 0) { if (res != 0) {
std::vector<const char *> fuse_argv(args.size()); return res;
for (std::size_t i = 0u; i < args.size(); ++i) { }
fuse_argv[i] = args[i].c_str();
}
{ if (not foreground_ && not utils::collection::includes(args, "-f")) {
struct fuse_args fa = FUSE_ARGS_INIT( args.emplace_back("-f");
static_cast<int>(fuse_argv.size()), }
reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())));
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 #if FUSE_USE_VERSION >= 30
struct fuse_cmdline_opts opts{}; struct fuse_cmdline_opts opts{};
fuse_parse_cmdline(&fa, &opts); fuse_parse_cmdline(&f_args, &opts);
mount_location = opts.mountpoint; mount_location = opts.mountpoint;
#else // FUSE_USE_VERSION < 30 #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 #endif // FUSE_USE_VERSION >= 30
if (mount_location) { if (mount_location != nullptr) {
mount_location_ = mount_location; mount_location_ = mount_location;
free(mount_location); free(mount_location);
} mount_location = nullptr;
} }
}
notify_fuse_args_parsed(args); notify_fuse_args_parsed(args);
#if FUSE_USE_VERSION < 30 const auto main_func = [&]() -> int {
umask(0); auto ret = fuse_main(
#endif // FUSE_USE_VERSION < 30
if (not console_enabled_) {
repertory::project_cleanup();
}
ret = fuse_main(
static_cast<int>(fuse_argv.size()), static_cast<int>(fuse_argv.size()),
reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())), reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())),
&fuse_ops_, this); &fuse_ops_, this);
notify_fuse_main_exit(ret); 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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, 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(); REPERTORY_USES_FUNCTION_NAME();
std::size_t bytes_read{}; std::size_t bytes_read{};
const auto res = instance().execute_callback( auto res = instance().execute_callback(
function_name, path, function_name, path,
[&](std::string api_path) -> api_error { [&](std::string api_path) -> api_error {
return instance().read_impl(std::move(api_path), buffer, read_size, return instance().read_impl(std::move(api_path), buffer, read_size,
read_offset, fi, bytes_read); read_offset, f_info, bytes_read);
}, },
true); true);
return (res == 0) ? static_cast<int>(bytes_read) : res; 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 #if FUSE_USE_VERSION >= 30
auto fuse_base::readdir_(const char *path, void *buf, auto fuse_base::readdir_(const char *path, void *buf,
fuse_fill_dir_t fuse_fill_dir, off_t offset, 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,
-> int { fuse_readdir_flags flags) -> int {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { function_name, path, [&](std::string api_path) -> api_error {
return instance().readdir_impl(std::move(api_path), buf, fuse_fill_dir, return instance().readdir_impl(std::move(api_path), buf, fuse_fill_dir,
offset, fi, flags); offset, f_info, flags);
}); });
} }
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
auto fuse_base::readdir_(const char *path, void *buf, auto fuse_base::readdir_(const char *path, void *buf,
fuse_fill_dir_t fuse_fill_dir, off_t offset, 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { function_name, path, [&](std::string api_path) -> api_error {
return instance().readdir_impl(std::move(api_path), buf, fuse_fill_dir, return instance().readdir_impl(std::move(api_path), buf, fuse_fill_dir,
offset, fi); offset, f_info);
}); });
} }
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
auto fuse_base::release_(const char *path, struct fuse_file_info *fi) -> int { auto fuse_base::release_(const char *path, struct fuse_file_info *f_info)
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)
-> int { -> int {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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(); REPERTORY_USES_FUNCTION_NAME();
int attribute_size = 0; int attribute_size = 0;
const auto res = instance().execute_callback( auto res = instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { function_name, path, [&](std::string api_path) -> api_error {
return instance().getxattr_impl(std::move(api_path), name, value, size, return instance().getxattr_impl(std::move(api_path), name, value, size,
position, attribute_size); position, attribute_size);
@@ -578,7 +588,7 @@ auto fuse_base::getxattr_(const char *path, const char *name, char *value,
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
int attribute_size = 0; int attribute_size = 0;
const auto res = instance().execute_callback( auto res = instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { function_name, path, [&](std::string api_path) -> api_error {
return instance().getxattr_impl(std::move(api_path), name, value, size, return instance().getxattr_impl(std::move(api_path), name, value, size,
attribute_size); attribute_size);
@@ -594,7 +604,7 @@ auto fuse_base::listxattr_(const char *path, char *buffer, size_t size) -> int {
int required_size = 0; int required_size = 0;
bool return_size = false; bool return_size = false;
const auto res = instance().execute_callback( auto res = instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { function_name, path, [&](std::string api_path) -> api_error {
return instance().listxattr_impl(std::move(api_path), buffer, size, return instance().listxattr_impl(std::move(api_path), buffer, size,
required_size, return_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 fuse_base::parse_args(std::vector<std::string> &args) -> int {
auto force_no_console = false; auto force_no_console{false};
for (std::size_t i = 1u; !force_no_console && (i < args.size()); ++i) { for (std::size_t idx{1U}; !force_no_console && (idx < args.size()); ++idx) {
if (args[i] == "-nc") { if (args[idx] == "-nc") {
force_no_console = true; force_no_console = true;
console_enabled_ = false;
} }
} }
utils::collection::remove_element(args, "-nc"); utils::collection::remove_element(args, "-nc");
for (std::size_t i = 1u; i < args.size(); ++i) { for (std::size_t idx{1U}; idx < args.size(); ++idx) {
if (args[i] == "-f") { if (args[idx] == "-f") {
console_enabled_ = not force_no_console; foreground_ = true;
} else if (args[i].find("-o") == 0) { } else if (args[idx].starts_with("-o")) {
std::string options = ""; std::string options;
if (args[i].size() == 2u) { if (args[idx].size() == 2U) {
if ((i + 1) < args.size()) { if ((idx + 1) < args.size()) {
options = args[++i]; options = args[++idx];
} }
} else { } 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) { for (const auto &option : option_parts) {
if (option.find("gid") == 0) { if (option.starts_with("gid")) {
const auto parts = utils::string::split(option, '=', true); auto parts = utils::string::split(option, '=', true);
if (parts.size() == 2u) { if (parts.size() == 2U) {
auto gid = getgrnam(parts[1].c_str()); auto *gid = getgrnam(parts[1U].c_str());
if (not gid) { if (gid == nullptr) {
gid = getgrgid(utils::string::to_uint32(parts[1])); gid = getgrgid(utils::string::to_uint32(parts[1U]));
} }
if ((getgid() != 0) && (gid->gr_gid == 0)) { if ((getgid() != 0) && (gid->gr_gid == 0)) {
std::cerr << "'gid=0' requires running as root" << std::endl; std::cerr << "'gid=0' requires running as root" << std::endl;
return -1; 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; atime_enabled_ = false;
} else if (option.find("uid") == 0) { } else if (option.starts_with("uid")) {
const auto parts = utils::string::split(option, '=', true); auto parts = utils::string::split(option, '=', true);
if (parts.size() == 2u) { if (parts.size() == 2U) {
auto *uid = getpwnam(parts[1u].c_str()); auto *uid = getpwnam(parts[1U].c_str());
if (not uid) { if (uid == nullptr) {
uid = getpwuid(utils::string::to_uint32(parts[1])); uid = getpwuid(utils::string::to_uint32(parts[1]));
} }
if ((getuid() != 0) && (uid->pw_uid == 0)) { if ((getuid() != 0) && (uid->pw_uid == 0)) {
std::cerr << "'uid=0' requires running as root" << std::endl; std::cerr << "'uid=0' requires running as root" << std::endl;
return -1; return -1;
} else {
forced_uid_ = uid->pw_uid;
} }
forced_uid_ = uid->pw_uid;
} }
} else if (option.find("umask") == 0) { } else if (option.starts_with("umask")) {
const auto parts = utils::string::split(option, '=', true); auto parts = utils::string::split(option, '=', true);
if (parts.size() == 2u) { if (parts.size() == 2U) {
static const auto match_number_regex = std::regex("[0-9]+"); static const auto match_number_regex = std::regex("[0-9]+");
try { try {
if (not std::regex_match(parts[1], match_number_regex)) { if (not std::regex_match(parts[1], match_number_regex)) {
throw std::runtime_error("invalid syntax"); throw std::runtime_error("invalid syntax");
} else {
forced_umask_ = utils::string::to_uint32(parts[1]);
} }
forced_umask_ = utils::string::to_uint32(parts[1]);
} catch (...) { } catch (...) {
std::cerr << ("'" + option + "' invalid syntax") << std::endl; std::cerr << ("'" + option + "' invalid syntax") << std::endl;
return -1; 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 { size_t size, int flags, uint32_t position) -> int {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto res = instance().execute_callback( auto res = instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { function_name, path, [&](std::string api_path) -> api_error {
return instance().setxattr_impl(std::move(api_path), name, value, size, return instance().setxattr_impl(std::move(api_path), name, value, size,
flags, position); 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 { size_t size, int flags) -> int {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto res = instance().execute_callback( auto res = instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { function_name, path, [&](std::string api_path) -> api_error {
return instance().setxattr_impl(std::move(api_path), name, value, size, return instance().setxattr_impl(std::move(api_path), name, value, size,
flags); flags);
@@ -835,12 +846,12 @@ auto fuse_base::statfs_(const char *path, struct statvfs *stbuf) -> int {
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_base::truncate_(const char *path, off_t size, 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #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 { auto fuse_base::unmount(const std::string &mount_location) -> int {
#if defined(__APPLE__) #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__) #else // !defined(__APPLE__)
#if FUSE_USE_VERSION >= 30 #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 #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 // FUSE_USE_VERSION >= 30
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
@@ -879,12 +890,12 @@ auto fuse_base::unmount(const std::string &mount_location) -> int {
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto fuse_base::utimens_(const char *path, const struct timespec tv[2], 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(); REPERTORY_USES_FUNCTION_NAME();
return instance().execute_callback( return instance().execute_callback(
function_name, path, [&](std::string api_path) -> api_error { 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 #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 #endif // FUSE_USE_VERSION >= 30
auto fuse_base::write_(const char *path, const char *buffer, size_t write_size, 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(); REPERTORY_USES_FUNCTION_NAME();
std::size_t bytes_written{}; std::size_t bytes_written{};
const auto res = instance().execute_callback( auto res = instance().execute_callback(
function_name, path, function_name, path,
[&](std::string api_path) -> api_error { [&](std::string api_path) -> api_error {
return instance().write_impl(std::move(api_path), buffer, write_size, return instance().write_impl(std::move(api_path), buffer, write_size,
write_offset, fi, bytes_written); write_offset, f_info, bytes_written);
}, },
true); true);
return (res == 0) ? static_cast<int>(bytes_written) : res; return (res == 0) ? static_cast<int>(bytes_written) : res;

View File

@@ -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) {} : fuse_drive_base(config), lock_data_(lock_data), provider_(provider) {}
#if defined(__APPLE__) #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 check_and_perform(api_path, X_OK, [&](api_meta_map &) -> api_error {
return provider_.set_item_meta(api_path, META_OSXFLAGS, return provider_.set_item_meta(api_path, META_OSXFLAGS,
std::to_string(flags)); 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 #if FUSE_USE_VERSION >= 30
auto fuse_drive::chmod_impl(std::string api_path, mode_t mode, auto fuse_drive::chmod_impl(std::string api_path, mode_t mode,
struct fuse_file_info * /*file_info*/) struct fuse_file_info * /*f_info*/) -> api_error {
-> api_error {
#else // FUSE_USE_VERSION < 30 #else // FUSE_USE_VERSION < 30
auto fuse_drive::chmod_impl(std::string api_path, mode_t mode) -> api_error { auto fuse_drive::chmod_impl(std::string api_path, mode_t mode) -> api_error {
#endif // FUSE_USE_VERSION >= 30 #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 #if FUSE_USE_VERSION >= 30
auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid, auto fuse_drive::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 {
-> api_error {
#else #else
auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) auto fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid)
-> api_error { -> 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, auto fuse_drive::create_impl(std::string api_path, mode_t mode,
struct fuse_file_info *file_info) -> api_error { struct fuse_file_info *f_info) -> api_error {
file_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE); f_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE);
auto is_append_op = ((file_info->flags & O_APPEND) == O_APPEND); auto is_append_op = ((f_info->flags & O_APPEND) == O_APPEND);
auto is_create_op = ((file_info->flags & O_CREAT) == O_CREAT); auto is_create_op = ((f_info->flags & O_CREAT) == O_CREAT);
auto is_directory_op = ((file_info->flags & O_DIRECTORY) == O_DIRECTORY); auto is_directory_op = ((f_info->flags & O_DIRECTORY) == O_DIRECTORY);
auto is_exclusive = ((file_info->flags & O_EXCL) == O_EXCL); auto is_exclusive = ((f_info->flags & O_EXCL) == O_EXCL);
auto is_read_write_op = ((file_info->flags & O_RDWR) == O_RDWR); auto is_read_write_op = ((f_info->flags & O_RDWR) == O_RDWR);
auto is_truncate_op = ((file_info->flags & O_TRUNC) == O_TRUNC); auto is_truncate_op = ((f_info->flags & O_TRUNC) == O_TRUNC);
auto is_write_only_op = ((file_info->flags & O_WRONLY) == O_WRONLY); auto is_write_only_op = ((f_info->flags & O_WRONLY) == O_WRONLY);
if (is_create_op && is_append_op && is_truncate_op) { if (is_create_op && is_append_op && is_truncate_op) {
return api_error::invalid_operation; 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) { if (is_create_op) {
auto now = utils::time::get_time_now(); auto now = utils::time::get_time_now();
#if defined(__APPLE__) #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__) #else // !defined(__APPLE__)
auto osx_flags = 0U; auto osx_flags = 0U;
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
@@ -226,12 +225,12 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
{utils::create_uuid_string()}), {utils::create_uuid_string()}),
get_effective_uid(), now); 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)) { if ((res != api_error::item_exists) && (res != api_error::success)) {
return res; return res;
} }
} else { } 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); open_file);
if (res != api_error::success) { if (res != api_error::success) {
return res; 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 (is_truncate_op) {
#if FUSE_USE_VERSION >= 30 #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) { if (res != api_error::success) {
#else // FUSE_USE_VERSION < 30 #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) { if (res != api_error::success) {
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
fm_->close(handle); 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)); errno = std::abs(utils::from_api_error(res));
return 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, auto fuse_drive::fallocate_impl(std::string /*api_path*/, int mode,
off_t offset, off_t length, 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; 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; 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); api_error::invalid_handle);
if (res != api_error::success) { if (res != api_error::success) {
return res; 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); O_WRONLY | O_APPEND, api_error::invalid_handle);
if (res != api_error::success) { if (res != api_error::success) {
return res; 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); static_cast<std::uint64_t>(offset + length), allocator);
} }
auto fuse_drive::fgetattr_impl(std::string api_path, struct stat *unix_st, auto fuse_drive::fgetattr_impl(std::string api_path, struct stat *u_stat,
struct fuse_file_info *file_info) -> api_error { struct fuse_file_info *f_info) -> api_error {
std::shared_ptr<i_open_file> open_file; 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; 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, 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; return api_error::success;
} }
#if defined(__APPLE__) #if defined(__APPLE__)
auto fuse_drive::fsetattr_x_impl(std::string api_path, struct setattr_x *attr, auto fuse_drive::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 {
-> api_error {
std::shared_ptr<i_open_file> f; 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; 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__ #endif // __APPLE__
auto fuse_drive::fsync_impl(std::string /*api_path*/, int datasync, 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; 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; 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 #if FUSE_USE_VERSION < 30
api_error fuse_drive::ftruncate_impl(std::string /*api_path*/, off_t size, auto fuse_drive::ftruncate_impl(std::string /*api_path*/, off_t size,
struct fuse_file_info *file_info) { struct fuse_file_info *f_info) -> api_error {
std::shared_ptr<i_open_file> f; 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; return api_error::invalid_handle;
} }
auto res = check_writeable(f->get_open_data(file_info->fh), auto res =
api_error::invalid_handle); check_writeable(f->get_open_data(f_info->fh), api_error::invalid_handle);
if (res != api_error::success) { if (res != api_error::success) {
return res; return res;
} }
@@ -498,11 +496,10 @@ auto fuse_drive::get_item_meta(const std::string &api_path,
} }
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
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,
struct fuse_file_info * /*file_info*/) struct fuse_file_info * /*f_info*/) -> api_error {
-> api_error {
#else #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 { -> api_error {
#endif #endif
auto parent = utils::path::get_parent_api_path(api_path); 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( fuse_drive_base::populate_stat(
api_path, utils::string::to_uint64(meta[META_SIZE]), meta, 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; 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) auto fuse_drive::init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg)
-> void * { -> void * {
#else #else
void *fuse_drive::init_impl(struct fuse_conn_info *conn) { auto fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
#endif #endif
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -687,18 +684,18 @@ void fuse_drive::notify_fuse_main_exit(int &ret) {
console_consumer_.reset(); console_consumer_.reset();
} }
auto fuse_drive::open_impl(std::string api_path, auto fuse_drive::open_impl(std::string api_path, struct fuse_file_info *f_info)
struct fuse_file_info *file_info) -> api_error { -> api_error {
file_info->flags &= (~O_CREAT); f_info->flags &= (~O_CREAT);
return create_impl(api_path, 0, file_info); return create_impl(api_path, 0, f_info);
} }
auto fuse_drive::opendir_impl(std::string api_path, auto fuse_drive::opendir_impl(std::string api_path,
struct fuse_file_info *file_info) -> api_error { struct fuse_file_info *f_info) -> api_error {
file_info->fh = static_cast<std::uint64_t>(INVALID_HANDLE_VALUE); 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); auto res = check_access(api_path, mask);
if (res != api_error::success) { if (res != api_error::success) {
return res; return res;
@@ -718,8 +715,8 @@ auto fuse_drive::opendir_impl(std::string api_path,
return api_error::directory_not_found; return api_error::directory_not_found;
} }
if ((file_info->flags & O_APPEND) == O_APPEND || if ((f_info->flags & O_APPEND) == O_APPEND ||
(file_info->flags & O_EXCL) == O_EXCL) { (f_info->flags & O_EXCL) == O_EXCL) {
return api_error::directory_exists; 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)); auto iter = std::make_shared<directory_iterator>(std::move(list));
file_info->fh = fm_->get_next_handle(); f_info->fh = fm_->get_next_handle();
directory_cache_->set_directory(api_path, file_info->fh, iter); directory_cache_->set_directory(api_path, f_info->fh, iter);
return api_error::success; return api_error::success;
} }
auto fuse_drive::read_impl(std::string api_path, char *buffer, size_t read_size, 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::size_t &bytes_read) -> api_error {
std::shared_ptr<i_open_file> open_file; 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; return api_error::item_not_found;
} }
if (open_file->is_directory()) { if (open_file->is_directory()) {
return api_error::directory_exists; 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); api_error::invalid_handle);
if (res != api_error::success) { if (res != api_error::success) {
return res; 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 #if FUSE_USE_VERSION >= 30
auto fuse_drive::readdir_impl(std::string api_path, void *buf, auto fuse_drive::readdir_impl(std::string api_path, void *buf,
fuse_fill_dir_t fuse_fill_dir, off_t offset, 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 { fuse_readdir_flags /*flags*/) -> api_error {
#else #else
auto fuse_drive::readdir_impl(std::string api_path, void *buf, auto fuse_drive::readdir_impl(std::string api_path, void *buf,
fuse_fill_dir_t fuse_fill_dir, off_t offset, 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 #endif
auto res = check_access(api_path, X_OK); auto res = check_access(api_path, X_OK);
if (res != api_error::success) { if (res != api_error::success) {
return res; return res;
} }
auto iter = directory_cache_->get_directory(file_info->fh); auto iter = directory_cache_->get_directory(f_info->fh);
if (iter == nullptr) { if (iter == nullptr) {
return api_error::invalid_handle; 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, static_cast<remote::file_offset>(offset++), fuse_fill_dir, buf,
[this](const std::string &cur_api_path, [this](const std::string &cur_api_path,
std::uint64_t cur_file_size, const api_meta_map &meta, 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, fuse_drive_base::populate_stat(cur_api_path, cur_file_size, meta,
directory, provider_, unix_st); directory, provider_, u_stat);
}) == 0) }) == 0)
? api_error::success ? api_error::success
: api_error::os_error; : 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*/, auto fuse_drive::release_impl(std::string /*api_path*/,
struct fuse_file_info *file_info) -> api_error { struct fuse_file_info *f_info) -> api_error {
fm_->close(file_info->fh); fm_->close(f_info->fh);
return api_error::success; return api_error::success;
} }
auto fuse_drive::releasedir_impl(std::string /*api_path*/, auto fuse_drive::releasedir_impl(std::string /*api_path*/,
struct fuse_file_info *file_info) struct fuse_file_info *f_info) -> api_error {
-> api_error { auto iter = directory_cache_->get_directory(f_info->fh);
auto iter = directory_cache_->get_directory(file_info->fh);
if (iter == nullptr) { if (iter == nullptr) {
return api_error::invalid_handle; return api_error::invalid_handle;
} }
directory_cache_->remove_directory(file_info->fh); directory_cache_->remove_directory(f_info->fh);
return api_error::success; 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 #if FUSE_USE_VERSION >= 30
auto fuse_drive::truncate_impl(std::string api_path, off_t size, 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 { -> api_error {
#else #else
auto fuse_drive::truncate_impl(std::string api_path, off_t size) -> api_error { 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 #if FUSE_USE_VERSION >= 30
auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2], auto fuse_drive::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 {
-> api_error {
#else #else
auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2]) auto fuse_drive::utimens_impl(std::string api_path, const struct timespec tv[2])
-> api_error { -> 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*/ auto fuse_drive::write_impl(std::string /*api_path*/
, ,
const char *buffer, size_t write_size, const char *buffer, size_t write_size,
off_t write_offset, off_t write_offset, struct fuse_file_info *f_info,
struct fuse_file_info *file_info,
std::size_t &bytes_written) -> api_error { std::size_t &bytes_written) -> api_error {
std::shared_ptr<i_open_file> open_file; 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; return api_error::item_not_found;
} }
@@ -1421,14 +1415,14 @@ auto fuse_drive::write_impl(std::string /*api_path*/
return api_error::directory_exists; 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); api_error::invalid_handle);
if (res != api_error::success) { if (res != api_error::success) {
return res; return res;
} }
if (write_size > 0) { 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()); write_offset = static_cast<off_t>(open_file->get_file_size());
} }

View File

@@ -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, void fuse_drive_base::populate_stat(const std::string &api_path,
std::uint64_t size_or_count, std::uint64_t size_or_count,
const api_meta_map &meta, bool directory, const api_meta_map &meta, bool directory,
i_provider &provider, struct stat *st) { i_provider &provider, struct stat *u_stat) {
std::memset(st, 0, sizeof(struct stat)); std::memset(u_stat, 0, sizeof(struct stat));
st->st_nlink = static_cast<nlink_t>( u_stat->st_nlink = static_cast<nlink_t>(
directory ? 2 + (size_or_count == 0U directory ? 2 + (size_or_count == 0U
? provider.get_directory_item_count(api_path) ? provider.get_directory_item_count(api_path)
: size_or_count) : size_or_count)
: 1); : 1);
if (directory) { if (directory) {
st->st_blocks = 0; u_stat->st_blocks = 0;
} else { } 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_stat = static_cast<std::uint64_t>(512U);
static const auto block_size = static_cast<std::uint64_t>(4096U); static const auto block_size = static_cast<std::uint64_t>(4096U);
auto size = utils::divide_with_ceiling( 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; block_size;
st->st_blocks = static_cast<blkcnt_t>( u_stat->st_blocks = static_cast<blkcnt_t>(
std::max(block_size / block_size_stat, std::max(block_size / block_size_stat,
utils::divide_with_ceiling(size, block_size_stat))); utils::divide_with_ceiling(size, block_size_stat)));
} }
st->st_gid = get_gid_from_meta(meta); u_stat->st_gid = get_gid_from_meta(meta);
st->st_mode = (directory ? S_IFDIR : S_IFREG) | get_mode_from_meta(meta); u_stat->st_mode = (directory ? S_IFDIR : S_IFREG) | get_mode_from_meta(meta);
st->st_uid = get_uid_from_meta(meta); u_stat->st_uid = get_uid_from_meta(meta);
#if defined(__APPLE__) #if defined(__APPLE__)
st->st_blksize = 0; u_stat->st_blksize = 0;
st->st_flags = get_flags_from_meta(meta); 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_MODIFIED, u_stat->st_mtimespec);
set_timespec_from_meta(meta, META_CREATION, st->st_birthtimespec); set_timespec_from_meta(meta, META_CREATION, u_stat->st_birthtimespec);
set_timespec_from_meta(meta, META_CHANGED, st->st_ctimespec); set_timespec_from_meta(meta, META_CHANGED, u_stat->st_ctimespec);
set_timespec_from_meta(meta, META_ACCESSED, st->st_atimespec); set_timespec_from_meta(meta, META_ACCESSED, u_stat->st_atimespec);
#else // !defined(__APPLE__) #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_MODIFIED, u_stat->st_mtim);
set_timespec_from_meta(meta, META_CREATION, st->st_ctim); set_timespec_from_meta(meta, META_CREATION, u_stat->st_ctim);
set_timespec_from_meta(meta, META_ACCESSED, st->st_atim); set_timespec_from_meta(meta, META_ACCESSED, u_stat->st_atim);
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
} }

View File

@@ -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); 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, bool &directory,
const remote::file_handle &handle) const remote::file_handle &handle)
-> packet::error_type { -> packet::error_type {
@@ -124,7 +124,7 @@ auto remote_client::fuse_fgetattr(const char *path, remote::stat &st,
auto ret = auto ret =
packet_client_.send(function_name, request, response, service_flags); packet_client_.send(function_name, request, response, service_flags);
if (ret == 0) { if (ret == 0) {
if ((ret = response.decode(st)) == 0) { if ((ret = response.decode(r_stat)) == 0) {
std::uint8_t d{}; std::uint8_t d{};
if ((ret = response.decode(d)) == 0) { if ((ret = response.decode(d)) == 0) {
directory = static_cast<bool>(d); 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); 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 { bool &directory) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -193,7 +193,7 @@ auto remote_client::fuse_getattr(const char *path, remote::stat &st,
auto ret = auto ret =
packet_client_.send(function_name, request, response, service_flags); packet_client_.send(function_name, request, response, service_flags);
if (ret == 0) { if (ret == 0) {
if ((ret = response.decode(st)) == 0) { if ((ret = response.decode(r_stat)) == 0) {
std::uint8_t d = 0; std::uint8_t d = 0;
if ((ret = response.decode(d)) == 0) { if ((ret = response.decode(d)) == 0) {
directory = static_cast<bool>(d); 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, 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(); REPERTORY_USES_FUNCTION_NAME();
packet request; packet request;
@@ -619,14 +619,15 @@ auto remote_client::fuse_statfs(const char *path, std::uint64_t frsize,
auto ret = auto ret =
packet_client_.send(function_name, request, response, service_flags); packet_client_.send(function_name, request, response, service_flags);
if (ret == 0) { if (ret == 0) {
ret = response.decode(st); ret = response.decode(r_stat);
} }
return ret; return ret;
} }
auto remote_client::fuse_statfs_x(const char *path, std::uint64_t bsize, 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(); REPERTORY_USES_FUNCTION_NAME();
packet request; packet request;
@@ -638,7 +639,7 @@ auto remote_client::fuse_statfs_x(const char *path, std::uint64_t bsize,
auto ret = auto ret =
packet_client_.send(function_name, request, response, service_flags); packet_client_.send(function_name, request, response, service_flags);
if (ret == 0) { if (ret == 0) {
ret = response.decode(st); ret = response.decode(r_stat);
} }
return ret; return ret;

View File

@@ -19,7 +19,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#include <memory>
#if !defined(_WIN32) #if !defined(_WIN32)
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp" #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); fuse_base::destroy_impl(ptr);
} }
auto remote_fuse_drive::fgetattr_impl(std::string api_path, auto remote_fuse_drive::fgetattr_impl(std::string api_path, struct stat *u_stat,
struct stat *unix_st,
struct fuse_file_info *f_info) struct fuse_file_info *f_info)
-> api_error { -> api_error {
remote::stat r_stat{}; 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, auto res = remote_instance_->fuse_fgetattr(api_path.c_str(), r_stat,
directory, f_info->fh); directory, f_info->fh);
if (res == 0) { if (res == 0) {
populate_stat(r_stat, directory, *unix_st); populate_stat(r_stat, directory, *u_stat);
} }
return utils::to_api_error(res); 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 #endif // FUSE_USE_VERSION < 30
#if 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*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else // FUSE_USE_VERSION < 30 #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 { -> api_error {
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
bool directory = false; bool directory = false;
@@ -195,7 +193,7 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
auto res = auto res =
remote_instance_->fuse_getattr(api_path.c_str(), r_stat, directory); remote_instance_->fuse_getattr(api_path.c_str(), r_stat, directory);
if (res == 0) { if (res == 0) {
populate_stat(r_stat, directory, *unix_st); populate_stat(r_stat, directory, *u_stat);
} }
return utils::to_api_error(res); 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, void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
bool directory, struct stat &unix_st) { bool directory, struct stat &u_stat) {
std::memset(&unix_st, 0, sizeof(struct stat)); std::memset(&u_stat, 0, sizeof(struct stat));
unix_st.st_blksize = u_stat.st_blksize =
static_cast<decltype(unix_st.st_blksize)>(r_stat.st_blksize); static_cast<decltype(u_stat.st_blksize)>(r_stat.st_blksize);
unix_st.st_blocks = u_stat.st_blocks = static_cast<decltype(u_stat.st_blocks)>(r_stat.st_blocks);
static_cast<decltype(unix_st.st_blocks)>(r_stat.st_blocks); u_stat.st_gid = r_stat.st_gid;
unix_st.st_gid = r_stat.st_gid; u_stat.st_mode = (directory ? S_IFDIR : S_IFREG) | r_stat.st_mode;
unix_st.st_mode = (directory ? S_IFDIR : S_IFREG) | r_stat.st_mode; u_stat.st_nlink = r_stat.st_nlink;
unix_st.st_nlink = r_stat.st_nlink; u_stat.st_size = static_cast<decltype(u_stat.st_size)>(r_stat.st_size);
unix_st.st_size = static_cast<decltype(unix_st.st_size)>(r_stat.st_size); u_stat.st_uid = r_stat.st_uid;
unix_st.st_uid = r_stat.st_uid;
#if defined(__APPLE__) #if defined(__APPLE__)
unix_st.st_atimespec.tv_nsec = u_stat.st_atimespec.tv_nsec =
r_stat.st_atimespec % utils::time::NANOS_PER_SECOND; 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; 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; 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; 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; 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; 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; 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; 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__) #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); 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); 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); 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); 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); 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); r_stat.st_mtimespec / utils::time::NANOS_PER_SECOND);
#endif // defined(__APPLE__) #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)); std::memset(p_stat.get(), 0, sizeof(struct stat));
if (item_path == ".") { if (item_path == ".") {
#if FUSE_USE_VERSION >= 30 #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 #else // FUSE_USE_VERSION < 30
stat_res = getattr_impl(api_path, p_stat.get()); stat_res = getattr_impl(api_path, p_stat.get());
#endif // FUSE_USE_VERSION >= 30 #endif // FUSE_USE_VERSION >= 30
@@ -538,17 +535,18 @@ api_error remote_fuse_drive::statfs_x_impl(std::string api_path,
struct statfs *stbuf) { struct statfs *stbuf) {
auto res = statfs(config_.get_data_directory().c_str(), stbuf); auto res = statfs(config_.get_data_directory().c_str(), stbuf);
if (res == 0) { if (res == 0) {
remote::statfs_x r{}; remote::statfs_x r_stat{};
if ((res = remote_instance_->fuse_statfs_x(api_path.c_str(), stbuf->f_bsize, res = remote_instance_->fuse_statfs_x(api_path.c_str(), stbuf->f_bsize,
r)) == 0) { r_stat);
stbuf->f_blocks = r.f_blocks; if (res == 0) {
stbuf->f_bavail = r.f_bavail; stbuf->f_blocks = r_stat.f_blocks;
stbuf->f_bfree = r.f_bfree; stbuf->f_bavail = r_stat.f_bavail;
stbuf->f_ffree = r.f_ffree; stbuf->f_bfree = r_stat.f_bfree;
stbuf->f_files = r.f_files; stbuf->f_ffree = r_stat.f_ffree;
stbuf->f_files = r_stat.f_files;
stbuf->f_owner = getuid(); stbuf->f_owner = getuid();
strncpy(&stbuf->f_mntonname[0U], get_mount_location().c_str(), MNAMELEN); 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 { } else {
res = -errno; res = -errno;

View File

@@ -80,7 +80,7 @@ auto remote_server::get_next_handle() -> std::uint64_t {
} }
auto remote_server::populate_file_info(const std::string &api_path, auto remote_server::populate_file_info(const std::string &api_path,
remote::file_info &file_info) remote::file_info &r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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 attributes = utils::string::to_uint32(meta_attributes);
auto file_size = directory ? 0U : drive_.get_file_size(api_path); 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; 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, void remote_server::populate_file_info(const std::string &api_path,
const UINT64 &file_size, const UINT64 &file_size,
const UINT32 &attributes, const UINT32 &attributes,
remote::file_info &file_info) { remote::file_info &r_info) {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
api_meta_map meta{}; 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, utils::error::raise_api_path_error(function_name, api_path, res,
"get item meta failed"); "get item meta failed");
} }
file_info.AllocationSize = r_info.AllocationSize =
utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) * utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) *
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]))); 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]))); utils::string::to_uint64(empty_as_zero(meta[META_CREATION])));
file_info.EaSize = 0; r_info.EaSize = 0;
file_info.FileAttributes = attributes; r_info.FileAttributes = attributes;
file_info.FileSize = file_size; r_info.FileSize = file_size;
file_info.HardLinks = 0; r_info.HardLinks = 0;
file_info.IndexNumber = 0; r_info.IndexNumber = 0;
file_info.LastAccessTime = utils::time::unix_time_to_windows_time( r_info.LastAccessTime = utils::time::unix_time_to_windows_time(
utils::string::to_uint64(empty_as_zero(meta[META_ACCESSED]))); 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]))); utils::string::to_uint64(empty_as_zero(meta[META_WRITTEN])));
if (meta[META_WRITTEN].empty() || (meta[META_WRITTEN] == "0") || if (meta[META_WRITTEN].empty() || (meta[META_WRITTEN] == "0") ||
(meta[META_WRITTEN] == "116444736000000000")) { (meta[META_WRITTEN] == "116444736000000000")) {
drive_.set_item_meta(api_path, META_WRITTEN, meta[META_MODIFIED]); 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) { remote::stat &r_stat) {
r_stat = {}; r_stat = {};
#if defined(__APPLE__) #if defined(__APPLE__)
r_stat.st_flags = unix_st.st_flags; r_stat.st_flags = u_stat.st_flags;
r_stat.st_atimespec = r_stat.st_atimespec =
unix_st.st_atimespec.tv_nsec + u_stat.st_atimespec.tv_nsec +
(unix_st.st_atimespec.tv_sec * utils::time::NANOS_PER_SECOND); (u_stat.st_atimespec.tv_sec * utils::time::NANOS_PER_SECOND);
r_stat.st_birthtimespec = r_stat.st_birthtimespec =
unix_st.st_birthtimespec.tv_nsec + u_stat.st_birthtimespec.tv_nsec +
(unix_st.st_birthtimespec.tv_sec * utils::time::NANOS_PER_SECOND); (u_stat.st_birthtimespec.tv_sec * utils::time::NANOS_PER_SECOND);
r_stat.st_ctimespec = r_stat.st_ctimespec =
unix_st.st_ctimespec.tv_nsec + u_stat.st_ctimespec.tv_nsec +
(unix_st.st_ctimespec.tv_sec * utils::time::NANOS_PER_SECOND); (u_stat.st_ctimespec.tv_sec * utils::time::NANOS_PER_SECOND);
r_stat.st_mtimespec = r_stat.st_mtimespec =
unix_st.st_mtimespec.tv_nsec + u_stat.st_mtimespec.tv_nsec +
(unix_st.st_mtimespec.tv_sec * utils::time::NANOS_PER_SECOND); (u_stat.st_mtimespec.tv_sec * utils::time::NANOS_PER_SECOND);
#else // !defined(__APPLE__) #else // !defined(__APPLE__)
r_stat.st_flags = 0; r_stat.st_flags = 0;
r_stat.st_atimespec = r_stat.st_atimespec = static_cast<remote::file_time>(u_stat.st_atim.tv_nsec) +
static_cast<remote::file_time>(unix_st.st_atim.tv_nsec) + (static_cast<remote::file_time>(u_stat.st_atim.tv_sec) *
(static_cast<remote::file_time>(unix_st.st_atim.tv_sec) * utils::time::NANOS_PER_SECOND);
utils::time::NANOS_PER_SECOND);
r_stat.st_birthtimespec = r_stat.st_birthtimespec =
static_cast<remote::file_time>(unix_st.st_ctim.tv_nsec) + static_cast<remote::file_time>(u_stat.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_sec) *
utils::time::NANOS_PER_SECOND); utils::time::NANOS_PER_SECOND);
r_stat.st_ctimespec = r_stat.st_ctimespec = static_cast<remote::file_time>(u_stat.st_ctim.tv_nsec) +
static_cast<remote::file_time>(unix_st.st_ctim.tv_nsec) + (static_cast<remote::file_time>(u_stat.st_ctim.tv_sec) *
(static_cast<remote::file_time>(unix_st.st_ctim.tv_sec) * utils::time::NANOS_PER_SECOND);
utils::time::NANOS_PER_SECOND);
r_stat.st_mtimespec = r_stat.st_mtimespec = static_cast<remote::file_time>(u_stat.st_mtim.tv_nsec) +
static_cast<remote::file_time>(unix_st.st_mtim.tv_nsec) + (static_cast<remote::file_time>(u_stat.st_mtim.tv_sec) *
(static_cast<remote::file_time>(unix_st.st_mtim.tv_sec) * utils::time::NANOS_PER_SECOND);
utils::time::NANOS_PER_SECOND);
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
r_stat.st_blksize = static_cast<remote::block_size>(unix_st.st_blksize); r_stat.st_blksize = static_cast<remote::block_size>(u_stat.st_blksize);
r_stat.st_blocks = static_cast<remote::block_count>(unix_st.st_blocks); r_stat.st_blocks = static_cast<remote::block_count>(u_stat.st_blocks);
r_stat.st_gid = unix_st.st_gid; r_stat.st_gid = u_stat.st_gid;
r_stat.st_mode = static_cast<remote::file_mode>(unix_st.st_mode); r_stat.st_mode = static_cast<remote::file_mode>(u_stat.st_mode);
r_stat.st_nlink = static_cast<remote::file_nlink>(unix_st.st_nlink); r_stat.st_nlink = static_cast<remote::file_nlink>(u_stat.st_nlink);
r_stat.st_size = static_cast<remote::file_size>(unix_st.st_size); r_stat.st_size = static_cast<remote::file_size>(u_stat.st_size);
r_stat.st_uid = unix_st.st_uid; r_stat.st_uid = u_stat.st_uid;
} }
auto remote_server::fuse_access(const char *path, const std::int32_t &mask) 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); auto res = has_open_info(static_cast<native_handle>(handle), EBADF);
if (res == 0) { if (res == 0) {
directory = utils::file::directory(file_path).exists(); directory = utils::file::directory(file_path).exists();
struct stat64 unix_st{}; struct stat64 u_stat{};
res = fstat64(static_cast<native_handle>(handle), &unix_st); res = fstat64(static_cast<native_handle>(handle), &u_stat);
if (res == 0) { 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(); directory = utils::file::directory(file_path).exists();
struct stat64 unix_st{}; struct stat64 u_stat{};
auto res = stat64(file_path.c_str(), &unix_st); auto res = stat64(file_path.c_str(), &u_stat);
if (res == 0) { if (res == 0) {
populate_stat(unix_st, r_stat); populate_stat(u_stat, r_stat);
} }
auto ret = ((res < 0) ? -errno : 0); 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, auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, UINT32 attributes, UINT32 granted_access, UINT32 attributes,
UINT64 /*allocation_size*/, PVOID *file_desc, UINT64 /*allocation_size*/, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name, BOOLEAN &exists) std::string &normalized_name, BOOLEAN &exists)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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, drive_.set_item_meta(construct_api_path(file_path), META_ATTRIBUTES,
std::to_string(attributes)); std::to_string(attributes));
set_open_info(res, open_info{ set_open_info(res, open_info{
"", .client_id = "",
nullptr, .directory_buffer = nullptr,
{}, .handles = {},
file_path, .path = file_path,
}); });
auto api_path = utils::path::create_api_path(relative_path); auto api_path = utils::path::create_api_path(relative_path);
normalized_name = utils::string::replace_copy(api_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>( ret = static_cast<packet::error_type>(
@@ -1176,7 +1173,7 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
return 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 { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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)) utils::unix_error_to_windows(errno))
: populate_file_info(construct_api_path(get_open_file_path( : populate_file_info(construct_api_path(get_open_file_path(
static_cast<native_handle>(handle))), static_cast<native_handle>(handle))),
*file_info); *r_info);
} }
RAISE_REMOTE_FUSE_SERVER_EVENT( 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, auto remote_server::winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -1209,7 +1206,7 @@ auto remote_server::winfsp_get_file_info(PVOID file_desc,
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
ret = populate_file_info(construct_api_path(get_open_file_path( ret = populate_file_info(construct_api_path(get_open_file_path(
static_cast<native_handle>(handle))), static_cast<native_handle>(handle))),
*file_info); *r_info);
} }
RAISE_REMOTE_FUSE_SERVER_EVENT( RAISE_REMOTE_FUSE_SERVER_EVENT(
@@ -1229,10 +1226,10 @@ auto remote_server::winfsp_get_security_by_name(
if (utils::file::file(file_path).exists() || if (utils::file::file(file_path).exists() ||
(utils::file::directory(file_path).exists())) { (utils::file::directory(file_path).exists())) {
if (attributes) { if (attributes) {
remote::file_info file_info{}; remote::file_info r_info{};
if ((ret = populate_file_info(construct_api_path(file_path), if ((ret = populate_file_info(construct_api_path(file_path), r_info)) ==
file_info)) == STATUS_SUCCESS) { STATUS_SUCCESS) {
*attributes = file_info.FileAttributes; *attributes = r_info.FileAttributes;
} }
} }
} else { } 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, auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc, UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name) std::string &normalized_name)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -1286,15 +1283,15 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
if (res >= 0) { if (res >= 0) {
*file_desc = reinterpret_cast<PVOID>(res); *file_desc = reinterpret_cast<PVOID>(res);
set_open_info(res, open_info{ set_open_info(res, open_info{
"", .client_id = "",
nullptr, .directory_buffer = nullptr,
{}, .handles = {},
file_path, .path = file_path,
}); });
auto api_path = utils::path::create_api_path(relative_path); auto api_path = utils::path::create_api_path(relative_path);
normalized_name = utils::string::replace_copy(api_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) { if (res != STATUS_SUCCESS) {
utils::error::raise_error(function_name, utils::error::raise_error(function_name,
"populate file info failed|err|" + "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, auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, BOOLEAN replace_attributes,
UINT64 /*allocation_size*/, UINT64 /*allocation_size*/,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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( ret = populate_file_info(construct_api_path(get_open_file_path(
static_cast<native_handle>(handle))), static_cast<native_handle>(handle))),
*file_info); *r_info);
} else { } else {
ret = ret =
static_cast<packet::error_type>(utils::unix_error_to_windows(errno)); 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( auto remote_server::winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_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(); REPERTORY_USES_FUNCTION_NAME();
auto handle = reinterpret_cast<remote::file_handle>(file_desc); 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))); 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( 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, auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -1562,7 +1559,7 @@ auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
if (ret == 0) { if (ret == 0) {
ret = populate_file_info(construct_api_path(get_open_file_path( ret = populate_file_info(construct_api_path(get_open_file_path(
static_cast<native_handle>(handle))), 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, UINT32 length, BOOLEAN write_to_end,
BOOLEAN constrained_io, BOOLEAN constrained_io,
PUINT32 bytes_transferred, PUINT32 bytes_transferred,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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); *bytes_transferred = static_cast<UINT32>(res);
ret = populate_file_info(construct_api_path(get_open_file_path( ret = populate_file_info(construct_api_path(get_open_file_path(
static_cast<native_handle>(handle))), static_cast<native_handle>(handle))),
*file_info); *r_info);
} else { } else {
ret = static_cast<packet::error_type>( ret = static_cast<packet::error_type>(
utils::unix_error_to_windows(errno)); utils::unix_error_to_windows(errno));

View File

@@ -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, auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, UINT32 attributes, UINT32 granted_access, UINT32 attributes,
UINT64 allocation_size, PVOID *file_desc, UINT64 allocation_size, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name, BOOLEAN &exists) std::string &normalized_name, BOOLEAN &exists)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -192,7 +192,7 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options,
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
HANDLE handle{}; HANDLE handle{};
DECODE_OR_IGNORE(&response, 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, normalized_name);
DECODE_OR_IGNORE(&response, exists); 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); *file_desc = reinterpret_cast<PVOID>(handle);
set_open_info(to_handle(*file_desc), set_open_info(to_handle(*file_desc),
open_info{ open_info{
"", .client_id = "",
nullptr, .directory_buffer = nullptr,
{}, .handles = {},
utils::string::to_utf8(file_name), .path = utils::string::to_utf8(file_name),
}); });
} }
} }
@@ -211,7 +211,7 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options,
return ret; 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 { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -223,7 +223,7 @@ auto remote_client::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
auto ret{ auto ret{
packet_client_.send(function_name, request, response, service_flags), packet_client_.send(function_name, request, response, service_flags),
}; };
DECODE_OR_IGNORE(&response, *file_info); DECODE_OR_IGNORE(&response, *r_info);
return ret; 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, auto remote_client::winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -253,7 +253,7 @@ auto remote_client::winfsp_get_file_info(PVOID file_desc,
auto ret{ auto ret{
packet_client_.send(function_name, request, response, service_flags), packet_client_.send(function_name, request, response, service_flags),
}; };
DECODE_OR_IGNORE(&response, *file_info); DECODE_OR_IGNORE(&response, *r_info);
return ret; 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, auto remote_client::winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc, UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name) std::string &normalized_name)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -350,7 +350,7 @@ auto remote_client::winfsp_open(PWSTR file_name, UINT32 create_options,
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
HANDLE handle{}; HANDLE handle{};
DECODE_OR_IGNORE(&response, 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, normalized_name);
if (ret == STATUS_SUCCESS) { 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, auto remote_client::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, BOOLEAN replace_attributes,
UINT64 allocation_size, UINT64 allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -386,7 +386,7 @@ auto remote_client::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
auto ret{ auto ret{
packet_client_.send(function_name, request, response, service_flags), packet_client_.send(function_name, request, response, service_flags),
}; };
DECODE_OR_IGNORE(&response, *file_info); DECODE_OR_IGNORE(&response, *r_info);
return ret; return ret;
} }
@@ -457,7 +457,7 @@ auto remote_client::winfsp_rename(PVOID file_desc, PWSTR file_name,
auto remote_client::winfsp_set_basic_info( auto remote_client::winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_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(); REPERTORY_USES_FUNCTION_NAME();
packet request; packet request;
@@ -473,14 +473,14 @@ auto remote_client::winfsp_set_basic_info(
auto ret{ auto ret{
packet_client_.send(function_name, request, response, service_flags), packet_client_.send(function_name, request, response, service_flags),
}; };
DECODE_OR_IGNORE(&response, *file_info); DECODE_OR_IGNORE(&response, *r_info);
return ret; return ret;
} }
auto remote_client::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, auto remote_client::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -494,7 +494,7 @@ auto remote_client::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
auto ret{ auto ret{
packet_client_.send(function_name, request, response, service_flags), packet_client_.send(function_name, request, response, service_flags),
}; };
DECODE_OR_IGNORE(&response, *file_info); DECODE_OR_IGNORE(&response, *r_info);
return ret; return ret;
} }
@@ -525,7 +525,7 @@ auto remote_client::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
UINT32 length, BOOLEAN write_to_end, UINT32 length, BOOLEAN write_to_end,
BOOLEAN constrained_io, BOOLEAN constrained_io,
PUINT32 bytes_transferred, PUINT32 bytes_transferred,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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), packet_client_.send(function_name, request, response, service_flags),
}; };
DECODE_OR_IGNORE(&response, *bytes_transferred); DECODE_OR_IGNORE(&response, *bytes_transferred);
DECODE_OR_IGNORE(&response, *file_info); DECODE_OR_IGNORE(&response, *r_info);
return ret; return ret;
} }

View File

@@ -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, auto remote_server::populate_file_info(const std::string &api_path,
remote::file_info &file_info) remote::file_info &r_info)
-> packet::error_type { -> 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_SUCCESS
: STATUS_OBJECT_NAME_NOT_FOUND; : STATUS_OBJECT_NAME_NOT_FOUND;
} }
void remote_server::populate_stat(const char *path, bool directory, void remote_server::populate_stat(const char *path, bool directory,
remote::stat &r_stat, remote::stat &r_stat,
const struct _stat64 &unix_st) { const struct _stat64 &u_stat) {
r_stat.st_nlink = static_cast<remote::file_nlink>( r_stat.st_nlink = static_cast<remote::file_nlink>(
directory ? 2 + drive_.get_directory_item_count( directory ? 2 + drive_.get_directory_item_count(
utils::path::create_api_path(path)) utils::path::create_api_path(path))
: 1); : 1);
r_stat.st_atimespec = 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 = 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 = 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 = r_stat.st_mtimespec =
utils::time::windows_time_t_to_unix_time(unix_st.st_mtime); utils::time::windows_time_t_to_unix_time(u_stat.st_mtime);
r_stat.st_size = static_cast<remote::file_size>(unix_st.st_size); r_stat.st_size = static_cast<remote::file_size>(u_stat.st_size);
r_stat.st_mode = unix_st.st_mode; r_stat.st_mode = u_stat.st_mode;
} }
// FUSE Layer // FUSE Layer
@@ -188,10 +188,10 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat,
}; };
if (res == 0) { if (res == 0) {
directory = utils::file::directory(file_path).exists(); directory = utils::file::directory(file_path).exists();
struct _stat64 unix_st{}; struct _stat64 u_stat{};
res = _fstat64(static_cast<int>(handle), &unix_st); res = _fstat64(static_cast<int>(handle), &u_stat);
if (res == 0) { 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; 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 { bool &directory) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
r_st = {}; r_stat = {};
auto file_path = construct_path(path); 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), _stat64(file_path.c_str(), &st1),
}; };
if (res == 0) { if (res == 0) {
populate_stat(path, directory, r_st, st1); populate_stat(path, directory, r_stat, st1);
} }
auto ret = ((res < 0) ? -errno : 0); 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, auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, UINT32 attributes, UINT32 granted_access, UINT32 attributes,
UINT64 /*allocation_size*/, PVOID *file_desc, UINT64 /*allocation_size*/, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name, BOOLEAN &exists) std::string &normalized_name, BOOLEAN &exists)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -1006,17 +1006,16 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
}); });
} }
auto ret = auto ret = (handle == INVALID_HANDLE_VALUE)
(handle == INVALID_HANDLE_VALUE) ? FspNtStatusFromWin32(::GetLastError())
? FspNtStatusFromWin32(::GetLastError()) : populate_file_info(
: populate_file_info(construct_api_path(get_open_file_path(handle)), construct_api_path(get_open_file_path(handle)), *r_info);
*file_info);
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name,
utils::string::to_utf8(file_path), ret); utils::string::to_utf8(file_path), ret);
return 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 { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -1027,7 +1026,7 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
: FspNtStatusFromWin32(::GetLastError()); : FspNtStatusFromWin32(::GetLastError());
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
ret = populate_file_info(construct_api_path(get_open_file_path(handle)), 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, auto remote_server::winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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); auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
ret = populate_file_info(construct_api_path(get_open_file_path(handle)), 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), RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, get_open_file_path(file_desc),
ret); 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, auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc, UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *r_info,
std::string &normalized_name) std::string &normalized_name)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -1145,11 +1144,10 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
}); });
} }
auto ret = auto ret = (handle == INVALID_HANDLE_VALUE)
(handle == INVALID_HANDLE_VALUE) ? FspNtStatusFromWin32(::GetLastError())
? FspNtStatusFromWin32(::GetLastError()) : populate_file_info(
: populate_file_info(construct_api_path(get_open_file_path(handle)), construct_api_path(get_open_file_path(handle)), *r_info);
*file_info);
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name,
utils::string::to_utf8(file_path), ret); utils::string::to_utf8(file_path), ret);
return 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, auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, BOOLEAN replace_attributes,
UINT64 /*allocation_size*/, UINT64 /*allocation_size*/,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -1187,13 +1185,12 @@ auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes,
if (ret == STATUS_SUCCESS) { if (ret == STATUS_SUCCESS) {
FILE_ALLOCATION_INFO allocationInfo{}; FILE_ALLOCATION_INFO allocationInfo{};
ret = ret = ::SetFileInformationByHandle(handle, FileAllocationInfo,
::SetFileInformationByHandle(handle, FileAllocationInfo, &allocationInfo,
&allocationInfo, sizeof(FILE_ALLOCATION_INFO)) != 0
sizeof(FILE_ALLOCATION_INFO)) != 0 ? populate_file_info(
? populate_file_info( construct_api_path(get_open_file_path(handle)), *r_info)
construct_api_path(get_open_file_path(handle)), *file_info) : FspNtStatusFromWin32(::GetLastError());
: FspNtStatusFromWin32(::GetLastError());
} }
} }
@@ -1285,7 +1282,7 @@ auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name,
auto remote_server::winfsp_set_basic_info( auto remote_server::winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time, PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_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(); REPERTORY_USES_FUNCTION_NAME();
auto *handle = reinterpret_cast<HANDLE>(file_desc); auto *handle = reinterpret_cast<HANDLE>(file_desc);
@@ -1307,7 +1304,7 @@ auto remote_server::winfsp_set_basic_info(
ret = ::SetFileInformationByHandle(handle, FileBasicInfo, &basic_info, ret = ::SetFileInformationByHandle(handle, FileBasicInfo, &basic_info,
sizeof(FILE_BASIC_INFO)) != 0 sizeof(FILE_BASIC_INFO)) != 0
? populate_file_info( ? 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()); : FspNtStatusFromWin32(::GetLastError());
} }
RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, get_open_file_path(file_desc), 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, auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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) ret = (ret == STATUS_SUCCESS)
? populate_file_info( ? populate_file_info(
construct_api_path(get_open_file_path(handle)), *file_info) construct_api_path(get_open_file_path(handle)), *r_info)
: ret; : ret;
} }
@@ -1365,7 +1362,7 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
UINT32 length, BOOLEAN /*write_to_end*/, UINT32 length, BOOLEAN /*write_to_end*/,
BOOLEAN constrained_io, BOOLEAN constrained_io,
PUINT32 bytes_transferred, PUINT32 bytes_transferred,
remote::file_info *file_info) remote::file_info *r_info)
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); 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), reinterpret_cast<LPDWORD>(bytes_transferred),
&overlapped) != 0 &overlapped) != 0
? populate_file_info( ? populate_file_info(
construct_api_path(get_open_file_path(handle)), construct_api_path(get_open_file_path(handle)), *r_info)
*file_info)
: FspNtStatusFromWin32(::GetLastError()); : FspNtStatusFromWin32(::GetLastError());
} }
} else { } else {
ret = populate_file_info(construct_api_path(get_open_file_path(handle)), ret = populate_file_info(construct_api_path(get_open_file_path(handle)),
*file_info); *r_info);
} }
} }

View File

@@ -131,14 +131,14 @@ auto remote_winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
UINT64 allocation_size, PVOID * /*file_node*/, UINT64 allocation_size, PVOID * /*file_node*/,
PVOID *file_desc, OpenFileInfo *ofi) PVOID *file_desc, OpenFileInfo *ofi)
-> NTSTATUS { -> NTSTATUS {
remote::file_info f_info{}; remote::file_info r_info{};
std::string normalized_name; std::string normalized_name;
BOOLEAN exists{0}; BOOLEAN exists{0};
auto ret = remote_instance_->winfsp_create( auto ret = remote_instance_->winfsp_create(
file_name, create_options, granted_access, attributes, allocation_size, 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) { 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); auto file_path = utils::string::from_utf8(normalized_name);
wcsncpy(ofi->NormalizedName, file_path.data(), wcslen(file_path.c_str())); wcsncpy(ofi->NormalizedName, file_path.data(), wcslen(file_path.c_str()));
ofi->NormalizedNameSize = 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, auto remote_winfsp_drive::Flush(PVOID /*file_node*/, PVOID file_desc,
FileInfo *file_info) -> NTSTATUS { FileInfo *f_info) -> NTSTATUS {
remote::file_info fi{}; remote::file_info r_info{};
auto ret = remote_instance_->winfsp_flush(file_desc, &fi); auto ret = remote_instance_->winfsp_flush(file_desc, &r_info);
set_file_info(*file_info, fi); set_file_info(*f_info, r_info);
return ret; return ret;
} }
auto remote_winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc, auto remote_winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc,
FileInfo *file_info) -> NTSTATUS { FileInfo *f_info) -> NTSTATUS {
remote::file_info fi{}; remote::file_info r_info{};
auto ret = remote_instance_->winfsp_get_file_info(file_desc, &fi); auto ret = remote_instance_->winfsp_get_file_info(file_desc, &r_info);
set_file_info(*file_info, fi); set_file_info(*f_info, r_info);
return ret; return ret;
} }
@@ -300,13 +300,13 @@ auto remote_winfsp_drive::Open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID * /*file_node*/, UINT32 granted_access, PVOID * /*file_node*/,
PVOID *file_desc, OpenFileInfo *ofi) PVOID *file_desc, OpenFileInfo *ofi)
-> NTSTATUS { -> NTSTATUS {
remote::file_info fi{}; remote::file_info r_info{};
std::string normalize_name; std::string normalize_name;
auto ret = auto ret =
remote_instance_->winfsp_open(file_name, create_options, granted_access, 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) { 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); auto file_path = utils::string::from_utf8(normalize_name);
wcsncpy(ofi->NormalizedName, file_path.data(), wcslen(file_path.c_str())); wcsncpy(ofi->NormalizedName, file_path.data(), wcslen(file_path.c_str()));
ofi->NormalizedNameSize = 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, auto remote_winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes, UINT32 attributes,
BOOLEAN replace_attributes, BOOLEAN replace_attributes,
UINT64 allocation_size, FileInfo *file_info) UINT64 allocation_size, FileInfo *f_info)
-> NTSTATUS { -> NTSTATUS {
remote::file_info info{}; remote::file_info r_info{};
auto ret = remote_instance_->winfsp_overwrite( auto ret = remote_instance_->winfsp_overwrite(
file_desc, attributes, replace_attributes, allocation_size, &info); file_desc, attributes, replace_attributes, allocation_size, &r_info);
set_file_info(*file_info, info); set_file_info(*f_info, r_info);
return ret; return ret;
} }
void remote_winfsp_drive::populate_file_info(const json &item, 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>(); auto dir_item = item.get<directory_item>();
file_info.FileSize = dir_item.directory ? 0 : dir_item.size; f_info.FileSize = dir_item.directory ? 0 : dir_item.size;
file_info.AllocationSize = f_info.AllocationSize =
utils::divide_with_ceiling(file_info.FileSize, WINFSP_ALLOCATION_UNIT) * utils::divide_with_ceiling(f_info.FileSize, WINFSP_ALLOCATION_UNIT) *
WINFSP_ALLOCATION_UNIT; WINFSP_ALLOCATION_UNIT;
file_info.ChangeTime = utils::get_changed_time_from_meta(dir_item.meta); f_info.ChangeTime = utils::get_changed_time_from_meta(dir_item.meta);
file_info.CreationTime = utils::get_creation_time_from_meta(dir_item.meta); f_info.CreationTime = utils::get_creation_time_from_meta(dir_item.meta);
file_info.FileAttributes = utils::get_attributes_from_meta(dir_item.meta); f_info.FileAttributes = utils::get_attributes_from_meta(dir_item.meta);
file_info.HardLinks = 0; f_info.HardLinks = 0;
file_info.IndexNumber = 0; f_info.IndexNumber = 0;
file_info.LastAccessTime = utils::get_accessed_time_from_meta(dir_item.meta); f_info.LastAccessTime = utils::get_accessed_time_from_meta(dir_item.meta);
file_info.LastWriteTime = utils::get_written_time_from_meta(dir_item.meta); f_info.LastWriteTime = utils::get_written_time_from_meta(dir_item.meta);
file_info.ReparseTag = 0; f_info.ReparseTag = 0;
file_info.EaSize = 0; f_info.EaSize = 0;
} }
auto remote_winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, 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, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_access_time,
UINT64 last_write_time, UINT64 last_write_time,
UINT64 change_time, FileInfo *file_info) UINT64 change_time, FileInfo *f_info)
-> NTSTATUS { -> NTSTATUS {
remote::file_info f_info{}; remote::file_info r_info{};
auto ret = remote_instance_->winfsp_set_basic_info( auto ret = remote_instance_->winfsp_set_basic_info(
file_desc, attributes, creation_time, last_access_time, last_write_time, file_desc, attributes, creation_time, last_access_time, last_write_time,
change_time, &f_info); change_time, &r_info);
set_file_info(*file_info, f_info); set_file_info(*f_info, r_info);
return ret; return ret;
} }
void remote_winfsp_drive::set_file_info(FileInfo &dest, void remote_winfsp_drive::set_file_info(FileInfo &f_info,
const remote::file_info &src) { const remote::file_info &r_info) {
dest.FileAttributes = src.FileAttributes; f_info.FileAttributes = r_info.FileAttributes;
dest.ReparseTag = src.ReparseTag; f_info.ReparseTag = r_info.ReparseTag;
dest.AllocationSize = src.AllocationSize; f_info.AllocationSize = r_info.AllocationSize;
dest.FileSize = src.FileSize; f_info.FileSize = r_info.FileSize;
dest.CreationTime = src.CreationTime; f_info.CreationTime = r_info.CreationTime;
dest.LastAccessTime = src.LastAccessTime; f_info.LastAccessTime = r_info.LastAccessTime;
dest.LastWriteTime = src.LastWriteTime; f_info.LastWriteTime = r_info.LastWriteTime;
dest.ChangeTime = src.ChangeTime; f_info.ChangeTime = r_info.ChangeTime;
dest.IndexNumber = src.IndexNumber; f_info.IndexNumber = r_info.IndexNumber;
dest.HardLinks = src.HardLinks; f_info.HardLinks = r_info.HardLinks;
dest.EaSize = src.EaSize; f_info.EaSize = r_info.EaSize;
} }
auto remote_winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc, auto remote_winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
UINT64 new_size, UINT64 new_size,
BOOLEAN set_allocation_size, BOOLEAN set_allocation_size,
FileInfo *file_info) -> NTSTATUS { FileInfo *f_info) -> NTSTATUS {
remote::file_info fi{}; remote::file_info r_info{};
auto ret = remote_instance_->winfsp_set_file_size(file_desc, new_size, auto ret = remote_instance_->winfsp_set_file_size(
set_allocation_size, &fi); file_desc, new_size, set_allocation_size, &r_info);
set_file_info(*file_info, fi); set_file_info(*f_info, r_info);
return ret; return ret;
} }
@@ -495,13 +495,13 @@ VOID remote_winfsp_drive::Unmounted(PVOID host) {
auto remote_winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc, auto remote_winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc,
PVOID buffer, UINT64 offset, ULONG length, PVOID buffer, UINT64 offset, ULONG length,
BOOLEAN write_to_end, BOOLEAN constrained_io, BOOLEAN write_to_end, BOOLEAN constrained_io,
PULONG bytes_transferred, FileInfo *file_info) PULONG bytes_transferred, FileInfo *f_info)
-> NTSTATUS { -> NTSTATUS {
remote::file_info fi{}; remote::file_info r_info{};
auto ret = remote_instance_->winfsp_write( auto ret = remote_instance_->winfsp_write(
file_desc, buffer, offset, length, write_to_end, constrained_io, file_desc, buffer, offset, length, write_to_end, constrained_io,
reinterpret_cast<PUINT32>(bytes_transferred), &fi); reinterpret_cast<PUINT32>(bytes_transferred), &r_info);
set_file_info(*file_info, fi); set_file_info(*f_info, r_info);
return ret; return ret;
} }
} // namespace repertory::remote_winfsp } // namespace repertory::remote_winfsp

View File

@@ -70,14 +70,14 @@ winfsp_drive::winfsp_service::winfsp_service(
auto winfsp_drive::handle_error(std::string_view function_name, auto winfsp_drive::handle_error(std::string_view function_name,
const std::string &api_path, api_error error, 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 { bool raise_on_failure_only) const -> NTSTATUS {
auto ret = utils::from_api_error(error); auto ret = utils::from_api_error(error);
if (not raise_on_failure_only) { if (not raise_on_failure_only) {
RAISE_WINFSP_EVENT(function_name, api_path, ret); RAISE_WINFSP_EVENT(function_name, api_path, ret);
} }
if (file_info == nullptr) { if (f_info == nullptr) {
return ret; return ret;
} }
@@ -86,7 +86,7 @@ auto winfsp_drive::handle_error(std::string_view function_name,
return ret; return ret;
} }
populate_file_info(file_size, meta, *file_info); populate_file_info(file_size, meta, *f_info);
return ret; return ret;
} }
@@ -371,15 +371,15 @@ auto winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
return ret; return ret;
} }
auto winfsp_drive::Flush(PVOID /*file_node*/, PVOID file_desc, auto winfsp_drive::Flush(PVOID /*file_node*/, PVOID file_desc, FileInfo *f_info)
FileInfo *file_info) -> NTSTATUS { -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
std::string api_path; std::string api_path;
std::shared_ptr<i_open_file> file; std::shared_ptr<i_open_file> file;
const auto handle_error = [this, &api_path, &file, const auto handle_error = [this, &api_path, &file,
&file_info](api_error error) -> NTSTATUS { &f_info](api_error error) -> NTSTATUS {
return this->handle_error(function_name, api_path, error, file_info, return this->handle_error(function_name, api_path, error, f_info,
file ? file->get_file_size() : 0U); 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, auto winfsp_drive::GetFileInfo(PVOID /*file_node*/, PVOID file_desc,
FileInfo *file_info) -> NTSTATUS { FileInfo *f_info) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
std::string api_path; std::string api_path;
std::shared_ptr<i_open_file> file; std::shared_ptr<i_open_file> file;
const auto handle_error = [this, &api_path, &file, const auto handle_error = [this, &api_path, &file,
&file_info](api_error error) -> NTSTATUS { &f_info](api_error error) -> NTSTATUS {
return this->handle_error(function_name, api_path, error, file_info, return this->handle_error(function_name, api_path, error, f_info,
file ? file->get_file_size() : 0U); 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, auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes, BOOLEAN replace_attributes, UINT32 attributes, BOOLEAN replace_attributes,
UINT64 /*allocation_size*/, FileInfo *file_info) UINT64 /*allocation_size*/, FileInfo *f_info)
-> NTSTATUS { -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
std::string api_path; std::string api_path;
std::shared_ptr<i_open_file> file; std::shared_ptr<i_open_file> file;
const auto handle_error = [this, &api_path, &file, const auto handle_error = [this, &api_path, &file,
&file_info](api_error error) -> NTSTATUS { &f_info](api_error error) -> NTSTATUS {
return this->handle_error(function_name, api_path, error, file_info, return this->handle_error(function_name, api_path, error, f_info,
file ? file->get_file_size() : 0U); 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, 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_error {
api_meta_map meta{}; api_meta_map meta{};
auto ret = provider_.get_item_meta(api_path, meta); auto ret = provider_.get_item_meta(api_path, meta);
if (ret == api_error::success) { if (ret == api_error::success) {
FSP_FSCTL_FILE_INFO info{}; FSP_FSCTL_FILE_INFO info{};
populate_file_info(utils::string::to_uint64(meta[META_SIZE]), meta, 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; 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, void winfsp_drive::populate_file_info(std::uint64_t file_size,
api_meta_map meta, api_meta_map meta,
FSP_FSCTL_FILE_INFO &file_info) const { FSP_FSCTL_FILE_INFO &f_info) const {
file_info.FileSize = file_size; f_info.FileSize = file_size;
file_info.AllocationSize = f_info.AllocationSize =
utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) * utils::divide_with_ceiling(file_size, WINFSP_ALLOCATION_UNIT) *
WINFSP_ALLOCATION_UNIT; WINFSP_ALLOCATION_UNIT;
file_info.ChangeTime = utils::get_changed_time_from_meta(meta); f_info.ChangeTime = utils::get_changed_time_from_meta(meta);
file_info.CreationTime = utils::get_creation_time_from_meta(meta); f_info.CreationTime = utils::get_creation_time_from_meta(meta);
file_info.FileAttributes = utils::get_attributes_from_meta(meta); f_info.FileAttributes = utils::get_attributes_from_meta(meta);
file_info.HardLinks = 0; f_info.HardLinks = 0;
file_info.IndexNumber = 0; f_info.IndexNumber = 0;
file_info.LastAccessTime = utils::get_accessed_time_from_meta(meta); f_info.LastAccessTime = utils::get_accessed_time_from_meta(meta);
file_info.LastWriteTime = utils::get_written_time_from_meta(meta); f_info.LastWriteTime = utils::get_written_time_from_meta(meta);
file_info.ReparseTag = 0; f_info.ReparseTag = 0;
file_info.EaSize = 0; f_info.EaSize = 0;
} }
auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer, 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, auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc,
UINT32 attributes, UINT64 creation_time, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 last_access_time, UINT64 last_write_time,
UINT64 change_time, FileInfo *file_info) UINT64 change_time, FileInfo *f_info)
-> NTSTATUS { -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
std::string api_path; std::string api_path;
std::shared_ptr<i_open_file> file; std::shared_ptr<i_open_file> file;
const auto handle_error = [this, &api_path, &file, const auto handle_error = [this, &api_path, &file,
&file_info](api_error error) -> NTSTATUS { &f_info](api_error error) -> NTSTATUS {
return this->handle_error(function_name, api_path, error, file_info, return this->handle_error(function_name, api_path, error, f_info,
file ? file->get_file_size() : 0U); 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)); return handle_error(provider_.set_item_meta(api_path, meta));
} }
void winfsp_drive::set_file_info(remote::file_info &dest, void winfsp_drive::set_file_info(remote::f_info &r_info,
const FSP_FSCTL_FILE_INFO &src) { const FSP_FSCTL_FILE_INFO &f_info) {
dest.FileAttributes = src.FileAttributes; r_info.FileAttributes = f_info.FileAttributes;
dest.ReparseTag = src.ReparseTag; r_info.ReparseTag = f_info.ReparseTag;
dest.AllocationSize = src.AllocationSize; r_info.AllocationSize = f_info.AllocationSize;
dest.FileSize = src.FileSize; r_info.FileSize = f_info.FileSize;
dest.CreationTime = src.CreationTime; r_info.CreationTime = f_info.CreationTime;
dest.LastAccessTime = src.LastAccessTime; r_info.LastAccessTime = f_info.LastAccessTime;
dest.LastWriteTime = src.LastWriteTime; r_info.LastWriteTime = f_info.LastWriteTime;
dest.ChangeTime = src.ChangeTime; r_info.ChangeTime = f_info.ChangeTime;
dest.IndexNumber = src.IndexNumber; r_info.IndexNumber = f_info.IndexNumber;
dest.HardLinks = src.HardLinks; r_info.HardLinks = f_info.HardLinks;
dest.EaSize = src.EaSize; r_info.EaSize = f_info.EaSize;
} }
auto winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc, auto winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
UINT64 new_size, BOOLEAN set_allocation_size, UINT64 new_size, BOOLEAN set_allocation_size,
FileInfo *file_info) -> NTSTATUS { FileInfo *f_info) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
std::string api_path; std::string api_path;
std::shared_ptr<i_open_file> file; std::shared_ptr<i_open_file> file;
const auto handle_error = [this, &api_path, &file, const auto handle_error = [this, &api_path, &file,
&file_info](api_error error) -> NTSTATUS { &f_info](api_error error) -> NTSTATUS {
return this->handle_error(function_name, api_path, error, file_info, return this->handle_error(function_name, api_path, error, f_info,
file ? file->get_file_size() : 0U); 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, auto winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
UINT64 offset, ULONG length, BOOLEAN write_to_end, UINT64 offset, ULONG length, BOOLEAN write_to_end,
BOOLEAN constrained_io, PULONG bytes_transferred, BOOLEAN constrained_io, PULONG bytes_transferred,
FileInfo *file_info) -> NTSTATUS { FileInfo *f_info) -> NTSTATUS {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
*bytes_transferred = 0U; *bytes_transferred = 0U;
@@ -1241,8 +1241,8 @@ auto winfsp_drive::Write(PVOID /*file_node*/, PVOID file_desc, PVOID buffer,
std::string api_path; std::string api_path;
std::shared_ptr<i_open_file> file; std::shared_ptr<i_open_file> file;
const auto handle_error = [this, &api_path, &file, const auto handle_error = [this, &api_path, &file,
&file_info](api_error error) -> NTSTATUS { &f_info](api_error error) -> NTSTATUS {
return this->handle_error(function_name, api_path, error, file_info, return this->handle_error(function_name, api_path, error, f_info,
file ? file->get_file_size() : 0U, true); file ? file->get_file_size() : 0U, true);
}; };

View File

@@ -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) { const auto add_to_lookup = [&](const std::string &lookup_path) {
if (lookup.find(lookup_path) == lookup.end()) { if (lookup.find(lookup_path) == lookup.end()) {
struct stat st {}; struct stat u_stat{};
stat(lookup_path.c_str(), &st); stat(lookup_path.c_str(), &u_stat);
#if defined(__APPLE__) #if defined(__APPLE__)
lookup[lookup_path] = 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) + 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__) #else // !defined(__APPLE__)
lookup[lookup_path] = (static_cast<std::uint64_t>(st.st_mtim.tv_sec) * lookup[lookup_path] =
utils::time::NANOS_PER_SECOND) + (static_cast<std::uint64_t>(u_stat.st_mtim.tv_sec) *
static_cast<std::uint64_t>(st.st_mtim.tv_nsec); utils::time::NANOS_PER_SECOND) +
static_cast<std::uint64_t>(u_stat.st_mtim.tv_nsec);
#endif // defined(__APPLE__) #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> { auto read_file_lines(const std::string &path) -> std::vector<std::string> {
std::vector<std::string> ret; std::vector<std::string> ret;
if (utils::file::file(path).exists()) { if (utils::file::file(path).exists()) {
std::ifstream fs(path); std::ifstream stream(path);
std::string current_line; 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')); ret.emplace_back(utils::string::right_trim(current_line, '\r'));
} }
fs.close(); stream.close();
} }
return ret; return ret;
@@ -159,10 +160,11 @@ auto reset_modified_time(const std::string &path) -> bool {
} }
} }
#else // !defined(_WIN32) #else // !defined(_WIN32)
auto fd = open(path.c_str(), O_RDWR); auto desc = open(path.c_str(), O_RDWR);
if ((ret = (fd != -1))) { ret = (desc != -1);
ret = futimens(fd, nullptr) == 0; if (ret) {
close(fd); ret = futimens(desc, nullptr) == 0;
close(desc);
} }
#endif // defined(_WIN32) #endif // defined(_WIN32)

View File

@@ -762,34 +762,11 @@ auto handlers::launch_process(provider_type prov, std::string_view name,
} }
exec_args.push_back(nullptr); exec_args.push_back(nullptr);
auto pid = fork(); exit(utils::create_daemon([&]() -> int {
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);
}
chdir(utils::path::get_parent_path(repertory_binary_).c_str()); chdir(utils::path::get_parent_path(repertory_binary_).c_str());
execvp(exec_args.at(0U), const_cast<char *const *>(exec_args.data())); return execvp(exec_args.at(0U),
exit(1); const_cast<char *const *>(exec_args.data()));
} else { }));
signal(SIGCHLD, SIG_IGN);
}
#endif // defined(_WIN32) #endif // defined(_WIN32)
return {}; return {};

View File

@@ -298,10 +298,10 @@ public:
EXPECT_TRUE(utils::file::file(file_path).exists()); EXPECT_TRUE(utils::file::file(file_path).exists());
EXPECT_FALSE(utils::file::directory(file_path).exists()); EXPECT_FALSE(utils::file::directory(file_path).exists());
struct stat64 unix_st{}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat));
EXPECT_EQ(getgid(), unix_st.st_gid); EXPECT_EQ(getgid(), u_stat.st_gid);
EXPECT_EQ(getuid(), unix_st.st_uid); EXPECT_EQ(getuid(), u_stat.st_uid);
return file_path; return file_path;
} }
@@ -322,10 +322,10 @@ public:
EXPECT_EQ(0U, utils::file::directory(dir_path).count(true)); EXPECT_EQ(0U, utils::file::directory(dir_path).count(true));
EXPECT_FALSE(utils::file::file(dir_path).exists()); EXPECT_FALSE(utils::file::file(dir_path).exists());
struct stat64 unix_st{}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(dir_path.c_str(), &unix_st)); EXPECT_EQ(0, stat64(dir_path.c_str(), &u_stat));
EXPECT_EQ(getgid(), unix_st.st_gid); EXPECT_EQ(getgid(), u_stat.st_gid);
EXPECT_EQ(getuid(), unix_st.st_uid); EXPECT_EQ(getuid(), u_stat.st_uid);
return dir_path; return dir_path;
} }

View File

@@ -42,8 +42,9 @@ private:
std::string mount_location_; std::string mount_location_;
public: public:
[[nodiscard]] auto get_directory_item_count( [[nodiscard]] auto
const std::string & /*api_path*/) const -> std::uint64_t override { get_directory_item_count(const std::string & /*api_path*/) const
-> std::uint64_t override {
return 1; return 1;
} }
@@ -84,10 +85,10 @@ public:
return api_error::error; return api_error::error;
} }
auto auto get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes,
get_security_by_name(PWSTR /*file_name*/, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor,
PSECURITY_DESCRIPTOR descriptor, std::uint64_t *descriptor_size)
std::uint64_t *descriptor_size) -> NTSTATUS override { -> NTSTATUS override {
auto ret = STATUS_SUCCESS; auto ret = STATUS_SUCCESS;
if (attributes != nullptr) { if (attributes != nullptr) {
@@ -134,9 +135,9 @@ public:
volume_label = "TestVolumeLabel"; volume_label = "TestVolumeLabel";
} }
auto auto populate_file_info(const std::string &api_path,
populate_file_info(const std::string &api_path, remote::file_info &r_info) const
remote::file_info &file_info) const -> api_error override { -> api_error override {
auto file_path = utils::path::combine(mount_location_, {api_path}); auto file_path = utils::path::combine(mount_location_, {api_path});
auto directory = utils::file::directory(file_path).exists(); auto directory = utils::file::directory(file_path).exists();
auto attributes = auto attributes =
@@ -155,21 +156,20 @@ public:
return api_error::os_error; 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 directory ? 0
: utils::divide_with_ceiling(file_info.FileSize, : utils::divide_with_ceiling(r_info.FileSize,
WINFSP_ALLOCATION_UNIT) * WINFSP_ALLOCATION_UNIT) *
WINFSP_ALLOCATION_UNIT; WINFSP_ALLOCATION_UNIT;
file_info.FileAttributes = basic_info.FileAttributes; r_info.FileAttributes = basic_info.FileAttributes;
file_info.ChangeTime = static_cast<UINT64>(basic_info.ChangeTime.QuadPart); r_info.ChangeTime = static_cast<UINT64>(basic_info.ChangeTime.QuadPart);
file_info.CreationTime = r_info.CreationTime = static_cast<UINT64>(basic_info.CreationTime.QuadPart);
static_cast<UINT64>(basic_info.CreationTime.QuadPart); r_info.LastAccessTime =
file_info.LastAccessTime =
static_cast<UINT64>(basic_info.LastAccessTime.QuadPart); static_cast<UINT64>(basic_info.LastAccessTime.QuadPart);
file_info.LastWriteTime = r_info.LastWriteTime =
static_cast<UINT64>(basic_info.LastWriteTime.QuadPart); static_cast<UINT64>(basic_info.LastWriteTime.QuadPart);
::CloseHandle(handle); ::CloseHandle(handle);
return api_error::success; return api_error::success;

View File

@@ -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)); EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR));
std::this_thread::sleep_for(SLEEP_SECONDS); std::this_thread::sleep_for(SLEEP_SECONDS);
struct stat64 unix_st{}; struct stat64 u_stat{};
stat64(file_path.c_str(), &unix_st); stat64(file_path.c_str(), &u_stat);
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR), 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); 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)); EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID));
std::this_thread::sleep_for(SLEEP_SECONDS); std::this_thread::sleep_for(SLEEP_SECONDS);
struct stat64 unix_st{}; struct stat64 u_stat{};
stat64(file_path.c_str(), &unix_st); stat64(file_path.c_str(), &u_stat);
EXPECT_EQ(0, S_ISGID & unix_st.st_mode); EXPECT_EQ(0, S_ISGID & u_stat.st_mode);
#else // !defined(__APPLE__) #else // !defined(__APPLE__)
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID)); EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISGID));
EXPECT_EQ(EPERM, errno); 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)); EXPECT_EQ(0, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID));
std::this_thread::sleep_for(SLEEP_SECONDS); std::this_thread::sleep_for(SLEEP_SECONDS);
struct stat64 unix_st{}; struct stat64 u_stat{};
stat64(file_path.c_str(), &unix_st); stat64(file_path.c_str(), &u_stat);
EXPECT_EQ(0, S_ISUID & unix_st.st_mode); EXPECT_EQ(0, S_ISUID & u_stat.st_mode);
#else // !defined(__APPLE__) #else // !defined(__APPLE__)
EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID)); EXPECT_EQ(-1, chmod(file_path.c_str(), S_IRUSR | S_IWUSR | S_ISUID));
EXPECT_EQ(EPERM, errno); EXPECT_EQ(EPERM, errno);

View File

@@ -31,16 +31,16 @@ TYPED_TEST(fuse_test,
std::string file_name{"chown_test"}; std::string file_name{"chown_test"};
auto file_path = this->create_file_and_test(file_name); auto file_path = this->create_file_and_test(file_name);
struct stat64 unix_st {}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat));
EXPECT_EQ(0, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid())); EXPECT_EQ(0, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid()));
std::this_thread::sleep_for(SLEEP_SECONDS); std::this_thread::sleep_for(SLEEP_SECONDS);
struct stat64 unix_st2 {}; struct stat64 u_stat2{};
stat64(file_path.c_str(), &unix_st2); stat64(file_path.c_str(), &u_stat2);
EXPECT_EQ(getgid(), unix_st2.st_gid); EXPECT_EQ(getgid(), u_stat2.st_gid);
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid);
this->unlink_file_and_test(file_path); this->unlink_file_and_test(file_path);
} }
@@ -51,16 +51,16 @@ TYPED_TEST(
std::string file_name{"chown_test"}; std::string file_name{"chown_test"};
auto file_path = this->create_file_and_test(file_name); auto file_path = this->create_file_and_test(file_name);
struct stat64 unix_st {}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat));
EXPECT_EQ(0, chown(file_path.c_str(), getuid(), getgid())); EXPECT_EQ(0, chown(file_path.c_str(), getuid(), getgid()));
std::this_thread::sleep_for(SLEEP_SECONDS); std::this_thread::sleep_for(SLEEP_SECONDS);
struct stat64 unix_st2 {}; struct stat64 u_stat2{};
stat64(file_path.c_str(), &unix_st2); stat64(file_path.c_str(), &u_stat2);
EXPECT_EQ(getgid(), unix_st2.st_gid); EXPECT_EQ(getgid(), u_stat2.st_gid);
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid);
this->unlink_file_and_test(file_path); this->unlink_file_and_test(file_path);
} }
@@ -70,16 +70,16 @@ TYPED_TEST(fuse_test,
std::string file_name{"chown_test"}; std::string file_name{"chown_test"};
auto file_path = this->create_file_and_test(file_name); auto file_path = this->create_file_and_test(file_name);
struct stat64 unix_st {}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); 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(-1, chown(file_path.c_str(), static_cast<uid_t>(-1), 0));
EXPECT_EQ(EPERM, errno); EXPECT_EQ(EPERM, errno);
struct stat64 unix_st2 {}; struct stat64 u_stat2{};
stat64(file_path.c_str(), &unix_st2); stat64(file_path.c_str(), &u_stat2);
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid); EXPECT_EQ(u_stat.st_gid, u_stat2.st_gid);
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid);
this->unlink_file_and_test(file_path); 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"}; std::string file_name{"chown_test"};
auto file_path = this->create_root_file(file_name); auto file_path = this->create_root_file(file_name);
struct stat64 unix_st {}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); 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(-1, chown(file_path.c_str(), static_cast<uid_t>(-1), getgid()));
EXPECT_EQ(EPERM, errno); EXPECT_EQ(EPERM, errno);
struct stat64 unix_st2 {}; struct stat64 u_stat2{};
stat64(file_path.c_str(), &unix_st2); stat64(file_path.c_str(), &u_stat2);
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid); EXPECT_EQ(u_stat.st_gid, u_stat2.st_gid);
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid);
this->unlink_root_file(file_path); 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"}; std::string file_name{"chown_test"};
auto file_path = this->create_file_and_test(file_name); auto file_path = this->create_file_and_test(file_name);
struct stat64 unix_st {}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); 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(-1, chown(file_path.c_str(), 0, static_cast<gid_t>(-1)));
EXPECT_EQ(EPERM, errno); EXPECT_EQ(EPERM, errno);
struct stat64 unix_st2 {}; struct stat64 u_stat2{};
stat64(file_path.c_str(), &unix_st2); stat64(file_path.c_str(), &u_stat2);
EXPECT_EQ(unix_st.st_gid, unix_st2.st_gid); EXPECT_EQ(u_stat.st_gid, u_stat2.st_gid);
EXPECT_EQ(unix_st.st_uid, unix_st2.st_uid); EXPECT_EQ(u_stat.st_uid, u_stat2.st_uid);
this->unlink_file_and_test(file_path); this->unlink_file_and_test(file_path);
} }

View File

@@ -41,9 +41,9 @@ TYPED_TEST(fuse_test, create_can_create_directory_with_specific_perms) {
std::string dir_name{"create_test"}; std::string dir_name{"create_test"};
auto dir_path = this->create_directory_and_test(dir_name, S_IRUSR); auto dir_path = this->create_directory_and_test(dir_name, S_IRUSR);
struct stat64 unix_st{}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(dir_path.c_str(), &unix_st)); EXPECT_EQ(0, stat64(dir_path.c_str(), &u_stat));
EXPECT_EQ(S_IRUSR, unix_st.st_mode & ACCESSPERMS); EXPECT_EQ(S_IRUSR, u_stat.st_mode & ACCESSPERMS);
this->rmdir_and_test(dir_path); 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"}; std::string file_name{"create_test"};
auto file_path = this->create_file_and_test(file_name, S_IRUSR); auto file_path = this->create_file_and_test(file_name, S_IRUSR);
struct stat64 unix_st{}; struct stat64 u_stat{};
EXPECT_EQ(0, stat64(file_path.c_str(), &unix_st)); EXPECT_EQ(0, stat64(file_path.c_str(), &u_stat));
EXPECT_EQ(S_IRUSR, unix_st.st_mode & ACCESSPERMS); EXPECT_EQ(S_IRUSR, u_stat.st_mode & ACCESSPERMS);
this->unlink_file_and_test(file_path); this->unlink_file_and_test(file_path);
} }

View File

@@ -135,8 +135,8 @@ auto get_free_drive_space(std::string_view path)
#endif // defined(_WIN32) #endif // defined(_WIN32)
#if defined(__linux__) #if defined(__linux__)
struct statfs64 st{}; struct statfs64 u_stat{};
if (statfs64(std::string{path}.c_str(), &st) != 0) { if (statfs64(std::string{path}.c_str(), &u_stat) != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
"failed to get free disk space", "failed to get free disk space",
@@ -145,12 +145,12 @@ auto get_free_drive_space(std::string_view path)
}); });
} }
return st.f_bfree * static_cast<std::uint64_t>(st.f_bsize); return u_stat.f_bfree * static_cast<std::uint64_t>(u_stat.f_bsize);
#endif // defined(__linux__) #endif // defined(__linux__)
#if defined(__APPLE__) #if defined(__APPLE__)
struct statvfs st{}; struct statvfs u_stat{};
if (statvfs(std::string{path}.c_str(), &st) != 0) { if (statvfs(std::string{path}.c_str(), &u_stat) != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
"failed to get free disk space", "failed to get free disk space",
@@ -159,7 +159,7 @@ auto get_free_drive_space(std::string_view path)
}); });
} }
return st.f_bfree * static_cast<std::uint64_t>(st.f_frsize); return u_stat.f_bfree * static_cast<std::uint64_t>(u_stat.f_frsize);
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
} catch (const std::exception &e) { } catch (const std::exception &e) {
utils::error::handle_exception(function_name, e); utils::error::handle_exception(function_name, e);
@@ -217,8 +217,8 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
} }
} }
struct _stat64 st{}; struct _stat64 u_stat{};
if (_stat64(std::string{path}.c_str(), &st) != 0) { if (_stat64(std::string{path}.c_str(), &u_stat) != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
"failed to get file times", "failed to get file times",
@@ -227,13 +227,13 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
}); });
} }
ret.accessed = utils::time::windows_time_t_to_unix_time(st.st_atime); ret.accessed = utils::time::windows_time_t_to_unix_time(u_stat.st_atime);
ret.created = utils::time::windows_time_t_to_unix_time(st.st_ctime); ret.created = utils::time::windows_time_t_to_unix_time(u_stat.st_ctime);
ret.modified = utils::time::windows_time_t_to_unix_time(st.st_mtime); ret.modified = utils::time::windows_time_t_to_unix_time(u_stat.st_mtime);
ret.written = utils::time::windows_time_t_to_unix_time(st.st_mtime); ret.written = utils::time::windows_time_t_to_unix_time(u_stat.st_mtime);
#else // !defined(_WIN32) #else // !defined(_WIN32)
struct stat64 st{}; struct stat64 u_stat{};
if (stat64(std::string{path}.c_str(), &st) != 0) { if (stat64(std::string{path}.c_str(), &u_stat) != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
"failed to get file times", "failed to get file times",
@@ -243,30 +243,30 @@ auto get_times(std::string_view path) -> std::optional<file_times> {
} }
#if defined(__APPLE__) #if defined(__APPLE__)
ret.accessed = static_cast<std::uint64_t>(st.st_atimespec.tv_nsec) + ret.accessed = static_cast<std::uint64_t>(u_stat.st_atimespec.tv_nsec) +
static_cast<std::uint64_t>(st.st_atimespec.tv_sec) * static_cast<std::uint64_t>(u_stat.st_atimespec.tv_sec) *
utils::time::NANOS_PER_SECOND; utils::time::NANOS_PER_SECOND;
ret.created = static_cast<std::uint64_t>(st.st_ctimespec.tv_nsec) + ret.created = static_cast<std::uint64_t>(u_stat.st_ctimespec.tv_nsec) +
static_cast<std::uint64_t>(st.st_ctimespec.tv_sec) * static_cast<std::uint64_t>(u_stat.st_ctimespec.tv_sec) *
utils::time::NANOS_PER_SECOND; utils::time::NANOS_PER_SECOND;
ret.modified = static_cast<std::uint64_t>(st.st_mtimespec.tv_nsec) + ret.modified = static_cast<std::uint64_t>(u_stat.st_mtimespec.tv_nsec) +
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; utils::time::NANOS_PER_SECOND;
ret.written = static_cast<std::uint64_t>(st.st_mtimespec.tv_nsec) + ret.written = static_cast<std::uint64_t>(u_stat.st_mtimespec.tv_nsec) +
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; utils::time::NANOS_PER_SECOND;
#else // !defined(__APPLE__) #else // !defined(__APPLE__)
ret.accessed = static_cast<std::uint64_t>(st.st_atim.tv_nsec) + ret.accessed = static_cast<std::uint64_t>(u_stat.st_atim.tv_nsec) +
static_cast<std::uint64_t>(st.st_atim.tv_sec) * static_cast<std::uint64_t>(u_stat.st_atim.tv_sec) *
utils::time::NANOS_PER_SECOND; utils::time::NANOS_PER_SECOND;
ret.created = static_cast<std::uint64_t>(st.st_ctim.tv_nsec) + ret.created = static_cast<std::uint64_t>(u_stat.st_ctim.tv_nsec) +
static_cast<std::uint64_t>(st.st_ctim.tv_sec) * static_cast<std::uint64_t>(u_stat.st_ctim.tv_sec) *
utils::time::NANOS_PER_SECOND; utils::time::NANOS_PER_SECOND;
ret.modified = static_cast<std::uint64_t>(st.st_mtim.tv_nsec) + ret.modified = static_cast<std::uint64_t>(u_stat.st_mtim.tv_nsec) +
static_cast<std::uint64_t>(st.st_mtim.tv_sec) * static_cast<std::uint64_t>(u_stat.st_mtim.tv_sec) *
utils::time::NANOS_PER_SECOND; utils::time::NANOS_PER_SECOND;
ret.written = static_cast<std::uint64_t>(st.st_mtim.tv_nsec) + ret.written = static_cast<std::uint64_t>(u_stat.st_mtim.tv_nsec) +
static_cast<std::uint64_t>(st.st_mtim.tv_sec) * static_cast<std::uint64_t>(u_stat.st_mtim.tv_sec) *
utils::time::NANOS_PER_SECOND; utils::time::NANOS_PER_SECOND;
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
#endif // defined(_WIN32) #endif // defined(_WIN32)
@@ -306,8 +306,8 @@ auto get_total_drive_space(std::string_view path)
#endif // defined(_WIN32) #endif // defined(_WIN32)
#if defined(__linux__) #if defined(__linux__)
struct statfs64 st{}; struct statfs64 u_stat{};
if (statfs64(std::string{path}.c_str(), &st) != 0) { if (statfs64(std::string{path}.c_str(), &u_stat) != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
"failed to get total disk space", "failed to get total disk space",
@@ -316,12 +316,12 @@ auto get_total_drive_space(std::string_view path)
}); });
} }
return st.f_blocks * static_cast<std::uint64_t>(st.f_bsize); return u_stat.f_blocks * static_cast<std::uint64_t>(u_stat.f_bsize);
#endif // defined(__linux__) #endif // defined(__linux__)
#if defined(__APPLE__) #if defined(__APPLE__)
struct statvfs st{}; struct statvfs u_stat{};
if (statvfs(std::string{path}.c_str(), &st) != 0) { if (statvfs(std::string{path}.c_str(), &u_stat) != 0) {
throw utils::error::create_exception( throw utils::error::create_exception(
function_name, { function_name, {
"failed to get total disk space", "failed to get total disk space",
@@ -330,7 +330,7 @@ auto get_total_drive_space(std::string_view path)
}); });
} }
return st.f_blocks * static_cast<std::uint64_t>(st.f_frsize); return u_stat.f_blocks * static_cast<std::uint64_t>(u_stat.f_frsize);
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
} catch (const std::exception &e) { } catch (const std::exception &e) {
utils::error::handle_exception(function_name, e); utils::error::handle_exception(function_name, e);

View File

@@ -215,8 +215,8 @@ auto directory::exists() const -> bool {
#if defined(_WIN32) #if defined(_WIN32)
return ::PathIsDirectoryA(path_.c_str()) != 0; return ::PathIsDirectoryA(path_.c_str()) != 0;
#else // !defined(_WIN32) #else // !defined(_WIN32)
struct stat64 st{}; struct stat64 u_stat{};
return (stat64(path_.c_str(), &st) == 0 && S_ISDIR(st.st_mode)); return (stat64(path_.c_str(), &u_stat) == 0 && S_ISDIR(u_stat.st_mode));
#endif // defined(_WIN32) #endif // defined(_WIN32)
return false; return false;

View File

@@ -33,13 +33,13 @@ namespace {
file_size = 0U; file_size = 0U;
#if defined(_WIN32) #if defined(_WIN32)
struct _stat64 st{}; struct _stat64 u_stat{};
auto res = _stat64(std::string{path}.c_str(), &st); auto res = _stat64(std::string{path}.c_str(), &u_stat);
if (res != 0) { if (res != 0) {
return false; return false;
} }
file_size = static_cast<std::uint64_t>(st.st_size); file_size = static_cast<std::uint64_t>(u_stat.st_size);
return true; return true;
#else // !defined(_WIN32) #else // !defined(_WIN32)
std::error_code ec{}; std::error_code ec{};
@@ -55,8 +55,9 @@ namespace {
return ((::PathFileExistsA(abs_path.c_str()) != 0) && return ((::PathFileExistsA(abs_path.c_str()) != 0) &&
(::PathIsDirectoryA(abs_path.c_str()) == 0)); (::PathIsDirectoryA(abs_path.c_str()) == 0));
#else // !defined(_WIN32) #else // !defined(_WIN32)
struct stat64 st{}; struct stat64 u_stat{};
return (stat64(abs_path.c_str(), &st) == 0 && not S_ISDIR(st.st_mode)); return (stat64(abs_path.c_str(), &u_stat) == 0 &&
not S_ISDIR(u_stat.st_mode));
#endif // defined(_WIN32) #endif // defined(_WIN32)
} }
} // namespace } // namespace