Defined the (*ioctl)() commands as unsigned int (#381)
authorJean-Pierre André <jpandre@users.noreply.github.com>
Mon, 11 Mar 2019 17:35:23 +0000 (18:35 +0100)
committerNikolaus Rath <Nikolaus@rath.org>
Mon, 11 Mar 2019 17:35:23 +0000 (17:35 +0000)
Instead of the Posix ioctl(2) command, Linux uses its own variant of ioctl()
in which the commands are requested as "unsigned long" and truncated to
32 bits by the fuse kernel module. Transmitting the commands to user space
file systems as "unsigned int" is a workaround for processing ioctl()
commands which do not fit into a signed int.

ChangeLog.rst
example/ioctl.c
include/fuse.h
include/fuse_lowlevel.h
lib/fuse.c

index 74bd0bee9b0aaf3c0f79ccee4337082d93bfee59..ca043192035c112cf526f4ad96ae4d13b39c30c9 100644 (file)
@@ -1,3 +1,7 @@
+* Changed ioctl commands to "unsigned int" in order to support commands
+  which do not fit into a signed int. Commands issued by applications
+  are still truncated to 32 bits.
+
 libfuse 3.4.2 (2019-03-09)
 ==========================
 
index 75991d75319995e2d6779a36b5d86d6b06fe9c5f..eab3061252e67e5c3fcf00abff3e0d68ec894477 100644 (file)
@@ -188,7 +188,7 @@ static int fioc_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
        return 0;
 }
 
-static int fioc_ioctl(const char *path, int cmd, void *arg,
+static int fioc_ioctl(const char *path, unsigned int cmd, void *arg,
                      struct fuse_file_info *fi, unsigned int flags, void *data)
 {
        (void) arg;
index 4f7131b6f4f690e2e176d8fcdde5593f60bae785..3e8aa2064450964990bf68695a4cc7623d063928 100644 (file)
@@ -677,8 +677,11 @@ struct fuse_operations {
         *
         * If flags has FUSE_IOCTL_DIR then the fuse_file_info refers to a
         * directory file handle.
+        *
+        * Note : the unsigned long request submitted by the application
+        * is truncated to 32 bits.
         */
-       int (*ioctl) (const char *, int cmd, void *arg,
+       int (*ioctl) (const char *, unsigned int cmd, void *arg,
                      struct fuse_file_info *, unsigned int flags, void *data);
 
        /**
@@ -1182,8 +1185,9 @@ int fuse_fs_removexattr(struct fuse_fs *fs, const char *path,
                        const char *name);
 int fuse_fs_bmap(struct fuse_fs *fs, const char *path, size_t blocksize,
                 uint64_t *idx);
-int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, int cmd, void *arg,
-                 struct fuse_file_info *fi, unsigned int flags, void *data);
+int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, unsigned int cmd,
+                 void *arg, struct fuse_file_info *fi, unsigned int flags,
+                 void *data);
 int fuse_fs_poll(struct fuse_fs *fs, const char *path,
                 struct fuse_file_info *fi, struct fuse_pollhandle *ph,
                 unsigned *reventsp);
index 68fd521fe850fe01bbba72fcab6f7fcdb4af5801..87c362ac569d98d5a6bc0b8952c3cd68f0672a2e 100644 (file)
@@ -1010,9 +1010,12 @@ struct fuse_lowlevel_ops {
         * @param in_buf data fetched from the caller
         * @param in_bufsz number of fetched bytes
         * @param out_bufsz maximum size of output data
+        *
+        * Note : the unsigned long request submitted by the application
+        * is truncated to 32 bits.
         */
-       void (*ioctl) (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
-                      struct fuse_file_info *fi, unsigned flags,
+       void (*ioctl) (fuse_req_t req, fuse_ino_t ino, unsigned int cmd,
+                      void *arg, struct fuse_file_info *fi, unsigned flags,
                       const void *in_buf, size_t in_bufsz, size_t out_bufsz);
 
        /**
index a40e9959c148e2c30f33a587c3f8c76cf799f714..5c3b55b84d35877a2eaa2cc13b20e1889968ee3f 100755 (executable)
@@ -2304,8 +2304,9 @@ int fuse_fs_removexattr(struct fuse_fs *fs, const char *path, const char *name)
        }
 }
 
-int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, int cmd, void *arg,
-                 struct fuse_file_info *fi, unsigned int flags, void *data)
+int fuse_fs_ioctl(struct fuse_fs *fs, const char *path, unsigned int cmd,
+                 void *arg, struct fuse_file_info *fi, unsigned int flags,
+                 void *data)
 {
        fuse_get_context()->private_data = fs->user_data;
        if (fs->op.ioctl) {
@@ -4222,10 +4223,10 @@ static void fuse_lib_bmap(fuse_req_t req, fuse_ino_t ino, size_t blocksize,
                reply_err(req, err);
 }
 
-static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
-                          struct fuse_file_info *llfi, unsigned int flags,
-                          const void *in_buf, size_t in_bufsz,
-                          size_t out_bufsz)
+static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, unsigned int cmd,
+                          void *arg, 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;