This commit is contained in:
Scott E. Graves 2024-11-09 07:22:33 -06:00
parent 73ec7f2252
commit 1d53cd8e8b
10 changed files with 315 additions and 288 deletions

View File

@ -49,9 +49,9 @@ private:
[[nodiscard]] auto get_next_handle() -> std::uint64_t;
[[nodiscard]] auto
populate_file_info(const std::string &api_path,
remote::file_info &file_info) -> packet::error_type;
[[nodiscard]] auto populate_file_info(const std::string &api_path,
remote::file_info &file_info)
-> packet::error_type;
void populate_file_info(const std::string &api_path, const UINT64 &file_size,
const UINT32 &attributes,
@ -72,14 +72,14 @@ public:
[[nodiscard]] auto fuse_chmod(const char *path, const remote::file_mode &mode)
-> packet::error_type override;
[[nodiscard]] auto
fuse_chown(const char *path, const remote::user_id &uid,
const remote::group_id &gid) -> packet::error_type override;
[[nodiscard]] auto fuse_chown(const char *path, const remote::user_id &uid,
const remote::group_id &gid)
-> packet::error_type override;
[[nodiscard]] auto
fuse_create(const char *path, const remote::file_mode &mode,
const remote::open_flags &flags,
remote::file_handle &handle) -> packet::error_type override;
const remote::open_flags &flags, remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto fuse_destroy() -> packet::error_type override;
@ -88,25 +88,28 @@ public:
remote::file_offset &length, const remote::file_handle &handle) override
;*/
[[nodiscard]] auto fuse_fgetattr(
const char *path, remote::stat &r_stat, bool &directory,
const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_fgetattr(const char *path, remote::stat &r_stat,
bool &directory,
const remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto fuse_fsetattr_x(
const char *path, const remote::setattr_x &attr,
const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_fsetattr_x(const char *path,
const remote::setattr_x &attr,
const remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto
fuse_fsync(const char *path, const std::int32_t &datasync,
const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_fsync(const char *path, const std::int32_t &datasync,
const remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto fuse_ftruncate(
const char *path, const remote::file_offset &size,
const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_ftruncate(const char *path,
const remote::file_offset &size,
const remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto
fuse_getattr(const char *path, remote::stat &r_stat,
bool &directory) -> packet::error_type override;
[[nodiscard]] auto fuse_getattr(const char *path, remote::stat &r_stat,
bool &directory)
-> packet::error_type override;
/*[[nodiscard]] packet::error_type fuse_getxattr(const char *path, const char
*name, char *value, const remote::file_size &size) override ;
@ -115,9 +118,10 @@ public:
*name, char *value, const remote::file_size &size, std::uint32_t position)
override ;*/
[[nodiscard]] auto
fuse_getxtimes(const char *path, remote::file_time &bkuptime,
remote::file_time &crtime) -> packet::error_type override;
[[nodiscard]] auto fuse_getxtimes(const char *path,
remote::file_time &bkuptime,
remote::file_time &crtime)
-> packet::error_type override;
[[nodiscard]] auto fuse_init() -> packet::error_type override;
@ -125,28 +129,30 @@ public:
*buffer, const remote::file_size &size) override ;*/
[[nodiscard]] auto
fuse_mkdir(const char *path,
const remote::file_mode &mode) -> packet::error_type override;
fuse_mkdir(const char *path, const remote::file_mode &mode)
-> packet::error_type override;
[[nodiscard]] auto
fuse_open(const char *path, const remote::open_flags &flags,
remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto fuse_open(const char *path,
const remote::open_flags &flags,
remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto fuse_opendir(const char *path, remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto
fuse_read(const char *path, char *buffer, const remote::file_size &read_size,
[[nodiscard]] auto fuse_read(const char *path, char *buffer,
const remote::file_size &read_size,
const remote::file_offset &read_offset,
const remote::file_handle &handle) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto fuse_rename(const char *from,
const char *to) -> packet::error_type override;
[[nodiscard]] auto fuse_rename(const char *from, const char *to)
-> packet::error_type override;
[[nodiscard]] auto
fuse_readdir(const char *path, const remote::file_offset &offset,
const remote::file_handle &handle,
std::string &item_path) -> packet::error_type override;
const remote::file_handle &handle, std::string &item_path)
-> packet::error_type override;
[[nodiscard]] auto fuse_release(const char *path,
const remote::file_handle &handle)
@ -160,8 +166,8 @@ public:
* char *name) override
* ;*/
[[nodiscard]] auto
fuse_rmdir(const char *path) -> packet::error_type override;
[[nodiscard]] auto fuse_rmdir(const char *path)
-> packet::error_type override;
[[nodiscard]] auto fuse_setattr_x(const char *path, remote::setattr_x &attr)
-> packet::error_type override;
@ -178,8 +184,8 @@ public:
const remote::file_time &crtime)
-> packet::error_type override;
[[nodiscard]] auto
fuse_setvolname(const char *volname) -> packet::error_type override;
[[nodiscard]] auto fuse_setvolname(const char *volname)
-> packet::error_type override;
/*[[nodiscard]] packet::error_type fuse_setxattr(const char *path, const char
*name, const char *value, const remote::file_size &size, const std::int32_t
@ -189,67 +195,70 @@ public:
char *name, const char *value, const remote::file_size &size, const
std::int32_t &flags, std::uint32_t position) override ;*/
[[nodiscard]] auto
fuse_statfs(const char *path, std::uint64_t frsize,
remote::statfs &r_stat) -> packet::error_type override;
[[nodiscard]] auto fuse_statfs(const char *path, std::uint64_t frsize,
remote::statfs &r_stat)
-> packet::error_type override;
[[nodiscard]] auto
fuse_statfs_x(const char *path, std::uint64_t bsize,
remote::statfs_x &r_stat) -> packet::error_type override;
[[nodiscard]] auto fuse_statfs_x(const char *path, std::uint64_t bsize,
remote::statfs_x &r_stat)
-> packet::error_type override;
[[nodiscard]] auto
fuse_truncate(const char *path,
const remote::file_offset &size) -> packet::error_type override;
[[nodiscard]] auto fuse_truncate(const char *path,
const remote::file_offset &size)
-> packet::error_type override;
[[nodiscard]] auto
fuse_unlink(const char *path) -> packet::error_type override;
[[nodiscard]] auto fuse_unlink(const char *path)
-> packet::error_type override;
[[nodiscard]] auto
fuse_utimens(const char *path, const remote::file_time *tv, std::uint64_t op0,
std::uint64_t op1) -> packet::error_type override;
[[nodiscard]] auto fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0, std::uint64_t op1)
-> packet::error_type override;
[[nodiscard]] auto
fuse_write(const char *path, const char *buffer,
[[nodiscard]] auto fuse_write(const char *path, const char *buffer,
const remote::file_size &write_size,
const remote::file_offset &write_offset,
const remote::file_handle &handle) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
[[nodiscard]] auto fuse_write_base64(
const char *path, const char *buffer, const remote::file_size &write_size,
[[nodiscard]] auto fuse_write_base64(const char *path, const char *buffer,
const remote::file_size &write_size,
const remote::file_offset &write_offset,
const remote::file_handle &handle) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
void set_fuse_uid_gid(const remote::user_id &,
const remote::group_id &) override {}
// JSON Layer
[[nodiscard]] auto
winfsp_get_dir_buffer(PVOID /*file_desc*/,
PVOID *& /*ptr*/) -> packet::error_type override {
[[nodiscard]] auto winfsp_get_dir_buffer(PVOID /*file_desc*/,
PVOID *& /*ptr*/)
-> packet::error_type override {
return static_cast<packet::error_type>(STATUS_INVALID_HANDLE);
}
[[nodiscard]] auto json_create_directory_snapshot(
const std::string &path, json &json_data) -> packet::error_type override;
[[nodiscard]] auto json_create_directory_snapshot(const std::string &path,
json &json_data)
-> packet::error_type override;
[[nodiscard]] auto json_read_directory_snapshot(
const std::string &path, const remote::file_handle &handle,
std::uint32_t page, json &json_data) -> packet::error_type override;
[[nodiscard]] auto json_release_directory_snapshot(
const std::string &path,
const remote::file_handle &handle) -> packet::error_type override;
[[nodiscard]] auto
json_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle)
-> packet::error_type override;
// WinFSP Layer
[[nodiscard]] auto winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type override;
[[nodiscard]] auto winfsp_cleanup(PVOID file_desc, PWSTR file_name,
UINT32 flags, BOOLEAN &was_deleted)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_close(PVOID file_desc) -> packet::error_type override;
[[nodiscard]] auto winfsp_close(PVOID file_desc)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
@ -264,57 +273,63 @@ public:
remote::file_info *file_info)
-> packet::error_type override;
[[nodiscard]] auto winfsp_get_security_by_name(
PWSTR file_name, PUINT32 attributes,
[[nodiscard]] auto
winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes,
std::uint64_t * /*security_descriptor_size*/,
std::wstring & /*str_descriptor*/) -> packet::error_type override;
std::wstring & /*str_descriptor*/)
-> packet::error_type override;
[[nodiscard]] auto winfsp_get_volume_info(
UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) -> packet::error_type override;
[[nodiscard]] auto winfsp_get_volume_info(UINT64 &total_size,
UINT64 &free_size,
std::string &volume_label)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_mounted(const std::wstring &location) -> packet::error_type override;
[[nodiscard]] auto winfsp_mounted(const std::wstring &location)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
PVOID *file_desc, remote::file_info *file_info,
std::string &normalized_name) -> packet::error_type override;
[[nodiscard]] auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info,
std::string &normalized_name)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 /*allocation_size*/,
remote::file_info *file_info) -> packet::error_type override;
[[nodiscard]] auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes,
UINT64 /*allocation_size*/,
remote::file_info *file_info)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type override;
[[nodiscard]] auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
UINT32 length, PUINT32 bytes_transferred)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/, PWSTR marker,
json &itemList) -> packet::error_type override;
[[nodiscard]] auto winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
PWSTR marker, json &itemList)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type override;
[[nodiscard]] auto winfsp_rename(PVOID /*file_desc*/, PWSTR file_name,
PWSTR new_file_name,
BOOLEAN replace_if_exists)
-> packet::error_type override;
[[nodiscard]] auto winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info) -> packet::error_type override;
[[nodiscard]] auto winfsp_set_file_size(
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) -> packet::error_type override;
[[nodiscard]] auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size,
remote::file_info *file_info)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
[[nodiscard]] auto winfsp_unmounted(const std::wstring &location)
-> packet::error_type override;
[[nodiscard]] auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io,
PUINT32 bytes_transferred,
remote::file_info *file_info) -> packet::error_type override;
PUINT32 bytes_transferred, remote::file_info *file_info)
-> packet::error_type override;
};
} // namespace remote_fuse
} // namespace repertory

