Commit 658a1e42 authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Kent Overstreet

bcachefs: thread_with_file: allow ioctls against these files

Make it so that a thread_with_stdio user can handle ioctls against the
file descriptor.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent ab6752e2
...@@ -247,12 +247,23 @@ static __poll_t thread_with_stdout_poll(struct file *file, struct poll_table_str ...@@ -247,12 +247,23 @@ static __poll_t thread_with_stdout_poll(struct file *file, struct poll_table_str
return mask; 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 = { static const struct file_operations thread_with_stdio_fops = {
.llseek = no_llseek, .llseek = no_llseek,
.read = thread_with_stdio_read, .read = thread_with_stdio_read,
.write = thread_with_stdio_write, .write = thread_with_stdio_write,
.poll = thread_with_stdio_poll, .poll = thread_with_stdio_poll,
.release = thread_with_stdio_release, .release = thread_with_stdio_release,
.unlocked_ioctl = thread_with_stdio_ioctl,
}; };
static const struct file_operations thread_with_stdout_fops = { static const struct file_operations thread_with_stdout_fops = {
...@@ -260,6 +271,7 @@ static const struct file_operations thread_with_stdout_fops = { ...@@ -260,6 +271,7 @@ static const struct file_operations thread_with_stdout_fops = {
.read = thread_with_stdio_read, .read = thread_with_stdio_read,
.poll = thread_with_stdout_poll, .poll = thread_with_stdout_poll,
.release = thread_with_stdio_release, .release = thread_with_stdio_release,
.unlocked_ioctl = thread_with_stdio_ioctl,
}; };
static int thread_with_stdio_fn(void *arg) static int thread_with_stdio_fn(void *arg)
......
...@@ -54,6 +54,7 @@ struct thread_with_stdio; ...@@ -54,6 +54,7 @@ struct thread_with_stdio;
struct thread_with_stdio_ops { struct thread_with_stdio_ops {
void (*exit)(struct thread_with_stdio *); void (*exit)(struct thread_with_stdio *);
void (*fn)(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 { struct thread_with_stdio {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment