mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 04:46:41 -05:00
fix getdent name length calculation
This commit is contained in:
parent
b5fae4b356
commit
698c4147fc
9 changed files with 101 additions and 87 deletions
|
|
@ -45,6 +45,26 @@ using std::vector;
|
|||
|
||||
namespace l
|
||||
{
|
||||
static
|
||||
uint64_t
|
||||
dirent_exact_namelen(const struct dirent *d_)
|
||||
{
|
||||
#ifdef _D_EXACT_NAMLEN
|
||||
return _D_EXACT_NAMLEN(d_);
|
||||
#elif defined _DIRENT_HAVE_D_NAMLEN
|
||||
return d_->d_namlen;
|
||||
#else
|
||||
return strlen(d_->d_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
uint64_t
|
||||
dirent_alloc_namelen(const struct dirent *d_)
|
||||
{
|
||||
return (dirent_exact_namelen(d_) + 1);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
readdir_plus(const Branches &branches_,
|
||||
|
|
@ -55,6 +75,7 @@ namespace l
|
|||
HashSet names;
|
||||
string basepath;
|
||||
struct stat st;
|
||||
uint64_t namelen;
|
||||
fuse_entry_t entry;
|
||||
|
||||
entry.nodeid = 0;
|
||||
|
|
@ -83,7 +104,9 @@ namespace l
|
|||
rv = 0;
|
||||
for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh))
|
||||
{
|
||||
rv = names.put(de->d_name);
|
||||
namelen = l::dirent_alloc_namelen(de);
|
||||
|
||||
rv = names.put(de->d_name,namelen);
|
||||
if(rv == 0)
|
||||
continue;
|
||||
|
||||
|
|
@ -94,7 +117,7 @@ namespace l
|
|||
de->d_ino = fs::inode::recompute(de->d_ino,dev);
|
||||
st.st_ino = de->d_ino;
|
||||
|
||||
rv = fuse_dirents_add_plus(buf_,de,&entry,&st);
|
||||
rv = fuse_dirents_add_plus(buf_,de,namelen,&entry,&st);
|
||||
if(rv)
|
||||
return (fs::closedir(dh),-ENOMEM);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue