Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Disseldorp and committed by
Christian Brauner
5f469c4f 2014c95a

+21 -3
+13 -3
init/initramfs.c
··· 20 20 #include <linux/security.h> 21 21 22 22 #include "do_mounts.h" 23 + #include "initramfs_internal.h" 23 24 24 25 static __initdata bool csum_present; 25 26 static __initdata u32 io_csum; ··· 257 256 258 257 static int __init do_start(void) 259 258 { 260 - read_into(header_buf, 110, GotHeader); 259 + read_into(header_buf, CPIO_HDRLEN, GotHeader); 261 260 return 0; 262 261 } 263 262 ··· 498 497 499 498 #include <linux/decompress/generic.h> 500 499 501 - static char * __init unpack_to_rootfs(char *buf, unsigned long len) 500 + /** 501 + * unpack_to_rootfs - decompress and extract an initramfs archive 502 + * @buf: input initramfs archive to extract 503 + * @len: length of initramfs data to process 504 + * 505 + * Returns: NULL for success or an error message string 506 + * 507 + * This symbol shouldn't be used externally. It's available for unit tests. 508 + */ 509 + char * __init unpack_to_rootfs(char *buf, unsigned long len) 502 510 { 503 511 long written; 504 512 decompress_fn decompress; 505 513 const char *compress_name; 506 514 static __initdata char msg_buf[64]; 507 515 508 - header_buf = kmalloc(110, GFP_KERNEL); 516 + header_buf = kmalloc(CPIO_HDRLEN, GFP_KERNEL); 509 517 symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL); 510 518 name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL); 511 519
+8
init/initramfs_internal.h
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #ifndef __INITRAMFS_INTERNAL_H__ 3 + #define __INITRAMFS_INTERNAL_H__ 4 + 5 + char *unpack_to_rootfs(char *buf, unsigned long len); 6 + #define CPIO_HDRLEN 110 7 + 8 + #endif