Browse Source

Merge pull request #722 from trapexit/alpine

fix name length calculation for musc
pull/723/head
trapexit 5 years ago
committed by GitHub
parent
commit
ada90eab57
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  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)
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
uint64_t
align_uint64_t(uint64_t v_)
@ -251,7 +271,7 @@ fuse_dirents_add(fuse_dirents_t *d_,
return -EINVAL;
}
namelen = _D_ALLOC_NAMLEN(dirent_);
namelen = dirent_alloc_namelen(dirent_);
size = fuse_dirent_size(namelen);
d = fuse_dirents_alloc(d_,size);
@ -288,7 +308,7 @@ fuse_dirents_add_plus(fuse_dirents_t *d_,
break;
}
namelen = _D_ALLOC_NAMLEN(dirent_);
namelen = dirent_alloc_namelen(dirent_);
size = fuse_direntplus_size(namelen);
d = fuse_dirents_alloc(d_,size);

15
src/fuse_readdir_plus_posix.icpp

@ -45,6 +45,19 @@ using std::vector;
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
int
readdir_plus(const Branches &branches_,
@ -83,7 +96,7 @@ namespace l
rv = 0;
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)
continue;

15
src/fuse_readdir_posix.icpp

@ -44,6 +44,19 @@ using std::vector;
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
int
readdir(const Branches &branches_,
@ -74,7 +87,7 @@ namespace l
rv = 0;
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)
continue;

Loading…
Cancel
Save