Skip to content

Commit

Permalink
FUSE - Set open flags during release
Browse files Browse the repository at this point in the history
  • Loading branch information
Liryna committed Nov 11, 2024
1 parent 45021e0 commit 255e4a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion dokan_fuse/include/fusemain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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); }
Expand Down
8 changes: 5 additions & 3 deletions dokan_fuse/src/fusemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ int impl_fuse_context::do_open_file(LPCWSTR FileName, DWORD share_mode,
std::unique_ptr<impl_file_handle> 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));

Expand Down Expand Up @@ -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); }

Expand All @@ -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;
Expand All @@ -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;
}

0 comments on commit 255e4a5

Please sign in to comment.