mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Jonathan Corbet <corbet@lwn.net>,
	"H. Peter Anvin" <hpa@zytor.com>
Cc: linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Lennart Poettering <lennart@poettering.net>,
	systemd-devel@lists.freedesktop.org
Subject: [RFC PATCH 1/3] fs/init: move creating the mount data_page into init_mount()
Date: Fri, 23 Jan 2026 16:39:34 -0800	[thread overview]
Message-ID: <20260124003939.426931-2-hpa@zytor.com> (raw)
In-Reply-To: <20260124003939.426931-1-hpa@zytor.com>

path_mount() wants the mount data if not NULL to be a whole
page. Expanding a string onto an allocated page was done in
do_mount_root(); move it instead into init_mount() so other users of
init_mount() can leverage this same code.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
 fs/init.c                     | 23 ++++++++++++++++++++---
 include/linux/init_syscalls.h |  3 ++-
 init/do_mounts.c              | 17 ++---------------
 3 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/fs/init.c b/fs/init.c
index e0f5429c0a49..1253bcc73e26 100644
--- a/fs/init.c
+++ b/fs/init.c
@@ -14,16 +14,33 @@
 #include "internal.h"
 
 int __init init_mount(const char *dev_name, const char *dir_name,
-		const char *type_page, unsigned long flags, void *data_page)
+		      const char *type_page, unsigned long flags,
+		      const char *data_str)
 {
+	struct page *data_page = NULL;
+	char *data_buf = NULL;
 	struct path path;
 	int ret;
 
+	/* path_mount() wants a proper page for data */
+	if (data_str && data_str[0]) {
+		data_page = alloc_page(GFP_KERNEL);
+		if (!data_page)
+			return -ENOMEM;
+		data_buf = page_address(data_page);
+		strscpy_pad(data_buf, data_str, PAGE_SIZE);
+	}
+
 	ret = kern_path(dir_name, LOOKUP_FOLLOW, &path);
 	if (ret)
-		return ret;
-	ret = path_mount(dev_name, &path, type_page, flags, data_page);
+		goto out;
+
+	ret = path_mount(dev_name, &path, type_page, flags, data_buf);
 	path_put(&path);
+
+out:
+	if (data_page)
+		put_page(data_page);
 	return ret;
 }
 
diff --git a/include/linux/init_syscalls.h b/include/linux/init_syscalls.h
index 92045d18cbfc..804d3070ce73 100644
--- a/include/linux/init_syscalls.h
+++ b/include/linux/init_syscalls.h
@@ -1,7 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 
 int __init init_mount(const char *dev_name, const char *dir_name,
-		const char *type_page, unsigned long flags, void *data_page);
+		      const char *type_page, unsigned long flags,
+		      const char *data_str);
 int __init init_umount(const char *name, int flags);
 int __init init_chdir(const char *filename);
 int __init init_chroot(const char *filename);
diff --git a/init/do_mounts.c b/init/do_mounts.c
index defbbf1d55f7..87cf110a48e6 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -147,23 +147,12 @@ static int __init split_fs_names(char *page, size_t size)
 }
 
 static int __init do_mount_root(const char *name, const char *fs,
-				 const int flags, const void *data)
+				 const int flags, const char *data)
 {
 	struct super_block *s;
-	struct page *p = NULL;
-	char *data_page = NULL;
 	int ret;
 
-	if (data) {
-		/* init_mount() requires a full page as fifth argument */
-		p = alloc_page(GFP_KERNEL);
-		if (!p)
-			return -ENOMEM;
-		data_page = page_address(p);
-		strscpy_pad(data_page, data, PAGE_SIZE);
-	}
-
-	ret = init_mount(name, "/root", fs, flags, data_page);
+	ret = init_mount(name, "/root", fs, flags, data);
 	if (ret)
 		goto out;
 
@@ -177,8 +166,6 @@ static int __init do_mount_root(const char *name, const char *fs,
 	       MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
 
 out:
-	if (p)
-		put_page(p);
 	return ret;
 }
 
-- 
2.52.0


  reply	other threads:[~2026-01-24  0:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-24  0:39 [PATCH 0/3] Add the ability to mount filesystems during initramfs expansion H. Peter Anvin
2026-01-24  0:39 ` H. Peter Anvin [this message]
2026-01-24  0:39 ` [RFC PATCH 2/3] initramfs: support mounting " H. Peter Anvin
2026-01-24  0:39 ` [RFC PATCH 3/3] Documentation/initramfs: document mount points in initramfs H. Peter Anvin
2026-01-24 17:41 ` [PATCH 0/3] Add the ability to mount filesystems during initramfs expansion Askar Safin
2026-01-24 18:33   ` H. Peter Anvin
2026-01-25  0:07   ` H. Peter Anvin
2026-02-02  7:38 ` [EXT] [systemd-devel] " Windl, Ulrich
2026-02-03 16:11   ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260124003939.426931-2-hpa@zytor.com \
    --to=hpa@zytor.com \
    --cc=brauner@kernel.org \
    --cc=corbet@lwn.net \
    --cc=jack@suse.cz \
    --cc=lennart@poettering.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=systemd-devel@lists.freedesktop.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®