View File

@ -85,10 +85,10 @@ public:
UINT32 flags{};
DECODE_OR_RETURN(request, flags);
BOOLEAN was_closed{};
BOOLEAN was_deleted{};
ret = this->winfsp_cleanup(file_desc, file_name.data(), flags,
was_closed);
response.encode(was_closed);
was_deleted);
response.encode(was_deleted);
return ret;
}});

View File

@ -29,11 +29,11 @@ class i_remote_instance : public virtual i_remote_json {
INTERFACE_SETUP(i_remote_instance);
public:
virtual auto winfsp_can_delete(PVOID file_desc,
PWSTR file_name) -> packet::error_type = 0;
virtual auto winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type = 0;
virtual auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type = 0;
BOOLEAN &was_deleted) -> packet::error_type = 0;
virtual auto winfsp_close(PVOID file_desc) -> packet::error_type = 0;
@ -41,72 +41,76 @@ public:
UINT32 granted_access, UINT32 file_attributes,
UINT64 allocation_size, PVOID *file_desc,
remote::file_info *file_info,
std::string &normalized_name,
BOOLEAN &exists) -> packet::error_type = 0;
std::string &normalized_name, BOOLEAN &exists)
-> packet::error_type = 0;
virtual auto winfsp_flush(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type = 0;
virtual auto winfsp_get_dir_buffer(PVOID file_desc,
PVOID *&ptr) -> packet::error_type = 0;
virtual auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type = 0;
virtual auto winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info)
-> packet::error_type = 0;
virtual auto
winfsp_get_file_info(PVOID file_desc,
remote::file_info *file_info) -> packet::error_type = 0;
virtual auto winfsp_get_security_by_name(
PWSTR file_name, PUINT32 file_attributes,
winfsp_get_security_by_name(PWSTR file_name, PUINT32 file_attributes,
std::uint64_t *security_descriptor_size,
std::wstring &str_descriptor) -> packet::error_type = 0;
std::wstring &str_descriptor)
-> packet::error_type = 0;
virtual auto
winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) -> packet::error_type = 0;
virtual auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label)
-> packet::error_type = 0;
virtual auto
winfsp_mounted(const std::wstring &location) -> packet::error_type = 0;
virtual auto winfsp_mounted(const std::wstring &location)
-> packet::error_type = 0;
virtual auto
winfsp_open(PWSTR file_name, UINT32 create_options, UINT32 granted_access,
PVOID *file_desc, remote::file_info *file_info,
std::string &normalized_name) -> packet::error_type = 0;
virtual auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info,
std::string &normalized_name)
-> packet::error_type = 0;
virtual auto
winfsp_overwrite(PVOID file_desc, UINT32 file_attributes,
BOOLEAN replace_file_attributes, UINT64 allocation_size,
remote::file_info *file_info) -> packet::error_type = 0;
virtual auto winfsp_overwrite(PVOID file_desc, UINT32 file_attributes,
BOOLEAN replace_file_attributes,
UINT64 allocation_size,
remote::file_info *file_info)
-> packet::error_type = 0;
virtual auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset,
UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type = 0;
UINT32 length, PUINT32 bytes_transferred)
-> packet::error_type = 0;
virtual auto winfsp_read_directory(PVOID file_desc, PWSTR pattern,
PWSTR marker,
json &itemList) -> packet::error_type = 0;
PWSTR marker, json &itemList)
-> packet::error_type = 0;
virtual auto
winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type = 0;
virtual auto winfsp_rename(PVOID file_desc, PWSTR file_name,
PWSTR new_file_name, BOOLEAN replace_if_exists)
-> packet::error_type = 0;
virtual auto
winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes,
UINT64 creation_time, UINT64 last_access_time,
virtual auto winfsp_set_basic_info(PVOID file_desc, UINT32 file_attributes,
UINT64 creation_time,
UINT64 last_access_time,
UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info) -> packet::error_type = 0;
remote::file_info *file_info)
-> packet::error_type = 0;
virtual auto
winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
virtual auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size,
remote::file_info *file_info) -> packet::error_type = 0;
remote::file_info *file_info)
-> packet::error_type = 0;
virtual auto
winfsp_unmounted(const std::wstring &location) -> packet::error_type = 0;
virtual auto winfsp_unmounted(const std::wstring &location)
-> packet::error_type = 0;
virtual auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io,
PUINT32 bytes_transferred,
remote::file_info *file_info) -> packet::error_type = 0;
virtual auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
UINT32 length, BOOLEAN write_to_end,
BOOLEAN constrained_io, PUINT32 bytes_transferred,
remote::file_info *file_info)
-> packet::error_type = 0;
};
using remote_instance_factory =

