From 3a46ec9fab0e947d1137b6b36bca0f66196c908e Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sat, 7 Mar 2020 11:22:33 -0500 Subject: [PATCH] fix filename hashing error --- src/fuse_readdir_linux.icpp | 8 ++------ src/fuse_readdir_plus_linux.icpp | 8 ++------ src/fuse_readdir_plus_posix.icpp | 15 +-------------- src/fuse_readdir_posix.icpp | 15 +-------------- src/hashset.hpp | 7 +++++++ 5 files changed, 13 insertions(+), 40 deletions(-) diff --git a/src/fuse_readdir_linux.icpp b/src/fuse_readdir_linux.icpp index a03a1fa6..cee408a4 100644 --- a/src/fuse_readdir_linux.icpp +++ b/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; } } diff --git a/src/fuse_readdir_plus_linux.icpp b/src/fuse_readdir_plus_linux.icpp index 81844fed..5d6d3bec 100644 --- a/src/fuse_readdir_plus_linux.icpp +++ b/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; } } diff --git a/src/fuse_readdir_plus_posix.icpp b/src/fuse_readdir_plus_posix.icpp index 4c9ebbf1..cd1afc5a 100644 --- a/src/fuse_readdir_plus_posix.icpp +++ b/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; diff --git a/src/fuse_readdir_posix.icpp b/src/fuse_readdir_posix.icpp index a653f9eb..a0c4f465 100644 --- a/src/fuse_readdir_posix.icpp +++ b/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; diff --git a/src/hashset.hpp b/src/hashset.hpp index fec6b3fd..985a417a 100644 --- a/src/hashset.hpp +++ b/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)