Browse Source

fix name length calculation for musc

pull/722/head
Antonio SJ Musumeci 5 years ago
parent
commit
9b2634a1e5
  1. 24
      libfuse/lib/fuse_dirents.c
  2. 15
      src/fuse_readdir_plus_posix.icpp
  3. 15
      src/fuse_readdir_posix.icpp

24
libfuse/lib/fuse_dirents.c

@ -17,6 +17,26 @@
#define DEFAULT_SIZE (1024 * 16) #define DEFAULT_SIZE (1024 * 16)
static
uint64_t
dirent_exact_namelen(const struct dirent *d_)
{
#ifdef _D_EXACT_NAMELEN
return _D_EXACT_NAMELEN(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 static
uint64_t uint64_t
align_uint64_t(uint64_t v_) align_uint64_t(uint64_t v_)
@ -251,7 +271,7 @@ fuse_dirents_add(fuse_dirents_t *d_,
return -EINVAL; return -EINVAL;
} }
namelen = _D_ALLOC_NAMLEN(dirent_);
namelen = dirent_alloc_namelen(dirent_);
size = fuse_dirent_size(namelen); size = fuse_dirent_size(namelen);
d = fuse_dirents_alloc(d_,size); d = fuse_dirents_alloc(d_,size);
@ -288,7 +308,7 @@ fuse_dirents_add_plus(fuse_dirents_t *d_,
break; break;
} }
namelen = _D_ALLOC_NAMLEN(dirent_);
namelen = dirent_alloc_namelen(dirent_);
size = fuse_direntplus_size(namelen); size = fuse_direntplus_size(namelen);
d = fuse_dirents_alloc(d_,size); d = fuse_dirents_alloc(d_,size);

15
src/fuse_readdir_plus_posix.icpp

@ -45,6 +45,19 @@ using std::vector;
namespace l namespace l
{ {
static
uint64_t
dirent_exact_namelen(const struct dirent *d_)
{
#ifdef _D_EXACT_NAMELEN
return _D_EXACT_NAMELEN(d_);
#elif defined _DIRENT_HAVE_D_NAMLEN
return d_->d_namlen;
#else
return strlen(d_->d_name);
#endif
}
static static
int int
readdir_plus(const Branches &branches_, readdir_plus(const Branches &branches_,
@ -83,7 +96,7 @@ namespace l
rv = 0; rv = 0;
for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh)) for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh))
{ {
rv = names.put(de->d_name,_D_EXACT_NAMLEN(de));
rv = names.put(de->d_name,l::dirent_exact_namelen(de));
if(rv == 0) if(rv == 0)
continue; continue;

15
src/fuse_readdir_posix.icpp

@ -44,6 +44,19 @@ using std::vector;
namespace l namespace l
{ {
static
uint64_t
dirent_exact_namelen(const struct dirent *d_)
{
#ifdef _D_EXACT_NAMELEN
return _D_EXACT_NAMELEN(d_);
#elif defined _DIRENT_HAVE_D_NAMLEN
return d_->d_namlen;
#else
return strlen(d_->d_name);
#endif
}
static static
int int
readdir(const Branches &branches_, readdir(const Branches &branches_,
@ -74,7 +87,7 @@ namespace l
rv = 0; rv = 0;
for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh)) for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh))
{ {
rv = names.put(de->d_name,_D_EXACT_NAMLEN(de));
rv = names.put(de->d_name,l::dirent_exact_namelen(de));
if(rv == 0) if(rv == 0)
continue; continue;

Loading…
Cancel
Save