View File

@ -50,19 +50,20 @@ public:
auto json_create_directory_snapshot(const std::string &path, json &json_data)
-> packet::error_type override;
auto json_read_directory_snapshot(
const std::string &path, const remote::file_handle &handle,
std::uint32_t page, json &json_data) -> packet::error_type override;
auto json_read_directory_snapshot(const std::string &path,
const remote::file_handle &handle,
std::uint32_t page, json &json_data)
-> packet::error_type override;
auto json_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle)
-> packet::error_type override;
auto winfsp_can_delete(PVOID file_desc,
PWSTR file_name) -> packet::error_type override;
auto winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type override;
auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type override;
BOOLEAN &was_deleted) -> packet::error_type override;
auto winfsp_close(PVOID file_desc) -> packet::error_type override;
@ -75,32 +76,33 @@ public:
auto winfsp_flush(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc,
PVOID *&ptr) -> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type override;
auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_get_security_by_name(
PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
std::wstring &string_descriptor) -> packet::error_type override;
auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes,
std::uint64_t *descriptor_size,
std::wstring &string_descriptor)
-> packet::error_type override;
auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label)
-> packet::error_type override;
auto
winfsp_mounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_mounted(const std::wstring &location)
-> packet::error_type override;
auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info,
std::string &normalized_name) -> packet::error_type override;
remote::file_info *file_info, std::string &normalized_name)
-> packet::error_type override;
auto
winfsp_overwrite(PVOID file_desc, UINT32 attributes,
auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size,
remote::file_info *file_info) -> packet::error_type override;
remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type override;
@ -111,23 +113,24 @@ public:
auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type override;
auto winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info) -> packet::error_type override;
auto winfsp_set_basic_info(PVOID file_desc, UINT32 attributes,
UINT64 creation_time, UINT64 last_access_time,
UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_set_file_size(
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) -> packet::error_type override;
auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size,
remote::file_info *file_info)
-> packet::error_type override;
auto
winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_unmounted(const std::wstring &location)
-> packet::error_type override;
auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io,
PUINT32 bytes_transferred,
remote::file_info *file_info) -> packet::error_type override;
PUINT32 bytes_transferred, remote::file_info *file_info)
-> packet::error_type override;
};
} // namespace remote_winfsp
} // namespace repertory

