Skip to content

Commit

Permalink
fix filename hashing error
Browse files Browse the repository at this point in the history
  • Loading branch information
trapexit committed Mar 7, 2020
1 parent ada90ea commit 3a46ec9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 40 deletions.
8 changes: 2 additions & 6 deletions src/fuse_readdir_linux.icpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ namespace l
{
int dirfd;
int64_t nread;
uint64_t namelen;

basepath = fs::path::make(&branches_[i].path,dirname_);

Expand All @@ -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;

Expand All @@ -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;
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/fuse_readdir_plus_linux.icpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ namespace l
{
int dirfd;
int64_t nread;
uint64_t namelen;

basepath = fs::path::make(&branches_[i].path,dirname_);

Expand All @@ -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;

Expand All @@ -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;
}
}

Expand Down
15 changes: 1 addition & 14 deletions src/fuse_readdir_plus_posix.icpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 1 addition & 14 deletions src/fuse_readdir_posix.icpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_,
Expand Down Expand Up @@ -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;

Expand Down
7 changes: 7 additions & 0 deletions src/hashset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class HashSet
return rv;
}

inline
int
put(const char *str_)
{
return put(str_,strlen(str_));
}

inline
int
size(void)
Expand Down

0 comments on commit 3a46ec9

Please sign in to comment.