From: Amir Goldstein Date: Thu, 2 Jan 2025 19:25:13 +0000 (+0100) Subject: example/passthrough: Enable testing of readdirplus without fill offsets X-Git-Tag: fuse-3.17.1-rc0~25 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c105b8fbfad6398b064f547e3ad193af24e53048;p=qemu-gpiodev%2Flibfuse.git example/passthrough: Enable testing of readdirplus without fill offsets passthrough example supports the --plus command line argument to reply to readdirplus with fill_dir_plus and unspecified (0) fill offsets. As explained in this comment: https://github.com/libfuse/libfuse/pull/896#issuecomment-1978917041 passthrough example needs a few more changes to be able to test commit dd95d13a ("fix readdirplus when filler is called with zero offset (#896)) With the changes in this commit, readdirplus without fill offsets can be tested to verify the readdirplus fix above with command line: passthrough --plus -o auto_cache,modules=subdir,subdir=/src /mnt Signed-off-by: Amir Goldstein --- diff --git a/example/passthrough.c b/example/passthrough.c index 30a8ad5..cc93f53 100644 --- a/example/passthrough.c +++ b/example/passthrough.c @@ -73,9 +73,11 @@ static void *xmp_init(struct fuse_conn_info *conn, the cache of the associated inode - resulting in an incorrect st_nlink value being reported for any remaining hardlinks to this inode. */ - cfg->entry_timeout = 0; - cfg->attr_timeout = 0; - cfg->negative_timeout = 0; + if (!cfg->auto_cache) { + cfg->entry_timeout = 0; + cfg->attr_timeout = 0; + cfg->negative_timeout = 0; + } return NULL; } @@ -134,9 +136,14 @@ static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler, while ((de = readdir(dp)) != NULL) { struct stat st; - memset(&st, 0, sizeof(st)); - st.st_ino = de->d_ino; - st.st_mode = de->d_type << 12; + if (fill_dir_plus) { + fstatat(dirfd(dp), de->d_name, &st, + AT_SYMLINK_NOFOLLOW); + } else { + 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, fill_dir_plus)) break; }