View File

@ -49,23 +49,23 @@ private:
[[nodiscard]] auto get_next_handle() -> std::uint64_t;
[[nodiscard]] auto
populate_file_info(const std::string &api_path,
remote::file_info &file_info) -> packet::error_type;
[[nodiscard]] auto populate_file_info(const std::string &api_path,
remote::file_info &file_info)
-> packet::error_type;
void populate_stat(const char *path, bool directory, remote::stat &r_stat,
const struct _stat64 &unix_st);
public:
// FUSE Layer
auto fuse_access(const char *path,
const std::int32_t &mask) -> packet::error_type override;
auto fuse_access(const char *path, const std::int32_t &mask)
-> packet::error_type override;
auto fuse_chflags(const char *path,
std::uint32_t flags) -> packet::error_type override;
auto fuse_chflags(const char *path, std::uint32_t flags)
-> packet::error_type override;
auto fuse_chmod(const char *path,
const remote::file_mode &mode) -> packet::error_type override;
auto fuse_chmod(const char *path, const remote::file_mode &mode)
-> packet::error_type override;
auto fuse_chown(const char *path, const remote::user_id &uid,
const remote::group_id &gid) -> packet::error_type override;
@ -84,16 +84,16 @@ public:
const remote::file_handle &handle)
-> packet::error_type override;
auto
fuse_fsync(const char *path, const std::int32_t &datasync,
const remote::file_handle &handle) -> packet::error_type override;
auto fuse_fsync(const char *path, const std::int32_t &datasync,
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_ftruncate(const char *path, const remote::file_offset &size,
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_getattr(const char *path, remote::stat &r_stat,
bool &directory) -> packet::error_type override;
auto fuse_getattr(const char *path, remote::stat &r_stat, bool &directory)
-> packet::error_type override;
/*packet::error_type fuse_getxattr(const char *path, const char *name, char
*value, const remote::file_size &size) override ;
@ -110,41 +110,43 @@ public:
const remote::file_size &size) override
;*/
auto fuse_mkdir(const char *path,
const remote::file_mode &mode) -> packet::error_type override;
auto fuse_mkdir(const char *path, const remote::file_mode &mode)
-> packet::error_type override;
auto fuse_opendir(const char *path,
remote::file_handle &handle) -> packet::error_type override;
auto fuse_opendir(const char *path, remote::file_handle &handle)
-> packet::error_type override;
auto fuse_create(const char *path, const remote::file_mode &mode,
const remote::open_flags &flags,
remote::file_handle &handle) -> packet::error_type override;
const remote::open_flags &flags, remote::file_handle &handle)
-> packet::error_type override;
auto fuse_open(const char *path, const remote::open_flags &flags,
remote::file_handle &handle) -> packet::error_type override;
auto
fuse_read(const char *path, char *buffer, const remote::file_size &read_size,
auto fuse_read(const char *path, char *buffer,
const remote::file_size &read_size,
const remote::file_offset &read_offset,
const remote::file_handle &handle) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_rename(const char *from,
const char *to) -> packet::error_type override;
auto fuse_rename(const char *from, const char *to)
-> packet::error_type override;
auto
fuse_write(const char *path, const char *buffer,
auto fuse_write(const char *path, const char *buffer,
const remote::file_size &write_size,
const remote::file_offset &write_offset,
const remote::file_handle &handle) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_write_base64(
const char *path, const char *buffer, const remote::file_size &write_size,
auto fuse_write_base64(const char *path, const char *buffer,
const remote::file_size &write_size,
const remote::file_offset &write_offset,
const remote::file_handle &handle) -> packet::error_type override;
const remote::file_handle &handle)
-> packet::error_type override;
auto fuse_readdir(const char *path, const remote::file_offset &offset,
const remote::file_handle &handle,
std::string &item_path) -> packet::error_type override;
const remote::file_handle &handle, std::string &item_path)
-> packet::error_type override;
auto fuse_release(const char *path, const remote::file_handle &handle)
-> packet::error_type override;
@ -157,8 +159,8 @@ public:
auto fuse_rmdir(const char *path) -> packet::error_type override;
auto fuse_setattr_x(const char *path,
remote::setattr_x &attr) -> packet::error_type override;
auto fuse_setattr_x(const char *path, remote::setattr_x &attr)
-> packet::error_type override;
auto fuse_setbkuptime(const char *path, const remote::file_time &bkuptime)
-> packet::error_type override;
@ -191,8 +193,8 @@ public:
auto fuse_unlink(const char *path) -> packet::error_type override;
auto fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0,
std::uint64_t op1) -> packet::error_type override;
std::uint64_t op0, std::uint64_t op1)
-> packet::error_type override;
void set_fuse_uid_gid(const remote::user_id & /* uid */,
const remote::group_id & /* gid */) override {}
@ -201,20 +203,21 @@ public:
auto json_create_directory_snapshot(const std::string &path, json &json_data)
-> packet::error_type override;
auto json_read_directory_snapshot(
const std::string &path, const remote::file_handle &handle,
std::uint32_t page, json &json_data) -> packet::error_type override;
auto json_read_directory_snapshot(const std::string &path,
const remote::file_handle &handle,
std::uint32_t page, json &json_data)
-> packet::error_type override;
auto json_release_directory_snapshot(const std::string &path,
const remote::file_handle &handle)
-> packet::error_type override;
// WinFSP Layer
auto winfsp_can_delete(PVOID file_desc,
PWSTR file_name) -> packet::error_type override;
auto winfsp_can_delete(PVOID file_desc, PWSTR file_name)
-> packet::error_type override;
auto winfsp_cleanup(PVOID file_desc, PWSTR file_name, UINT32 flags,
BOOLEAN &was_closed) -> packet::error_type override;
BOOLEAN &was_deleted) -> packet::error_type override;
auto winfsp_close(PVOID file_desc) -> packet::error_type override;
@ -227,32 +230,33 @@ public:
auto winfsp_flush(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc,
PVOID *&ptr) -> packet::error_type override;
auto winfsp_get_dir_buffer(PVOID file_desc, PVOID *&ptr)
-> packet::error_type override;
auto winfsp_get_file_info(PVOID file_desc, remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_get_security_by_name(
PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size,
std::wstring &string_descriptor) -> packet::error_type override;
auto winfsp_get_security_by_name(PWSTR file_name, PUINT32 attributes,
std::uint64_t *descriptor_size,
std::wstring &string_descriptor)
-> packet::error_type override;
auto winfsp_get_volume_info(UINT64 &total_size, UINT64 &free_size,
std::string &volume_label)
-> packet::error_type override;
auto
winfsp_mounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_mounted(const std::wstring &location)
-> packet::error_type override;
auto winfsp_open(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, PVOID *file_desc,
remote::file_info *file_info,
std::string &normalized_name) -> packet::error_type override;
remote::file_info *file_info, std::string &normalized_name)
-> packet::error_type override;
auto
winfsp_overwrite(PVOID file_desc, UINT32 attributes,
auto winfsp_overwrite(PVOID file_desc, UINT32 attributes,
BOOLEAN replace_attributes, UINT64 allocation_size,
remote::file_info *file_info) -> packet::error_type override;
remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
PUINT32 bytes_transferred) -> packet::error_type override;
@ -263,23 +267,24 @@ public:
auto winfsp_rename(PVOID file_desc, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) -> packet::error_type override;
auto winfsp_set_basic_info(
PVOID file_desc, UINT32 attributes, UINT64 creation_time,
UINT64 last_access_time, UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info) -> packet::error_type override;
auto winfsp_set_basic_info(PVOID file_desc, UINT32 attributes,
UINT64 creation_time, UINT64 last_access_time,
UINT64 last_write_time, UINT64 change_time,
remote::file_info *file_info)
-> packet::error_type override;
auto winfsp_set_file_size(
PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) -> packet::error_type override;
auto winfsp_set_file_size(PVOID file_desc, UINT64 new_size,
BOOLEAN set_allocation_size,
remote::file_info *file_info)
-> packet::error_type override;
auto
winfsp_unmounted(const std::wstring &location) -> packet::error_type override;
auto winfsp_unmounted(const std::wstring &location)
-> packet::error_type override;
auto
winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
auto winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN write_to_end, BOOLEAN constrained_io,
PUINT32 bytes_transferred,
remote::file_info *file_info) -> packet::error_type override;
PUINT32 bytes_transferred, remote::file_info *file_info)
-> packet::error_type override;
};
} // namespace remote_winfsp
} // namespace repertory

