[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <170873669465.1861696.18118008706761741778.stgit@frogsfrogsfrogs>
Date: Fri, 23 Feb 2024 17:17:23 -0800
From: "Darrick J. Wong" <djwong@...nel.org>
To: akpm@...ux-foundation.org, daniel@...o.nz, kent.overstreet@...ux.dev,
djwong@...nel.org
Cc: linux-xfs@...r.kernel.org, linux-bcachefs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 4/5] thread_with_file: allow ioctls against these files
From: Darrick J. Wong <djwong@...nel.org>
Make it so that a thread_with_stdio user can handle ioctls against the
file descriptor.
Signed-off-by: Darrick J. Wong <djwong@...nel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@...ux.dev>
---
include/linux/thread_with_file.h | 1 +
lib/thread_with_file.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/linux/thread_with_file.h b/include/linux/thread_with_file.h
index 445b1b12a0bd6..33770938d5d9a 100644
--- a/include/linux/thread_with_file.h
+++ b/include/linux/thread_with_file.h
@@ -57,6 +57,7 @@ struct thread_with_stdio;
struct thread_with_stdio_ops {
void (*exit)(struct thread_with_stdio *);
void (*fn)(struct thread_with_stdio *);
+ long (*unlocked_ioctl)(struct thread_with_stdio *, unsigned int, unsigned long);
};
struct thread_with_stdio {
diff --git a/lib/thread_with_file.c b/lib/thread_with_file.c
index 2edf33c3e7dc5..8b129744a48a3 100644
--- a/lib/thread_with_file.c
+++ b/lib/thread_with_file.c
@@ -379,12 +379,23 @@ static __poll_t thread_with_stdout_poll(struct file *file, struct poll_table_str
return mask;
}
+static long thread_with_stdio_ioctl(struct file *file, unsigned int cmd, unsigned long p)
+{
+ struct thread_with_stdio *thr =
+ container_of(file->private_data, struct thread_with_stdio, thr);
+
+ if (thr->ops->unlocked_ioctl)
+ return thr->ops->unlocked_ioctl(thr, cmd, p);
+ return -ENOTTY;
+}
+
static const struct file_operations thread_with_stdio_fops = {
.llseek = no_llseek,
.read = thread_with_stdio_read,
.write = thread_with_stdio_write,
.poll = thread_with_stdio_poll,
.release = thread_with_stdio_release,
+ .unlocked_ioctl = thread_with_stdio_ioctl,
};
static const struct file_operations thread_with_stdout_fops = {
@@ -392,6 +403,7 @@ static const struct file_operations thread_with_stdout_fops = {
.read = thread_with_stdio_read,
.poll = thread_with_stdout_poll,
.release = thread_with_stdio_release,
+ .unlocked_ioctl = thread_with_stdio_ioctl,
};
static int thread_with_stdio_fn(void *arg)
Powered by blists - more mailing lists