From bdd2d4110fbc6d2059eb699efad2cca4a7eacccb Mon Sep 17 00:00:00 2001 From: Jean-Pierre André Date: Thu, 18 Mar 2021 10:52:30 +0100 Subject: Fix returning d_ino and d_type by readdir(3) in non-plus mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When not using the readdir_plus mode, the d_type was not returned, and the use_ino flag was not used for returning d_ino. This patch fixes the returned values for d_ino and d_type by readdir(3) The test for the returned value of d_ino has been adjusted to also take the d_type into consideration and to check the returned values in both basic readdir and readdir_plus modes. This is done by executing the passthrough test twice. Co-authored-by: Jean-Pierre André --- example/passthrough.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'example/passthrough.c') diff --git a/example/passthrough.c b/example/passthrough.c index 86ac698..ae13225 100644 --- a/example/passthrough.c +++ b/example/passthrough.c @@ -55,6 +55,8 @@ #include "passthrough_helpers.h" +static int fill_dir_plus = 0; + static void *xmp_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { @@ -132,7 +134,7 @@ static int xmp_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, FUSE_FILL_DIR_PLUS)) + if (filler(buf, de->d_name, &st, 0, fill_dir_plus)) break; } @@ -551,6 +553,18 @@ static const struct fuse_operations xmp_oper = { int main(int argc, char *argv[]) { + enum { MAX_ARGS = 10 }; + int i,new_argc; + char *new_argv[MAX_ARGS]; + umask(0); - return fuse_main(argc, argv, &xmp_oper, NULL); + /* Process the "--plus" option apart */ + for (i=0, new_argc=0; (i