mirror of
https://github.com/trapexit/mergerfs.git
synced 2025-03-05 05:31:55 +08:00
Merge pull request #723 from trapexit/getdents
fix filename hashing error
This commit is contained in:
commit
14d26ba434
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -56,6 +56,13 @@ public:
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline
|
||||
int
|
||||
put(const char *str_)
|
||||
{
|
||||
return put(str_,strlen(str_));
|
||||
}
|
||||
|
||||
inline
|
||||
int
|
||||
size(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user