All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cobalt/pipe: Add support for compat_ioctl
@ 2021-06-09  8:01 Jan Kiszka
  0 siblings, 0 replies; only message in thread
From: Jan Kiszka @ 2021-06-09  8:01 UTC (permalink / raw)
  To: Xenomai, Philippe Gerum

From: Jan Kiszka <jan.kiszka@siemens.com>

There are only two pipe IOCTLs that take arguments and both are int
pointers. Therefore, use the compat_ptr_ioctl pattern, just open-coding
it for support of kernels < 5.4.4.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 kernel/cobalt/pipe.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel/cobalt/pipe.c b/kernel/cobalt/pipe.c
index 9465fb2da..19064ea69 100644
--- a/kernel/cobalt/pipe.c
+++ b/kernel/cobalt/pipe.c
@@ -1052,6 +1052,16 @@ static long xnpipe_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return ret;
 }
 
+/*
+ * Could be replaced with compat_ptr_ioctl if support for kernels < 5.4 is
+ * dropped.
+ */
+static long xnpipe_compat_ioctl(struct file *file, unsigned int cmd,
+				unsigned long arg)
+{
+	return xnpipe_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+}
+
 static int xnpipe_fasync(int fd, struct file *file, int on)
 {
 	struct xnpipe_state *state = file->private_data;
@@ -1112,6 +1122,7 @@ static struct file_operations xnpipe_fops = {
 	.write = xnpipe_write,
 	.poll = xnpipe_poll,
 	.unlocked_ioctl = xnpipe_ioctl,
+	.compat_ioctl = xnpipe_compat_ioctl,
 	.open = xnpipe_open,
 	.release = xnpipe_release,
 	.fasync = xnpipe_fasync
-- 
2.26.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-09  8:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  8:01 [PATCH] cobalt/pipe: Add support for compat_ioctl Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.