lkml.org 
[lkml]   [2022]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 04/20] cachefiles: extract generic daemon write function
Date
... so that the following new devnode can reuse most of the code when
implementing its .write() callback.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
---
fs/cachefiles/daemon.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 7ac04ee2c0a0..aa2e5e354afb 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -209,10 +209,11 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
/*
* Take a command from cachefilesd, parse it and act on it.
*/
-static ssize_t cachefiles_daemon_write(struct file *file,
- const char __user *_data,
- size_t datalen,
- loff_t *pos)
+static ssize_t cachefiles_daemon_do_write(struct file *file,
+ const char __user *_data,
+ size_t datalen,
+ loff_t *pos,
+ const struct cachefiles_daemon_cmd *cmds)
{
const struct cachefiles_daemon_cmd *cmd;
struct cachefiles_cache *cache = file->private_data;
@@ -261,7 +262,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
}

/* run the appropriate command handler */
- for (cmd = cachefiles_daemon_cmds; cmd->name[0]; cmd++)
+ for (cmd = cmds; cmd->name[0]; cmd++)
if (strcmp(cmd->name, data) == 0)
goto found_command;

@@ -284,6 +285,15 @@ static ssize_t cachefiles_daemon_write(struct file *file,
goto error;
}

+static ssize_t cachefiles_daemon_write(struct file *file,
+ const char __user *_data,
+ size_t datalen,
+ loff_t *pos)
+{
+ return cachefiles_daemon_do_write(file, _data, datalen, pos,
+ cachefiles_daemon_cmds);
+}
+
/*
* Poll for culling state
* - use EPOLLOUT to indicate culling state
--
2.27.0
\
 
 \ /
  Last update: 2022-01-18 14:13    [W:0.213 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site