Browse Source

Merge pull request #723 from trapexit/getdents

fix filename hashing error
pull/726/head
trapexit 5 years ago
committed by GitHub
parent
commit
14d26ba434
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/fuse_readdir_linux.icpp
  2. 8
      src/fuse_readdir_plus_linux.icpp
  3. 15
      src/fuse_readdir_plus_posix.icpp
  4. 15
      src/fuse_readdir_posix.icpp
  5. 7
      src/hashset.hpp

8
src/fuse_readdir_linux.icpp

@ -94,7 +94,6 @@ namespace l
{
int dirfd;
int64_t nread;
uint64_t namelen;
basepath = fs::path::make(&branches_[i].path,dirname_);
@ -114,12 +113,11 @@ namespace l
if(nread == 0)
break;
for(int64_t pos = 0; pos < nread;)
for(int64_t pos = 0; pos < nread; pos += d->d_reclen)
{
d = (struct linux_dirent64*)(buf + pos);
namelen = (d->d_reclen - offsetof(struct linux_dirent64,d_name));
rv = names.put(d->d_name,namelen);
rv = names.put(d->d_name);
if(rv == 0)
continue;
@ -128,8 +126,6 @@ namespace l
rv = fuse_dirents_add_linux(buf_,d);
if(rv)
return close_free_ret_enomem(dirfd,buf);
pos += d->d_reclen;
}
}

8
src/fuse_readdir_plus_linux.icpp

@ -100,7 +100,6 @@ namespace l
{
int dirfd;
int64_t nread;
uint64_t namelen;
basepath = fs::path::make(&branches_[i].path,dirname_);
@ -120,12 +119,11 @@ namespace l
if(nread == 0)
break;
for(int64_t pos = 0; pos < nread;)
for(int64_t pos = 0; pos < nread; pos += d->d_reclen)
{
d = (struct linux_dirent64*)(buf + pos);
namelen = (d->d_reclen - offsetof(struct linux_dirent64,d_name));
rv = names.put(d->d_name,namelen);
rv = names.put(d->d_name);
if(rv == 0)
continue;
@ -139,8 +137,6 @@ namespace l
rv = fuse_dirents_add_linux_plus(buf_,d,&entry,&st);
if(rv)
return close_free_ret_enomem(dirfd,buf);
pos += d->d_reclen;
}
}

15
src/fuse_readdir_plus_posix.icpp

@ -45,19 +45,6 @@ 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_,
@ -96,7 +83,7 @@ namespace l
rv = 0;
for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh))
{
rv = names.put(de->d_name,l::dirent_exact_namelen(de));
rv = names.put(de->d_name);
if(rv == 0)
continue;

15
src/fuse_readdir_posix.icpp

@ -44,19 +44,6 @@ 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_,
@ -87,7 +74,7 @@ namespace l
rv = 0;
for(struct dirent *de = fs::readdir(dh); de && !rv; de = fs::readdir(dh))
{
rv = names.put(de->d_name,l::dirent_exact_namelen(de));
rv = names.put(de->d_name);
if(rv == 0)
continue;

7
src/hashset.hpp

@ -56,6 +56,13 @@ public:
return rv;
}
inline
int
put(const char *str_)
{
return put(str_,strlen(str_));
}
inline
int
size(void)

Loading…
Cancel
Save