Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5686932pxb; Thu, 20 Jan 2022 02:28:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdP7Q9TF8Zwr4K5Fx4VfvNnPVWaEbfyxjl5/IIIp8403dRL2hj3sUmYJm/woQHcUwPDBLp X-Received: by 2002:a63:b509:: with SMTP id y9mr31088693pge.31.1642674512799; Thu, 20 Jan 2022 02:28:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642674512; cv=none; d=google.com; s=arc-20160816; b=y9Q/OhMw0FmhqZqII3oNWk+9HRs5YtCwS/sfjSOverl8mV1iwAxrtY8S+I3L5BCDjh SFxeMaqtfeq8ho7bH8qgqm+8lJ+cXDYt7wlmv4AgehwbhgAKZ+3KT21uNfj5wM9vFslZ /S91L6g8s63J9Kqd+aDW143v/pmYi7WfMRvf2cp++KXm7UaJbSBz5Szlop8/eGXren6h MD/UWOblM0JRfyU+L6bkrt4dhRO8g1HfcjDoBupPKCKE0bsqXD2OWRnUEwaSe1sL/orW gWMOQBE1rVWJhgm2mW91iIxqr8WwI0y8/UqN04ZPMI3PHkVRy7UXvShUOZOoj5bHbSr6 YJ9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nOKsB4mJjxtl6TpMHwkocmRPakXxz1Q4a0CVEGYI9Lk=; b=QyLmWhJwEVrXRZeGGR7z1uaKq7RQ4rB+tfq2+RJ/8GIt2GnsYpkzSrwUsvPvSZHRCS wV5L4cUNlfzsNEZRQcn9zzsfvv7Sszb+MnS2l2E8qrT1+6sbVeyunMtu5wS4Mr27DSrm AqHyGJyhwG/B/yGZbzHKkak5BHEHo8dvX42z8VlrEY3U6WoVaf5zfOlK8euBb/PLrPdx p/2CIMH2SjU9mkyCFdm1GahhpnlpgXmGyb4wJ7skjfvq6Vk93WMvPBAagtr0RrfGLBrE DWgcUGpdVBeevSWDjIKNotAc80rSEUce4qJwYe+QYo9HpotVb81RIVQZhU9MOBOw9aQ+ lCnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si163100pgb.20.2022.01.20.02.28.03; Thu, 20 Jan 2022 02:28:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242362AbiARNMh (ORCPT + 99 others); Tue, 18 Jan 2022 08:12:37 -0500 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:54042 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241972AbiARNMZ (ORCPT ); Tue, 18 Jan 2022 08:12:25 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R541e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0V2CR7xO_1642511541; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V2CR7xO_1642511541) by smtp.aliyun-inc.com(127.0.0.1); Tue, 18 Jan 2022 21:12:22 +0800 From: Jeffle Xu To: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/20] cachefiles: extract generic daemon write function Date: Tue, 18 Jan 2022 21:12:00 +0800 Message-Id: <20220118131216.85338-5-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220118131216.85338-1-jefflexu@linux.alibaba.com> References: <20220118131216.85338-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ... so that the following new devnode can reuse most of the code when implementing its .write() callback. Signed-off-by: Jeffle Xu --- 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