{"id":2231569,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2231569/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/177758363550.1314717.5871127121158541585.stgit@frogsfrogsfrogs/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.1/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<177758363550.1314717.5871127121158541585.stgit@frogsfrogsfrogs>","date":"2026-04-30T21:15:17","name":"[01/13] Refactor mount code / move common functions to mount_util.c","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e523b6420f7b987c81d70ebbdefee947a2128bcb","submitter":{"id":77032,"url":"http://patchwork.ozlabs.org/api/1.1/people/77032/?format=json","name":"Darrick J. Wong","email":"djwong@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/177758363550.1314717.5871127121158541585.stgit@frogsfrogsfrogs/mbox/","series":[{"id":502386,"url":"http://patchwork.ozlabs.org/api/1.1/series/502386/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=502386","date":"2026-04-30T21:15:17","name":"[01/13] Refactor mount code / move common functions to mount_util.c","version":1,"mbox":"http://patchwork.ozlabs.org/series/502386/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231569/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231569/checks/","tags":{},"headers":{"Return-Path":"\n <SRS0=rmRh=C5=vger.kernel.org=linux-ext4+bounces-16253-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=B3sCIWar;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org;\n envelope-from=srs0=rmrh=c5=vger.kernel.org=linux-ext4+bounces-16253-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=\"2600:3c0a:e001:db::12fc:5321\"\n arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org","gandalf.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=B3sCIWar;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-16253-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"B3sCIWar\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g66QS3Hgnz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 07:15:26 +1000 (AEST)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4g66QQ5yYqz4wSd\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 07:15:26 +1000 (AEST)","by gandalf.ozlabs.org (Postfix)\n\tid 4g66QQ5p5cz4wck; Fri, 01 May 2026 07:15:26 +1000 (AEST)","from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4g66QL0CjQz4wSd\n\tfor <patchwork-incoming@ozlabs.org>; Fri, 01 May 2026 07:15:22 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 2B3C83010156\n\tfor <patchwork-incoming@ozlabs.org>; Thu, 30 Apr 2026 21:15:19 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 67FA53A7F6E;\n\tThu, 30 Apr 2026 21:15:18 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 21A0539A7E5;\n\tThu, 30 Apr 2026 21:15:17 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id BB3BCC2BCB3;\n\tThu, 30 Apr 2026 21:15:17 +0000 (UTC)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1777583726; cv=pass;\n\tb=ct5e4UIhPg7R1IFSRrXk9aZxyIb8o3oG18Zbnk7lrP+9hyRj/di2XCPM/L9SEysDJ8lXGYn/XqoidStXoi4tEOiZFa10kvI9XxK5kFMF+Sy+84hXKjTysffvVaGuCTOoxQO4ppwrqibIc4oc+Aco5wOf9B9DaRRpKHEZQJpOwnv7uVxMpStPc2vvRbhZPlzTA7I920O+bJhJvekWENxfHcCvdWnCtuNp1mz1RaI0qspsnN5BioXfryMlxtwPrBTS84qv+adH0ViGiHqD0nzmCjdh0IIZDsqu5D4vaVTDq7SyrFpEPstIDZHW2TA2c3u7JmgfYw/BjIwee7nDEz2XGQ==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777583718; cv=none;\n b=aDypkFCeeT2aTan9knwOmHqnuqDjbuTpQIxjIVJtGxJzfnsWtvdn4aNO0dYjrYITC4kXIi82H4MIO2jIXHqWV9IIZRMcuu/1zObuLkWUAcAQOYuun0rAn/tBZv0rZDSAgctRfx0caHJsPJpSOjnjSbm+o0mX+aXlV6fyHrU9KRo="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1777583726; c=relaxed/relaxed;\n\tbh=bAttvGhYlZzOkvQQMLcozJGeLf/rGdImBRQdlVyJlWY=;\n\th=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=u6wjECz9c+Yjbzr3wEYvudEBSymdbbO15jqX75UfughUqnJCbDKCYWPbXhE8+8NkdZF6G/m4F9esGhCTt45u6hbf65MQVcqiUoJPc2rI0JDVB0Wf9Nx71XCJmJwmlKzeJ249/U4PmwEh7ZbZQwFra5k+25iqvM1q16s1J0XVbCMe0HaPKeRHdegof35kTSgeUcv3wjW6Mv4CS4kDvdH72HBm2SFKM2jQKUSA9CvrUIWe5zZOwcUmiQWVRoaoeN4/oYmovYGIhTG+0lTFfxRw7HL/0RlHsgKfl9PKPakUfnp/LzTZ+OJ+NpPP4/I7/prs0KmRrXqikDSR9aTfW98Lew==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777583718; c=relaxed/simple;\n\tbh=EOymO4oY61WWpzMPS6eh41i6TXvJ89URZSns2tmAPJk=;\n\th=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References:\n\t MIME-Version:Content-Type;\n b=mw9MVqfFsMa3HNwZ2pKaT2FSQ0Z+VzUGjEThEs8PZFEA/O3zsLTgIInA/efpmKGGuRSqEJ2EEBUWGqiBh+3dGTWsqQRdRJB3PNm+XIaPHSzXXhkOvHlsgvpg0Xw64Hi2PgszAbxCzYXmksWBW8Tye9gpKm8pXxxVRQ4hvJTwPVs="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=B3sCIWar; dkim-atps=neutral;\n spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-16253-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=B3sCIWar; arc=none smtp.client-ip=10.30.226.201"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777583717;\n\tbh=EOymO4oY61WWpzMPS6eh41i6TXvJ89URZSns2tmAPJk=;\n\th=Date:Subject:From:To:Cc:In-Reply-To:References:From;\n\tb=B3sCIWarHW64fPwvz0M55mUM6tLsDlqoyKbrBrLkPa8R5hqx2V7XmsaSfoYtJGIgf\n\t TkO303b0IwzCPbsz4/FF7MbCJSc13FDOfxB2g4ATYWf8iWZ6ynB3ne07lg95UQ7Dng\n\t h5LKBK+EH3vkgYGfhEbxdzoLc0+4CW0NKIqWWWiGDZlv6dvXfl5+pTPdA+FnwqJdYR\n\t 8zQ96yorNeCGlldHx2uuSMoISmLBKL95lA8sqwvnaurQxFob1woAG5I4owM0fInN7q\n\t ttMXOduFhJ++B6QheJ3vc98NroEJWpGpWBA+3FpNh9Mlt08njAR+uKffBlwE0FZ8nG\n\t FhVPQFscpT2Og==","Date":"Thu, 30 Apr 2026 14:15:17 -0700","Subject":"[PATCH 01/13] Refactor mount code / move common functions to\n mount_util.c","From":"\"Darrick J. Wong\" <djwong@kernel.org>","To":"bernd@bsbernd.com, djwong@kernel.org","Cc":"linux-fsdevel@vger.kernel.org, fuse-devel@lists.linux.dev,\n linux-ext4@vger.kernel.org, miklos@szeredi.hu, neal@gompa.dev,\n joannelkoong@gmail.com","Message-ID":"<177758363550.1314717.5871127121158541585.stgit@frogsfrogsfrogs>","In-Reply-To":"<177758363484.1314717.11777978893472254088.stgit@frogsfrogsfrogs>","References":"<177758363484.1314717.11777978893472254088.stgit@frogsfrogsfrogs>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","X-Spam-Status":"No, score=-1.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,\n\tMAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled\n\tversion=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"From: Bernd Schubert <bernd@bsbernd.com>\n\nAlso create the new \"mount_i.h\", which is independent of the\nthe rest of libfuse.\n\nThis is preparation for the new mount API, which goes into a new file.\n\nThis is to allow fusermount to use the code from mount_fsmount.c.\nI.e. avoid code dup and add just re-use the new linux api mount\nfunctions from that file for fusermount.\n\nSigned-off-by: Bernd Schubert <bernd@bsbernd.com>\n[djwong: extract only the parts we need for mount services]\nReviewed-by: \"Darrick J. Wong\" <djwong@kernel.org>\nSigned-off-by: \"Darrick J. Wong\" <djwong@kernel.org>\n---\n lib/mount_common_i.h |   18 +++++++++++++++++\n lib/mount_util.h     |    8 ++++++++\n lib/mount.c          |   53 ++++++++++++++++++++++++++++++++++++--------------\n lib/mount_util.c     |    9 ++++++++\n util/fusermount.c    |    5 +----\n 5 files changed, 74 insertions(+), 19 deletions(-)\n create mode 100644 lib/mount_common_i.h","diff":"diff --git a/lib/mount_common_i.h b/lib/mount_common_i.h\nnew file mode 100644\nindex 00000000000000..6bcb055ff1c23f\n--- /dev/null\n+++ b/lib/mount_common_i.h\n@@ -0,0 +1,18 @@\n+/*\n+ *  FUSE: Filesystem in Userspace\n+ *  Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>\n+ *                2026 Bernd Schubert <bernd@bsbernd.com>\n+ *\n+ *  This program can be distributed under the terms of the GNU LGPLv2.\n+ *  See the file LGPL2.txt\n+ */\n+\n+#ifndef FUSE_MOUNT_COMMON_I_H_\n+#define FUSE_MOUNT_COMMON_I_H_\n+\n+struct mount_opts;\n+\n+char *fuse_mnt_build_source(const struct mount_opts *mo);\n+char *fuse_mnt_build_type(const struct mount_opts *mo);\n+\n+#endif /* FUSE_MOUNT_COMMON_I_H_ */\ndiff --git a/lib/mount_util.h b/lib/mount_util.h\nindex 9cb9077dd17738..b54392abb8b07d 100644\n--- a/lib/mount_util.h\n+++ b/lib/mount_util.h\n@@ -6,6 +6,9 @@\n   See the file LGPL2.txt.\n */\n \n+#ifndef FUSE_MOUNT_UTIL_H_\n+#define FUSE_MOUNT_UTIL_H_\n+\n #include <sys/types.h>\n \n int fuse_mnt_add_mount(const char *progname, const char *fsname,\n@@ -16,3 +19,8 @@ int fuse_mnt_umount(const char *progname, const char *abs_mnt,\n char *fuse_mnt_resolve_path(const char *progname, const char *orig);\n int fuse_mnt_check_fuseblk(void);\n int fuse_mnt_parse_fuse_fd(const char *mountpoint);\n+\n+/* Helper functions for mount operations */\n+const char *fuse_mnt_get_devname(void);\n+\n+#endif /* FUSE_MOUNT_UTIL_H_ */\ndiff --git a/lib/mount.c b/lib/mount.c\nindex c56a9da1fe8014..2397c3fb2aa26b 100644\n--- a/lib/mount.c\n+++ b/lib/mount.c\n@@ -31,6 +31,7 @@\n #include <sys/wait.h>\n \n #include \"fuse_mount_compat.h\"\n+#include \"mount_common_i.h\"\n \n #ifdef __NetBSD__\n #include <perfuse.h>\n@@ -49,7 +50,6 @@\n #define FUSERMOUNT_PROG\t\t\"fusermount3\"\n #define FUSE_COMMFD_ENV\t\t\"_FUSE_COMMFD\"\n #define FUSE_COMMFD2_ENV\t\"_FUSE_COMMFD2\"\n-#define FUSE_KERN_DEVICE_ENV\t\"FUSE_KERN_DEVICE\"\n \n #ifndef MS_DIRSYNC\n #define MS_DIRSYNC 128\n@@ -510,7 +510,7 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo,\n \t\t\t  const char *mnt_opts)\n {\n \tchar tmp[128];\n-\tconst char *devname = getenv(FUSE_KERN_DEVICE_ENV) ?: \"/dev/fuse\";\n+\tconst char *devname = fuse_mnt_get_devname();\n \tchar *source = NULL;\n \tchar *type = NULL;\n \tstruct stat stbuf;\n@@ -550,24 +550,13 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo,\n \tif (res == -1)\n \t\tgoto out_close;\n \n-\tsource = malloc((mo->fsname ? strlen(mo->fsname) : 0) +\n-\t\t\t(mo->subtype ? strlen(mo->subtype) : 0) +\n-\t\t\tstrlen(devname) + 32);\n-\n-\ttype = malloc((mo->subtype ? strlen(mo->subtype) : 0) + 32);\n+\tsource = fuse_mnt_build_source(mo);\n+\ttype = fuse_mnt_build_type(mo);\n \tif (!type || !source) {\n \t\tfuse_log(FUSE_LOG_ERR, \"fuse: failed to allocate memory\\n\");\n \t\tgoto out_close;\n \t}\n \n-\tstrcpy(type, mo->blkdev ? \"fuseblk\" : \"fuse\");\n-\tif (mo->subtype) {\n-\t\tstrcat(type, \".\");\n-\t\tstrcat(type, mo->subtype);\n-\t}\n-\tstrcpy(source,\n-\t       mo->fsname ? mo->fsname : (mo->subtype ? mo->subtype : devname));\n-\n \tres = mount(source, mnt, type, mo->flags, mo->kernel_opts);\n \tif (res == -1 && errno == ENODEV && mo->subtype) {\n \t\t/* Probably missing subtype support */\n@@ -727,3 +716,37 @@ int fuse_kern_mount(const char *mountpoint, struct mount_opts *mo)\n \tfree(mnt_opts);\n \treturn res;\n }\n+\n+char *fuse_mnt_build_source(const struct mount_opts *mo)\n+{\n+\tconst char *devname = fuse_mnt_get_devname();\n+\tchar *source;\n+\n+\tsource = malloc((mo->fsname ? strlen(mo->fsname) : 0) +\n+\t\t\t(mo->subtype ? strlen(mo->subtype) : 0) +\n+\t\t\tstrlen(devname) + 32);\n+\tif (!source)\n+\t\treturn NULL;\n+\n+\tstrcpy(source,\n+\t       mo->fsname ? mo->fsname : (mo->subtype ? mo->subtype : devname));\n+\n+\treturn source;\n+}\n+\n+char *fuse_mnt_build_type(const struct mount_opts *mo)\n+{\n+\tchar *type;\n+\n+\ttype = malloc((mo->subtype ? strlen(mo->subtype) : 0) + 32);\n+\tif (!type)\n+\t\treturn NULL;\n+\n+\tstrcpy(type, mo->blkdev ? \"fuseblk\" : \"fuse\");\n+\tif (mo->subtype) {\n+\t\tstrcat(type, \".\");\n+\t\tstrcat(type, mo->subtype);\n+\t}\n+\n+\treturn type;\n+}\ndiff --git a/lib/mount_util.c b/lib/mount_util.c\nindex 5746e8ed06b736..bdafeda7567fbd 100644\n--- a/lib/mount_util.c\n+++ b/lib/mount_util.c\n@@ -377,3 +377,12 @@ int fuse_mnt_parse_fuse_fd(const char *mountpoint)\n \n \treturn -1;\n }\n+\n+#define FUSE_KERN_DEVICE_ENV\t\"FUSE_KERN_DEVICE\"\n+\n+const char *fuse_mnt_get_devname(void)\n+{\n+\tconst char *devname = getenv(FUSE_KERN_DEVICE_ENV);\n+\n+\treturn devname ? devname : \"/dev/fuse\";\n+}\ndiff --git a/util/fusermount.c b/util/fusermount.c\nindex a5ed4d26dd4d27..68370468140a59 100644\n--- a/util/fusermount.c\n+++ b/util/fusermount.c\n@@ -47,9 +47,6 @@\n #endif\n \n #define FUSE_COMMFD_ENV\t\t\"_FUSE_COMMFD\"\n-#define FUSE_KERN_DEVICE_ENV\t\"FUSE_KERN_DEVICE\"\n-\n-#define FUSE_DEV \"/dev/fuse\"\n \n static const char *progname;\n \n@@ -1262,7 +1259,7 @@ static int mount_fuse(const char *mnt, const char *opts, const char **type)\n {\n \tint res;\n \tint fd;\n-\tconst char *dev = getenv(FUSE_KERN_DEVICE_ENV) ?: FUSE_DEV;\n+\tconst char *dev = fuse_mnt_get_devname();\n \tstruct stat stbuf;\n \tchar *source = NULL;\n \tchar *mnt_opts = NULL;\n","prefixes":["01/13"]}