Article View: linux.kernel.netdev
Article #24478[PATCH 01/10] fuse: Share cuse_parse_one() as fuse_kv_parse_one()
From: "Richard Weinberger (sigma star ...
Date: Mon, 30 Nov 2026 08:26
Date: Mon, 30 Nov 2026 08:26
224 lines
13854 bytes
13854 bytes
From: Richard Weinberger <richard@nod.at>
CUSE_INIT replies with the device parameters as a list of key=value
strings, cuse_parse_one() walks it. MUSE will describe its MTD in the
same way.
Move the function into the new fs/fuse/helper.c and rename it to
fuse_kv_parse_one(). The file is built into fuse.ko if FUSE_HELPER is
selected, which CUSE does now.
As the function is no longer CUSE only, its two error messages carry
the prefix "fuse: " instead of "CUSE: ".
Signed-off-by: Richard Weinberger <richard@nod.at>
---
fs/fuse/Kconfig | 4 +++
fs/fuse/Makefile | 1 +
fs/fuse/cuse.c | 58 +-------------------------------------
fs/fuse/fuse_i.h | 4 +++
fs/fuse/helper.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 83 insertions(+), 57 deletions(-)
create mode 100644 fs/fuse/helper.c
diff --git a/fs/fuse/Kconfig b/fs/fuse/Kconfig
index 3d1e52896b87..93ead2528ca8 100644
--- a/fs/fuse/Kconfig
+++ b/fs/fuse/Kconfig
@@ -19,9 +19,13 @@ config FUSE_FS
If you want to develop a userspace FS, or if you want to use
a filesystem based on FUSE, answer Y or M.
+config FUSE_HELPER
+ bool
+
config CUSE
tristate "Character device in Userspace support"
depends on FUSE_FS
+ select FUSE_HELPER
help
This FUSE extension allows character devices to be
implemented in userspace.
diff --git a/fs/fuse/Makefile b/fs/fuse/Makefile
index da9e802d7ae1..adcf912c87a1 100644
--- a/fs/fuse/Makefile
+++ b/fs/fuse/Makefile
@@ -17,6 +17,7 @@ fuse-y += iomode.o
fuse-$(CONFIG_FUSE_VDAX) += dax.o
fuse-$(CONFIG_FUSE_PASSTHROUGH) += passthrough.o backing.o ext_map.o
fuse-$(CONFIG_SYSCTL) += sysctl.o
+fuse-$(CONFIG_FUSE_HELPER) += helper.o
fuse-$(CONFIG_FUSE_IO_URING) += dev_uring.o
virtiofs-y := virtio_fs.o
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index 2538db153991..73512b26da10 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -201,62 +201,6 @@ struct cuse_devinfo {
const char *name;
};
-/**
- * cuse_parse_one - parse one key=value pair
- * @pp: i/o parameter for the current position
- * @end: points to one past the end of the packed string
- * @keyp: out parameter for key
- * @valp: out parameter for value
- *
- * *@pp points to packed strings - "key0=val0\0key1=val1\0" which ends
- * at @end - 1. This function parses one pair and set *@keyp to the
- * start of the key and *@valp to the start of the value. Note that
- * the original string is modified such that the key string is
- * terminated with '\0'. *@pp is updated to point to the next string.
- *
- * RETURNS:
- * 1 on successful parse, 0 on EOF, -errno on failure.
- */
-static int cuse_parse_one(char **pp, char *end, char **keyp, char **valp)
-{
- char *p = *pp;
- char *key, *val;
-
- while (p < end && *p == '\0')
- p++;
- if (p == end)
- return 0;
-
- if (end[-1] != '\0') {
- pr_err("info not properly terminated\n");
- return -EINVAL;
- }
-
- key = val = p;
- p += strlen(p);
-
- if (valp) {
- strsep(&val, "=");
- if (!val)
- val = key + strlen(key);
- key = strstrip(key);
- val = strstrip(val);
- } else
- key = strstrip(key);
-
- if (!strlen(key)) {
- pr_err("zero length info key specified\n");
- return -EINVAL;
- }
-
- *pp = p;
- *keyp = key;
- if (valp)
- *valp = val;
-
- return 1;
-}
-
/**
* cuse_parse_devinfo - parse device info
* @p: device info string
@@ -277,7 +221,7 @@ static int cuse_parse_devinfo(char *p, size_t len, struct cuse_devinfo *devinfo)
int rc;
while (true) {
- rc = cuse_parse_one(&p, end, &key, &val);
+ rc = fuse_kv_parse_one(&p, end, &key, &val);
if (rc < 0)
return rc;
if (!rc)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index e0992fcbcc55..b6153db7e76a 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1410,4 +1410,8 @@ int fuse_ext_map_mmap(struct file *file, struct vm_area_struct *vma);
bool fuse_ext_map_is_dax(struct fuse_backing *fb);
int fuse_ext_map_populate(struct fuse_conn *fc, struct fuse_notify_backing_map_out *arg,
struct fuse_extent *ext);
+
+/* helper.c */
+int fuse_kv_parse_one(char **pp, char *end, char **keyp, char **valp);
+
#endif /* _FS_FUSE_I_H */
diff --git a/fs/fuse/helper.c b/fs/fuse/helper.c
new file mode 100644
index 000000000000..29db362d930c
--- /dev/null
+++ b/fs/fuse/helper.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Helper functions used by CUSE and MUSE
+ *
+ * Copyright (C) 2008-2009 SUSE Linux Products GmbH
+ * Copyright (C) 2008-2009 Tejun Heo <tj@kernel.org>
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/export.h>
+#include <linux/printk.h>
+#include <linux/string.h>
+
+#include "fuse_i.h"
+
+/**
+ * fuse_kv_parse_one - parse one key=value pair
+ * @pp: i/o parameter for the current position
+ * @end: points to one past the end of the packed string
+ * @keyp: out parameter for key
+ * @valp: out parameter for value
+ *
+ * *@pp points to packed strings - "key0=val0\0key1=val1\0" which ends
+ * at @end - 1. This function parses one pair and set *@keyp to the
+ * start of the key and *@valp to the start of the value. Note that
+ * the original string is modified such that the key string is
+ * terminated with '\0'. *@pp is updated to point to the next string.
+ *
+ * RETURNS:
+ * 1 on successful parse, 0 on EOF, -errno on failure.
+ */
+int fuse_kv_parse_one(char **pp, char *end, char **keyp, char **valp)
+{
+ char *p = *pp;
+ char *key, *val;
+
+ while (p < end && *p == '\0')
+ p++;
+ if (p == end)
+ return 0;
+
+ if (end[-1] != '\0') {
+ pr_err("info not properly terminated\n");
+ return -EINVAL;
+ }
+
+ key = val = p;
+ p += strlen(p);
+
+ if (valp) {
+ strsep(&val, "=");
+ if (!val)
+ val = key + strlen(key);
+ key = strstrip(key);
+ val = strstrip(val);
+ } else
+ key = strstrip(key);
+
+ if (!strlen(key)) {
+ pr_err("zero length info key specified\n");
+ return -EINVAL;
+ }
+
+ *pp = p;
+ *keyp = key;
+ if (valp)
+ *valp = val;
+
+ return 1;
+}
+EXPORT_SYMBOL_GPL(fuse_kv_parse_one);
--
2.55.0
Technical Details
Message-ID:
<20261130082634.2750846-2-rw@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374008-linux-kernel-netdev=dewy.ruReferences:
<20261130082634.2750846-1-rw@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374008-linux-kernel-netdev=dewy.ru
From: rw@kernel.org ("Richard Weinberger (sigma star gmbh)")
Newsgroups: linux.kernel.netdev
Subject: [PATCH 01/10] fuse: Share cuse_parse_one() as fuse_kv_parse_one()
Date: Mon, 30 Nov 2026 09:26:24 +0100
Organization: Usenet Network
Message-ID: <20261130082634.2750846-2-rw@kernel.org>
References: <20261130082634.2750846-1-rw@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="1375830"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:OhhT6fRoiNJP+0tWV464NsKALw8= sha256:AKZmSJf2Ep5BhIbrAfKme3uR3JwJpfCY9BprgwE+bm8= sha1:0xkAIfmLhtoH/srCeS7R3wSuJVE= sha256:co44QKFG8MvPd3JiISPTBfDMOxoBiq+gKrZVMel/+4o=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 9989E125FD0; Mon, 30 Nov 2026 11:27:07 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 74CEHsCDkOUG; Mon, 30 Nov 2026 11:27:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374008-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 1FB37125FCD; Mon, 30 Nov 2026 11:26:54 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id AD94725F48; Mon, 30 Nov 2026 08:26:51 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796027210; b=xO5jg+Ut8M19KyILjxJ2XbTYne1JPAE/Ng+zX6YN4gtgVukbs3oYlXwfFBXnmGVKzhwt oEh8evBx7SxtvPiUy/hbzykobnq07VNXIq7J+PLcz6/yeW4NKokbYnHVCZ4aQAhTeexVP I3m4ocgMYMBOj3U5sV+SQ/JL51lxek9XTIwjj7to/Jd3djofkiAJsHDcysSCrU03tlBW1 eYAcAuRQm184akFNtWnjAGWggkj64pUiiI6q3sPomlGtDP2zeNiZvjviMH6pXTKisxA9o W8qEQzA3eO7TDLAyAJXL01Jngm6i/JR5ratHb/6ggRuNx6bC7YhAq21DQavh725fjog==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796027210; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=f/f9nuD7GrAz73ebGBe9z4mW2s2EErVQUw5188Xe6wE=; b=F3FF8A5alKbfojMOp5nBjQRu2h4LcoUI+PAStLiMaMjXNYm/63lz5xgq4gBL5YiD9IVQ HVS2R2FY7C7vTs7yupOvJRZvclhMm4H/cKA5AxEM7/LvixJXAlOp2mddVEBZyZBk60qVU vpebG4/eHsqe6x6/lhPcpujZFDZios0d+y2u4/Ncruo3sAn5fVoH6ICamCeuQ93bt7bZ9 R2pW/NGrXXw8Cn6qr1nGNzVAAa3rLXbrfv+nFWVzGYB0BAf7TAsEvpnghBfAU1ccKoZYe 5a6wMVNPh+ppoij5r15nBSlCnblo0Dz85NZIwmATSI5emYJNGBf1gzhfEM8LSdcTG8A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jQphrC0y; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50374606A333; Mon, 30 Nov 2026 08:26:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jQphrC0y
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796027209; b=eCHDFu1GIVrw1lsQOsZVCIRXhpntTmnZMzaN2wfk39tDYUFOOp/mnELPEqsGTQr6ktI/ umRisC3Nt0wDKPRx9bWpeca4j+mvT9op8XFjmNJRpfyfhB9fc23Jyhi0hxJKt/Y0/S7TU 4gzF5qRHxGpFDwlbtNIb1MbXFAzUYiPAgbicT8CVjgZjo4DBIdPwom7uwRAG6XEZ6xEK1 dje+i87VtVgZtH6hQgGReyMJJcVKj6wszSgmYPCyI/mv9eXr5f8o7qbr3geaskQAVbuef t2rIgnWW43bZ9b0MAIjLqQc+eMJ8tyXIMfa1klvOXFoCsa3kTxLezluuwLktufZhN2A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796027209; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=f/f9nuD7GrAz73ebGBe9z4mW2s2EErVQUw5188Xe6wE=; b=qf+gFACOFd1gBN6EJLxeRYQ/7xUSo+VNuJ7xiWpg32o70B7xHdQPRBJIx5264NESBk4H R15f59kC+yQICfohM9VNu7qp/6LFNnsHP6hVSwBNP92ZyU//JGuEfKsuZu3s7D5h3Q76D REnhv5Lf+oi1oGD5bwzyFyE84hmOndYuHPaeh6EmwSJSRbEz2cXd3KP428ZIn0Ll+ZUlW DqEskTVz05wwVQvR18OR9Olaj4Sm6z01DSxyc64wONYEM3mjBhphbUwqTUWHZYWsqWW3I HjVAXEPm7yM9cHrEPe0AKk4EYCHK9E5P8S3+rGFMaWzgyvY6uqOQAJtRIyhMSb6rHzA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jQphrC0y; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 729D0606A330; Mon, 30 Nov 2026 08:26:49 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6AD81F000C1; Mon, 30 Nov 2026 08:26:44 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796027209; bh=f/f9nuD7GrAz73ebGBe9z4mW2s2EErVQUw5188Xe6wE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jQphrC0ymXbeNhkLuOPLkRZ5ko6T5qjH656RZ2ZBT/UCRNEq1J/uhoPVaTe62hvd/ s03oTAOHlD7VAX2v0ytgZjKCB3mBwzJMrk2wcxGQ9aW+iFM1/zURiouUCpfum57Vu1 AqdpRizX7FFWA1IIITiRCSm8ycjVE5o0q0JqXurJ2wTf2CwwmNZyNrPoAXyv12/wnM X90pPg9/zA9lebtKLV/0nUmIuBY6bMLf+hMKNUZ6/FR9PkMMu43P/XMrnN0h0Jzkmk ANTwp3x55goYgzll/UGu859mPUvVnZSaZg54DlaW+UFlRCgAPTxEr60UaG87eXc7FK ciFghOvjVB/AA==
X-Cc: fuse-devel@lists.linux.dev, netdev@vger.kernel.org, horms@kernel.org, pabeni@redhat.com, kuba@kernel.org, edumazet@google.com, davem@davemloft.net, miklos@szeredi.hu, vigneshr@ti.com, miquel.raynal@bootlin.com, david.oberhollenzer@sigma-star.at, upstream+linux@sigma-star.at, Richard Weinberger <richard@nod.at>
X-Mailer: git-send-email 2.55.0
X-In-Reply-To: <20261130082634.2750846-1-rw@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list