summaryrefslogtreecommitdiff
path: root/example/passthrough.c
diff options
context:
space:
mode:
authorJean-Pierre André <jpandre@users.noreply.github.com>2021-03-18 10:52:30 +0100
committerGitHub <noreply@github.com>2021-03-18 09:52:30 +0000
commitbdd2d4110fbc6d2059eb699efad2cca4a7eacccb (patch)
tree62ca0ce9b94529a68e376922963993606af2f35a /example/passthrough.c
parent77d662459a0fcdf358d515477d33795837e859d5 (diff)
downloadfuse-bdd2d4110fbc6d2059eb699efad2cca4a7eacccb.tar.gz
Fix returning d_ino and d_type by readdir(3) in non-plus mode
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é <jpandre@users.sourceforge.net>
Diffstat (limited to 'example/passthrough.c')
-rw-r--r--example/passthrough.c18
1 files changed, 16 insertions, 2 deletions
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<argc) && (new_argc<MAX_ARGS); i++) {
+ if (!strcmp(argv[i], "--plus")) {
+ fill_dir_plus = FUSE_FILL_DIR_PLUS;
+ } else {
+ new_argv[new_argc++] = argv[i];
+ }
+ }
+ return fuse_main(new_argc, new_argv, &xmp_oper, NULL);
}