summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2025-03-04 16:57:44 +1100
committerChristian Brauner <brauner@kernel.org>2025-03-04 09:52:36 +0100
commit5f469c4f716746bc8aebf84a34faa5d14e78bf7e (patch)
tree185e96a0eacf8e226f3eeda7322fe949de42b20c /init
parent2014c95afecee3e76ca4a56956a936e23283f05b (diff)
downloadlinux-5f469c4f716746bc8aebf84a34faa5d14e78bf7e.tar.gz
linux-5f469c4f716746bc8aebf84a34faa5d14e78bf7e.tar.bz2
linux-5f469c4f716746bc8aebf84a34faa5d14e78bf7e.zip
init: add initramfs_internal.h
The new header only exports a single unpack function and a CPIO_HDRLEN constant for future test use. Signed-off-by: David Disseldorp <ddiss@suse.de> Link: https://lore.kernel.org/r/20250304061020.9815-2-ddiss@suse.de Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'init')
-rw-r--r--init/initramfs.c16
-rw-r--r--init/initramfs_internal.h8
2 files changed, 21 insertions, 3 deletions
diff --git a/init/initramfs.c b/init/initramfs.c
index b2f7583bb1f5..002e83ae12ac 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -20,6 +20,7 @@
#include <linux/security.h>
#include "do_mounts.h"
+#include "initramfs_internal.h"
static __initdata bool csum_present;
static __initdata u32 io_csum;
@@ -256,7 +257,7 @@ static __initdata char *header_buf, *symlink_buf, *name_buf;
static int __init do_start(void)
{
- read_into(header_buf, 110, GotHeader);
+ read_into(header_buf, CPIO_HDRLEN, GotHeader);
return 0;
}
@@ -497,14 +498,23 @@ static unsigned long my_inptr __initdata; /* index of next byte to be processed
#include <linux/decompress/generic.h>
-static char * __init unpack_to_rootfs(char *buf, unsigned long len)
+/**
+ * unpack_to_rootfs - decompress and extract an initramfs archive
+ * @buf: input initramfs archive to extract
+ * @len: length of initramfs data to process
+ *
+ * Returns: NULL for success or an error message string
+ *
+ * This symbol shouldn't be used externally. It's available for unit tests.
+ */
+char * __init unpack_to_rootfs(char *buf, unsigned long len)
{
long written;
decompress_fn decompress;
const char *compress_name;
static __initdata char msg_buf[64];
- header_buf = kmalloc(110, GFP_KERNEL);
+ header_buf = kmalloc(CPIO_HDRLEN, GFP_KERNEL);
symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL);
diff --git a/init/initramfs_internal.h b/init/initramfs_internal.h
new file mode 100644
index 000000000000..233dad16b0a0
--- /dev/null
+++ b/init/initramfs_internal.h
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef __INITRAMFS_INTERNAL_H__
+#define __INITRAMFS_INTERNAL_H__
+
+char *unpack_to_rootfs(char *buf, unsigned long len);
+#define CPIO_HDRLEN 110
+
+#endif