View File

@ -1041,18 +1041,18 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name)
}
auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name,
UINT32 flags, BOOLEAN &was_closed)
UINT32 flags, BOOLEAN &was_deleted)
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME();
const auto relative_path = utils::string::to_utf8(file_name);
const auto file_path = construct_path(relative_path);
was_closed = 0;
was_deleted = 0U;
const auto directory = utils::file::directory(file_path).exists();
if (flags & FileSystemBase::FspCleanupDelete) {
remove_all(file_path);
was_closed = 1;
was_deleted = 1U;
if (directory) {
rmdir(file_path.c_str());

View File

@ -136,7 +136,7 @@ auto remote_client::json_release_directory_snapshot(
}
auto remote_client::winfsp_cleanup(PVOID file_desc, PWSTR file_name,
UINT32 flags, BOOLEAN &was_closed)
UINT32 flags, BOOLEAN &was_deleted)
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME();
@ -148,7 +148,7 @@ auto remote_client::winfsp_cleanup(PVOID file_desc, PWSTR file_name,
get_open_file_path(handle),
};
was_closed = 0;
was_deleted = 0U;
packet request;
request.encode(file_desc);
@ -161,8 +161,8 @@ auto remote_client::winfsp_cleanup(PVOID file_desc, PWSTR file_name,
packet_client_.send(function_name, request, response, service_flags),
};
DECODE_OR_IGNORE(&response, was_closed);
if (was_closed != 0U) {
DECODE_OR_IGNORE(&response, was_deleted);
if (was_deleted != 0U) {
remove_all(file_path);
}

View File

@ -936,18 +936,18 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR /*file_name*/)
}
auto remote_server::winfsp_cleanup(PVOID file_desc, PWSTR /*file_name*/,
UINT32 flags, BOOLEAN &was_closed)
UINT32 flags, BOOLEAN &was_deleted)
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME();
auto file_path = get_open_file_path(file_desc);
was_closed = FALSE;
was_deleted = FALSE;
auto *handle = reinterpret_cast<HANDLE>(file_desc);
auto ret = has_open_info(handle, STATUS_INVALID_HANDLE);
if (ret == STATUS_SUCCESS) {
if ((flags & FspCleanupDelete) != 0U) {
remove_and_close_all(file_desc);
was_closed = TRUE;
was_deleted = TRUE;
}
}

