mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-19 16:16:48 +00:00
Several FUSE ops fell back to looking up a FileInfo via state.open_files when the kernel-provided fh was zero, returning -ENOENT if the lookup failed. This path papered over handle-tracking bugs and added cost on every call. Use the handle directly and return -EBADF when it is invalid - the kernel should always hand us a valid fh for an open resource. Also simplify FileInfo::from_fh / DirInfo::from_fh and their to_fh helpers: callers now handle the null-pointer case explicitly so the ASSERT_NOT_NULL checks are redundant. Covers fallocate, fchmod, fchown, fgetattr, flock, ftruncate, futimens, read, release, releasedir, write, statx, ioctl (file + dir), readdir (sequential, concurrent-on-read, concurrent-on-search), and the passthrough fast paths in create/open.
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
/*
|
|
ISC License
|
|
|
|
Copyright (c) 2026, Antonio SJ Musumeci <trapexit@spawn.link>
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#include "fuse_fchmod.hpp"
|
|
|
|
#include "errno.hpp"
|
|
#include "fileinfo.hpp"
|
|
#include "fs_fchmod.hpp"
|
|
#include "state.hpp"
|
|
|
|
#include "fuse.h"
|
|
|
|
|
|
static
|
|
int
|
|
_fchmod(const int fd_,
|
|
const mode_t mode_)
|
|
{
|
|
int rv;
|
|
|
|
rv = fs::fchmod(fd_,mode_);
|
|
|
|
return rv;
|
|
}
|
|
|
|
int
|
|
FUSE::fchmod(const fuse_req_ctx_t *ctx_,
|
|
cu64 fh_,
|
|
const mode_t mode_)
|
|
{
|
|
FileInfo *fi = FileInfo::from_fh(fh_);
|
|
|
|
if(not fi)
|
|
return -EBADF;
|
|
|
|
return ::_fchmod(fi->fd,mode_);
|
|
}
|