summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2014-07-21 18:53:04 +0200
committerMiklos Szeredi <mszeredi@suse.cz>2014-07-21 18:59:23 +0200
commitd6c284cbdac0c4e2965653706280f668e5632f02 (patch)
treeb065abecaeb4d2bb51aac3c0da88513f6fce8213
parent60ac20d25ff061561fe2150a3197f894b36a0240 (diff)
downloadfuse-d6c284cbdac0c4e2965653706280f668e5632f02.tar.gz
libfuse: highlevel API: fix directory file handle passed to ioctl() method
Reported by Eric Biggers
-rw-r--r--ChangeLog5
-rw-r--r--include/fuse.h3
-rw-r--r--lib/fuse.c10
3 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f4657a0..da3b11a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-07-21 Miklos Szeredi <miklos@szeredi.hu>
+
+ * libfuse: highlevel API: fix directory file handle passed to
+ ioctl() method. Reported by Eric Biggers
+
2014-07-15 Miklos Szeredi <miklos@szeredi.hu>
* fusermount, libfuse: send value as unsigned in "user_id=" and
diff --git a/include/fuse.h b/include/fuse.h
index c657e67..911a676 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -500,6 +500,9 @@ struct fuse_operations {
* _IOC_READ in area and if both are set in/out area. In all
* non-NULL cases, the area is of _IOC_SIZE(cmd) bytes.
*
+ * If flags has FUSE_IOCTL_DIR then the fuse_file_info refers to a
+ * directory file handle.
+ *
* Introduced in version 2.8
*/
int (*ioctl) (const char *, int cmd, void *arg,
diff --git a/lib/fuse.c b/lib/fuse.c
index cfac238..7ba654a 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -3998,12 +3998,13 @@ static void fuse_lib_bmap(fuse_req_t req, fuse_ino_t ino, size_t blocksize,
}
static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
- struct fuse_file_info *fi, unsigned int flags,
+ struct fuse_file_info *llfi, unsigned int flags,
const void *in_buf, size_t in_bufsz,
size_t out_bufsz)
{
struct fuse *f = req_fuse_prepare(req);
struct fuse_intr_data d;
+ struct fuse_file_info fi;
char *path, *out_buf = NULL;
int err;
@@ -4011,6 +4012,11 @@ static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
if (flags & FUSE_IOCTL_UNRESTRICTED)
goto err;
+ if (flags & FUSE_IOCTL_DIR)
+ get_dirhandle(llfi, &fi);
+ else
+ fi = *llfi;
+
if (out_bufsz) {
err = -ENOMEM;
out_buf = malloc(out_bufsz);
@@ -4028,7 +4034,7 @@ static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
fuse_prepare_interrupt(f, req, &d);
- err = fuse_fs_ioctl(f->fs, path, cmd, arg, fi, flags,
+ err = fuse_fs_ioctl(f->fs, path, cmd, arg, &fi, flags,
out_buf ?: (void *)in_buf);
fuse_finish_interrupt(f, req, &d);