View File

@ -114,8 +114,8 @@ auto remote_winfsp_drive::CanDelete(PVOID /*file_node*/, PVOID file_desc,
VOID remote_winfsp_drive::Cleanup(PVOID /*file_node*/, PVOID file_desc,
PWSTR file_name, ULONG flags) {
BOOLEAN was_closed{};
remote_instance_->winfsp_cleanup(file_desc, file_name, flags, was_closed);
BOOLEAN was_deleted{};
remote_instance_->winfsp_cleanup(file_desc, file_name, flags, was_deleted);
}
VOID remote_winfsp_drive::Close(PVOID /*file_node*/, PVOID file_desc) {

View File

@ -102,10 +102,10 @@ static void cleanup_test(remote_client &client) {
normalized_name, exists);
EXPECT_EQ(STATUS_SUCCESS, ret);
BOOLEAN was_closed = 0u;
BOOLEAN was_deleted{0U};
EXPECT_EQ(STATUS_SUCCESS,
client.winfsp_cleanup(file_desc, &api_path[0], 0, was_closed));
EXPECT_FALSE(was_closed);
client.winfsp_cleanup(file_desc, &api_path[0], 0, was_deleted));
EXPECT_FALSE(was_deleted);
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
EXPECT_TRUE(utils::file::file(test_file).remove());