When file unlinked check open_files map

Inadvertantly removed. Didn't realize that the kernel would not always
send file handle when unlinked.
This commit is contained in:
Antonio SJ Musumeci 2026-04-28 09:07:27 -05:00 • committed by trapexit
parent 7616d8b1ac
commit 9308a3729c
16 changed files with 140 additions and 36 deletions

View file

@ -22,6 +22,7 @@
#include "fileinfo.hpp"
#include "fs_close.hpp"
#include "fs_dup.hpp"
#include "state.hpp"
#include "fuse.h"
@ -39,12 +40,20 @@ _flush(const int fd_)
return fs::close(rv);
}
// In cases where the node was opened but unlinked there will be no
// path and no guarentee of a `fh`. It could always do the lookup but
// why bother if the kernel has provided it to us? The reason the
// function doesn't need to run within the visit lambda is because
// since the request is outstanding the kernel won't be releasing the
// node and therefore the entry will be valid over the lifetime of
// this function.
int
FUSE::flush(const fuse_req_ctx_t *ctx_,
const fuse_file_info_t *ffi_)
{
FileInfo *fi = FileInfo::from_fh(ffi_->fh);
FileInfo *fi;
fi = state.get_fi(ctx_,ffi_->fh);
if(not fi)
return -EBADF;