Browse Source
Merge pull request #723 from trapexit/getdents
fix filename hashing error
pull/726/head
trapexit
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
13 additions and
40 deletions
-
src/fuse_readdir_linux.icpp
-
src/fuse_readdir_plus_linux.icpp
-
src/fuse_readdir_plus_posix.icpp
-
src/fuse_readdir_posix.icpp
-
src/hashset.hpp
|
@ -94,7 +94,6 @@ namespace l |
|
|
{ |
|
|
{ |
|
|
int dirfd; |
|
|
int dirfd; |
|
|
int64_t nread; |
|
|
int64_t nread; |
|
|
uint64_t namelen; |
|
|
|
|
|
|
|
|
|
|
|
basepath = fs::path::make(&branches_[i].path,dirname_); |
|
|
basepath = fs::path::make(&branches_[i].path,dirname_); |
|
|
|
|
|
|
|
@ -114,12 +113,11 @@ namespace l |
|
|
if(nread == 0) |
|
|
if(nread == 0) |
|
|
break; |
|
|
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); |
|
|
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) |
|
|
if(rv == 0) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
@ -128,8 +126,6 @@ namespace l |
|
|
rv = fuse_dirents_add_linux(buf_,d); |
|
|
rv = fuse_dirents_add_linux(buf_,d); |
|
|
if(rv) |
|
|
if(rv) |
|
|
return close_free_ret_enomem(dirfd,buf); |
|
|
return close_free_ret_enomem(dirfd,buf); |
|
|
|
|
|
|
|
|
pos += d->d_reclen; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
@ -100,7 +100,6 @@ namespace l |
|
|
{ |
|
|
{ |
|
|
int dirfd; |
|
|
int dirfd; |
|
|
int64_t nread; |
|
|
int64_t nread; |
|
|
uint64_t namelen; |
|
|
|
|
|
|
|
|
|
|
|
basepath = fs::path::make(&branches_[i].path,dirname_); |
|
|
basepath = fs::path::make(&branches_[i].path,dirname_); |
|
|
|
|
|
|
|
@ -120,12 +119,11 @@ namespace l |
|
|
if(nread == 0) |
|
|
if(nread == 0) |
|
|
break; |
|
|
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); |
|
|
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) |
|
|
if(rv == 0) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
@ -139,8 +137,6 @@ namespace l |
|
|
rv = fuse_dirents_add_linux_plus(buf_,d,&entry,&st); |
|
|
rv = fuse_dirents_add_linux_plus(buf_,d,&entry,&st); |
|
|
if(rv) |
|
|
if(rv) |
|
|
return close_free_ret_enomem(dirfd,buf); |
|
|
return close_free_ret_enomem(dirfd,buf); |
|
|
|
|
|
|
|
|
pos += d->d_reclen; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
@ -45,19 +45,6 @@ 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_, |
|
@ -96,7 +83,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,l::dirent_exact_namelen(de)); |
|
|
|
|
|
|
|
|
rv = names.put(de->d_name); |
|
|
if(rv == 0) |
|
|
if(rv == 0) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
|
|
@ -44,19 +44,6 @@ 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_, |
|
@ -87,7 +74,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,l::dirent_exact_namelen(de)); |
|
|
|
|
|
|
|
|
rv = names.put(de->d_name); |
|
|
if(rv == 0) |
|
|
if(rv == 0) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
|
|
@ -56,6 +56,13 @@ public: |
|
|
return rv; |
|
|
return rv; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
int |
|
|
|
|
|
put(const char *str_) |
|
|
|
|
|
{ |
|
|
|
|
|
return put(str_,strlen(str_)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
inline |
|
|
inline |
|
|
int |
|
|
int |
|
|
size(void) |
|
|
size(void) |
|
|