Skip to content

Commit

Permalink
Pass basepath into FileInfo to enable fgetattr
Browse files Browse the repository at this point in the history
  • Loading branch information
PhracturedBlue committed Apr 2, 2024
1 parent 51b891c commit 6c0be44
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/fileinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ class FileInfo : public FH
{
public:
FileInfo(int const fd_,
const std::string &basepath_,
char const *fusepath_,
bool const direct_io_)
: FH(fusepath_),
fd(fd_),
basepath(basepath_),
direct_io(direct_io_)
{
}

public:
int fd;
const std::string &basepath;
uint32_t direct_io:1;
std::mutex mutex;
};
2 changes: 1 addition & 1 deletion src/fuse_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace l
if(rv == -1)
return -errno;

fi = new FileInfo(rv,fusepath_,ffi_->direct_io);
fi = new FileInfo(rv,createpath_,fusepath_,ffi_->direct_io);

ffi_->fh = reinterpret_cast<uint64_t>(fi);

Expand Down
5 changes: 3 additions & 2 deletions src/fuse_fgetattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace l
static
int
fgetattr(const int fd_,
const std::string &basepath_,
const std::string &fusepath_,
struct stat *st_)
{
Expand All @@ -37,7 +38,7 @@ namespace l
if(rv == -1)
return -errno;

fs::inode::calc("",fusepath_,st_);
fs::inode::calc(basepath_,fusepath_,st_);

return 0;
}
Expand All @@ -54,7 +55,7 @@ namespace FUSE
Config::Read cfg;
FileInfo *fi = reinterpret_cast<FileInfo*>(ffi_->fh);

rv = l::fgetattr(fi->fd,fi->fusepath,st_);
rv = l::fgetattr(fi->fd,fi->basepath,fi->fusepath,st_);

timeout_->entry = ((rv >= 0) ?
cfg->cache_entry :
Expand Down
2 changes: 1 addition & 1 deletion src/fuse_open.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ namespace l
if(fd == -1)
return -errno;

fi = new FileInfo(fd,fusepath_,ffi_->direct_io);
fi = new FileInfo(fd,basepath_,fusepath_,ffi_->direct_io);

ffi_->fh = reinterpret_cast<uint64_t>(fi);

Expand Down

0 comments on commit 6c0be44

Please sign in to comment.