From: Aurelien Jarno <aurelien@aurel32.net>
To: linux-kernel@vger.kernel.org
Cc: Aurelien Jarno <aurelien@aurel32.net>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>,
"Theodore Ts'o" <tytso@mit.edu>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH] UAPI linux/fs.h: add a warning about wrong ioctl argument types
Date: Wed, 27 Nov 2013 11:40:39 +0100 [thread overview]
Message-ID: <1385548839-16617-1-git-send-email-aurelien@aurel32.net> (raw)
The FS_IOC_GETFLAGS, FS_IOC_SETFLAGS, FS_IOC_GETVERSION and
FS_IOC_SETVERSION ioctls are declared for historical reasons with a long
argument, while in practice they take an int argument. This is
unfortunately not possible to fix that without breaking the kernel ABI.
However good programmers actually lookup for the argument type of these
ioctls in <fs/linux.h> and end-up using a long. This breaks on 64-bit
big endian machines.
Instead of letting the same "mistake" to be done again and again, add an
explanation to <fs/linux.h> so that people use the correct argument type
in their code. Also add a small comment on the same line while staying
within 80 characters so that the issue appears when doing a grep on this
file.
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
include/uapi/linux/fs.h | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 6c28b61..baeb803 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -154,10 +154,16 @@ struct inodes_stat_t {
#define FITHAW _IOWR('X', 120, int) /* Thaw */
#define FITRIM _IOWR('X', 121, struct fstrim_range) /* Trim */
-#define FS_IOC_GETFLAGS _IOR('f', 1, long)
-#define FS_IOC_SETFLAGS _IOW('f', 2, long)
-#define FS_IOC_GETVERSION _IOR('v', 1, long)
-#define FS_IOC_SETVERSION _IOW('v', 2, long)
+/*
+ * WARNING: The next four following ioctls actually take an int argument
+ * despite their definition. This is important to support 64-bit big-endian
+ * machines.
+ */
+#define FS_IOC_GETFLAGS _IOR('f', 1, long) /* should be int */
+#define FS_IOC_SETFLAGS _IOW('f', 2, long) /* should be int */
+#define FS_IOC_GETVERSION _IOR('v', 1, long) /* should be int */
+#define FS_IOC_SETVERSION _IOW('v', 2, long) /* should be int */
+
#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
--
1.8.4.2
next reply other threads:[~2013-11-27 10:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-27 10:40 Aurelien Jarno [this message]
2013-11-27 11:13 ` [PATCH] UAPI linux/fs.h: add a warning about wrong ioctl argument types Christoph Hellwig
2013-11-27 23:02 ` Aurelien Jarno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385548839-16617-1-git-send-email-aurelien@aurel32.net \
--to=aurelien@aurel32.net \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox