aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Pärtel <martin.partel@gmail.com>2016-01-19 22:01:31 +0000
committerMartin Pärtel <martin.partel@gmail.com>2016-01-19 22:01:31 +0000
commit7d3c41a881d746ea9a18f56910bb7bdb633f00cc (patch)
tree2186712beef370e22f72913c32371bec2f3391ef
parentba628e6cd1e39c5c20ffb9b991a2697cf60c4723 (diff)
downloadbindfs-7d3c41a881d746ea9a18f56910bb7bdb633f00cc.tar.gz
Added a comment and some defensive error handling to readdir's filler call.
-rw-r--r--src/bindfs.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bindfs.c b/src/bindfs.c
index a274079..f6cd6c6 100644
--- a/src/bindfs.c
+++ b/src/bindfs.c
@@ -608,8 +608,17 @@ static int bindfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
memset(&st, 0, sizeof(st));
st.st_ino = de->d_ino;
st.st_mode = de->d_type << 12;
- if (filler(buf, de->d_name, &st, 0))
+
+ // See issue #28 for why we pass a 0 offset to `filler`.
+ // Given a 0 offset, `filler` should never return non-zero, so we
+ // consider it an error if it does. It is undocumented whether it sets
+ // errno in that case, so we zero it first and set it ourself if it
+ // doesn't.
+ errno = 0;
+ if (filler(buf, de->d_name, &st, 0) != 0) {
+ result = errno != 0 ? -errno : -EIO;
break;
+ }
}
free(de_buf);