mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
restructure readdir, add readdir_plus
Does not enable READDIR_AUTO. Might add in the future.
This commit is contained in:
parent
10e8bd9fa3
commit
d119807adb
29 changed files with 1081 additions and 364 deletions
|
|
@ -32,27 +32,27 @@
|
|||
#include "ugid.hpp"
|
||||
|
||||
#include <fuse.h>
|
||||
#include <fuse_dirents.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
#define NO_OFFSET 0
|
||||
|
||||
namespace l
|
||||
{
|
||||
static
|
||||
int
|
||||
readdir(const Branches &branches_,
|
||||
const char *dirname_,
|
||||
void *buf_,
|
||||
const fuse_fill_dir_t filler_)
|
||||
readdir(const Branches &branches_,
|
||||
const char *dirname_,
|
||||
fuse_dirents_t *buf_)
|
||||
{
|
||||
dev_t dev;
|
||||
HashSet names;
|
||||
string basepath;
|
||||
struct stat st = {0};
|
||||
|
||||
for(size_t i = 0, ei = branches_.size(); i != ei; i++)
|
||||
{
|
||||
|
|
@ -66,24 +66,21 @@ namespace l
|
|||
if(!dh)
|
||||
continue;
|
||||
|
||||
dirfd = fs::dirfd(dh);
|
||||
st.st_dev = fs::devid(dirfd);
|
||||
if(st.st_dev == (dev_t)-1)
|
||||
st.st_dev = i;
|
||||
dirfd = fs::dirfd(dh);
|
||||
dev = fs::devid(dirfd);
|
||||
if(dev == (dev_t)-1)
|
||||
dev = i;
|
||||
|
||||
rv = 0;
|
||||
for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh))
|
||||
{
|
||||
rv = names.put(de->d_name);
|
||||
rv = names.put(de->d_name,_D_EXACT_NAMLEN(de));
|
||||
if(rv == 0)
|
||||
continue;
|
||||
|
||||
st.st_ino = de->d_ino;
|
||||
st.st_mode = DTTOIF(de->d_type);
|
||||
de->d_ino = fs::inode::recompute(de->d_ino,dev);
|
||||
|
||||
fs::inode::recompute(&st);
|
||||
|
||||
rv = filler_(buf_,de->d_name,&st,NO_OFFSET);
|
||||
rv = fuse_dirents_add(buf_,de);
|
||||
if(rv)
|
||||
return (fs::closedir(dh),-ENOMEM);
|
||||
}
|
||||
|
|
@ -98,11 +95,8 @@ namespace l
|
|||
namespace FUSE
|
||||
{
|
||||
int
|
||||
readdir(const char *fusepath_,
|
||||
void *buf_,
|
||||
fuse_fill_dir_t filler_,
|
||||
off_t offset_,
|
||||
fuse_file_info *ffi_)
|
||||
readdir(fuse_file_info *ffi_,
|
||||
fuse_dirents_t *buf_)
|
||||
{
|
||||
DirInfo *di = reinterpret_cast<DirInfo*>(ffi_->fh);
|
||||
const fuse_context *fc = fuse_get_context();
|
||||
|
|
@ -112,7 +106,6 @@ namespace FUSE
|
|||
|
||||
return l::readdir(config.branches,
|
||||
di->fusepath.c_str(),
|
||||
buf_,
|
||||
filler_);
|
||||
buf_);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue