From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BED1E606A334 for ; Mon, 30 Nov 2026 08:26:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=LIi50kYv; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jQphrC0y DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=gx9VQXsDnICAuUOHrzG02eRcuhDnwiUkvgvkiAFO2gw=; b=LIi50kYvMGg58cEMKAFLxoanVe XoXSRnYvEzLKTPcLUMiryhLX9UDHro1g6D8T/7j9RCvq5YjPBV3SFD/7QfpotEVZ5ffsfS61WXwvd OAyIxDJFUTVG/8tIHuyFyywk0qTdXXXITFvexzN0K/354fWjNkZPI5TAroeXsSN2bL5zHsR8uR7tq QEbhCNy8gdz/i0WJFBh9g/OIEjZ9EP2wuEQOXxnbiSiybqe72fxqngTZEgxi0aNaaIRvrxzILQA3e +LZrdsGlTZyzfPACRU+ee6rOiAv7RpyvR3wlcjW0j2bQbKhJZI181Ogmf7DeDe7UI8Ig7he8ZFYCx q1JrIa6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXwio-00000003juX-21CP; Mon, 30 Nov 2026 08:26:50 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXwin-00000003jtv-43Gx for linux-mtd@lists.infradead.org; Mon, 30 Nov 2026 08:26:50 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 687B661DD7; Mon, 30 Nov 2026 08:26:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6AD81F000C1; Mon, 30 Nov 2026 08:26:44 +0000 (UTC) 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== From: "Richard Weinberger (sigma star gmbh)" To: linux-mtd@lists.infradead.org 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 Subject: [PATCH 01/10] fuse: Share cuse_parse_one() as fuse_kv_parse_one() Date: Mon, 30 Nov 2026 09:26:24 +0100 Message-ID: <20261130082634.2750846-2-rw@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130082634.2750846-1-rw@kernel.org> References: <20261130082634.2750846-1-rw@kernel.org> X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Richard Weinberger 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 --- 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 + * + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include + +#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 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/