From 255e4a508b744996191d652af70d912c26c74f56 Mon Sep 17 00:00:00 2001 From: Liryna Date: Sun, 10 Nov 2024 22:34:21 -0500 Subject: [PATCH] FUSE - Set open flags during release #1250 --- dokan_fuse/include/fusemain.h | 5 ++++- dokan_fuse/src/fusemain.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dokan_fuse/include/fusemain.h b/dokan_fuse/include/fusemain.h index 7692de3c..6389de62 100644 --- a/dokan_fuse/include/fusemain.h +++ b/dokan_fuse/include/fusemain.h @@ -232,6 +232,7 @@ class impl_file_handle friend class impl_file_lock; friend class impl_file_locks; bool is_dir_; + int open_flags_; uint64_t fh_; impl_file_handle *next_file; impl_file_lock *file_lock; @@ -247,7 +248,9 @@ class impl_file_handle bool is_dir() const {return is_dir_;} int close(const struct fuse_operations *ops); fuse_file_info make_finfo(); - const std::string& get_name() const {return file_lock->get_name();} + const std::string &get_name() const { return file_lock->get_name(); } + void set_open_flags(int open_flags) { open_flags_ = open_flags; }; + int open_flags() { return open_flags_; }; void set_finfo(const fuse_file_info& finfo) { fh_ = finfo.fh; }; int check_lock(long long start, long long len) { return file_lock->lock_file(this, start, len, false); } int lock(long long start, long long len) { return file_lock->lock_file(this, start, len); } diff --git a/dokan_fuse/src/fusemain.cpp b/dokan_fuse/src/fusemain.cpp index 8914606f..f2964101 100644 --- a/dokan_fuse/src/fusemain.cpp +++ b/dokan_fuse/src/fusemain.cpp @@ -137,8 +137,9 @@ int impl_fuse_context::do_open_file(LPCWSTR FileName, DWORD share_mode, std::unique_ptr file; CHECKED(file_locks.get_file(fname, false, Flags, share_mode, file)); + file->set_open_flags(convert_flags(Flags)); fuse_file_info finfo = {0}; - finfo.flags = convert_flags(Flags); + finfo.flags = file->open_flags(); CHECKED(ops_.open(fname.c_str(), &finfo)); @@ -1178,7 +1179,7 @@ int impl_file_lock::unlock_file(impl_file_handle *file, long long start, ////// File handle /////////////////////////////////////////////////////////////////////////////////////// impl_file_handle::impl_file_handle(bool is_dir, DWORD shared_mode) - : is_dir_(is_dir), fh_(-1), next_file(nullptr), file_lock(nullptr), shared_mode_(shared_mode) {} + : is_dir_(is_dir), open_flags_(0), fh_(-1), next_file(nullptr), file_lock(nullptr), shared_mode_(shared_mode) {} impl_file_handle::~impl_file_handle() { file_lock->remove_file(this); } @@ -1198,7 +1199,7 @@ int impl_file_handle::close(const struct fuse_operations *ops) { if (ops->release) // Ignoring result. { fuse_file_info finfo(make_finfo()); - ops->release(get_name().c_str(), &finfo); // Set open() flags here? + ops->release(get_name().c_str(), &finfo); } } return flush_err; @@ -1207,5 +1208,6 @@ int impl_file_handle::close(const struct fuse_operations *ops) { fuse_file_info impl_file_handle::make_finfo() { fuse_file_info res = {0}; res.fh = fh_; + res.flags = open_flags_; return res; }