summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Schubert <bschubert@ddn.com>2022-03-23 19:49:17 +0100
committerNikolaus Rath <Nikolaus@rath.org>2023-01-13 10:21:42 +0000
commitc67b9219cfe132809555ad5a04c3e13c7cde70ed (patch)
treefe671b6b46e41fce1366b5b09912bcb63a3777b3
parent856c683c361cb1f3a176df331cbbac76c34402e7 (diff)
downloadfuse-c67b9219cfe132809555ad5a04c3e13c7cde70ed.tar.gz
passthrough_hp: Avoid a bit code dup in readdir
Just a slight code simplification.
-rw-r--r--example/passthrough_hp.cc23
1 files changed, 9 insertions, 14 deletions
diff --git a/example/passthrough_hp.cc b/example/passthrough_hp.cc
index 0167738..b367978 100644
--- a/example/passthrough_hp.cc
+++ b/example/passthrough_hp.cc
@@ -695,7 +695,7 @@ static bool is_dot_or_dotdot(const char *name) {
static void do_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t offset, fuse_file_info *fi, int plus) {
+ off_t offset, fuse_file_info *fi, const int plus) {
auto d = get_dir_handle(fi);
Inode& inode = get_inode(ino);
lock_guard<mutex> g {inode.m};
@@ -740,28 +740,23 @@ static void do_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
fuse_entry_param e{};
size_t entsize;
- if(plus) {
+ if (plus) {
err = do_lookup(ino, entry->d_name, &e);
if (err)
goto error;
entsize = fuse_add_direntry_plus(req, p, rem, entry->d_name, &e, entry->d_off);
-
- if (entsize > rem) {
- if (fs.debug)
- cerr << "DEBUG: readdir(): buffer full, returning data. " << endl;
- forget_one(e.ino, 1);
- break;
- }
} else {
e.attr.st_ino = entry->d_ino;
e.attr.st_mode = entry->d_type << 12;
entsize = fuse_add_direntry(req, p, rem, entry->d_name, &e.attr, entry->d_off);
+ }
- if (entsize > rem) {
- if (fs.debug)
- cerr << "DEBUG: readdir(): buffer full, returning data. " << endl;
- break;
- }
+ if (entsize > rem) {
+ if (fs.debug)
+ cerr << "DEBUG: readdir(): buffer full, returning data. " << endl;
+ if (plus)
+ forget_one(e.ino, 1);
+ break;
}
p += entsize;