Skip to contentSkip to conversation

initrd/initramfs: extracted common code to init_rootfs.c file

RFC PATCH In review Vasyl Vavrychuk 2 participants 2 messages Jul 16, 2018 VFS

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 initrd/initramfs: extracted common code to init_rootfs.c file

Extracted from initramfs to common place code that sits on top of iniramfs and initrd and initializes one or another depending on configuration.

---
 init/Makefile           |   5 +-
 init/default_rootfs.c   |  52 ++++++++++++++++
 init/do_mounts_initrd.c |   2 -
 init/init_rootfs.c      | 162 ++++++++++++++++++++++++++++++++++++++++++++++++
 init/initramfs.c        | 156 +---------------------------------------------
 init/initramfs.h        |   4 ++
 init/noinitramfs.c      |  52 ----------------
 7 files changed, 222 insertions(+), 211 deletions(-)
 create mode 100644 init/default_rootfs.c
 create mode 100644 init/init_rootfs.c
 create mode 100644 init/initramfs.h
 delete mode 100644 init/noinitramfs.c
init/Makefile +3 -2
index a3e5ce2..d513411 100644
@@ -7,10 +7,11 @@ ccflags-y := -fno-function-sections -fno-data-sections
 
 obj-y                          := main.o version.o mounts.o
 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
-obj-y                          += noinitramfs.o
+obj-y                          += default_rootfs.o
 else
-obj-$(CONFIG_BLK_DEV_INITRD)   += initramfs.o
+obj-$(CONFIG_BLK_DEV_INITRD)   += init_rootfs.o
 endif
+obj-$(CONFIG_BLK_DEV_INITRD)   += initramfs.o
 obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
 
 obj-y                          += init_task.o
init/default_rootfs.c new file +52 -0

52 lines not on this page · raw message

init/do_mounts_initrd.c +0 -2
index 5a91aef..05b958f 100644
@@ -21,8 +21,6 @@
 
 #include "do_mounts.h"
 
-unsigned long initrd_start, initrd_end;
-int initrd_below_start_ok;
 unsigned int real_root_dev;	/* do_proc_dointvec cannot handle kdev_t */
 static int __initdata mount_initrd = 1;
 
init/init_rootfs.c new file +162 -0

162 lines not on this page · raw message

init/initramfs.c +1 -155

165 lines not on this page · raw message

init/initramfs.h new file +4 -0
new file mode 100644
index 0000000..3ecad6f
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/init.h>
+
+char * __init initramfs_unpack_to_rootfs(char *buf, unsigned long len);
init/noinitramfs.c deleted +0 -52

52 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Quoted 5 lines · Vasyl Vavrychuk

Extracted from initramfs to common place code that sits on top of iniramfs and initrd and initializes one or another depending on configuration.

Just nits here...

Quoted 9 lines
---
 init/Makefile           |   5 +-
 init/default_rootfs.c   |  52 ++++++++++++++++
 init/do_mounts_initrd.c |   2 -
 init/init_rootfs.c      | 162 ++++++++++++++++++++++++++++++++++++++++++++++++
 init/initramfs.c        | 156 +---------------------------------------------
 init/initramfs.h        |   4 ++
 init/noinitramfs.c      |  52 ----------------
 7 files changed, 222 insertions(+), 211 deletions(-)

Does this change save us anything? More source code. How about object code?

Quoted 12 lines
 create mode 100644 init/default_rootfs.c
 create mode 100644 init/init_rootfs.c
 create mode 100644 init/initramfs.h
 delete mode 100644 init/noinitramfs.c
init/default_rootfs.c new file +0 -0
new file mode 100644
index 0000000..f4bad84

init/default_rootfs.c line 2

Quoted 2 lines
init/default_rootfs.c new file +2 -0
@@ -0,0 +1,52 @@
+/*
+ * init/noinitramfs.c

wrong source file name.

init/initramfs.h line 4

Quoted 10 lines
init/initramfs.h new file +4 -0
new file mode 100644
index 0000000..3ecad6f
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/init.h>
+
+char * __init initramfs_unpack_to_rootfs(char *buf, unsigned long len);

Unfortunately, the format for SPDX identifiers in C header files is thus:

/* SPDX-License-Identifier: <SPDX License Expression> */

according to Documentation/process/license-rules.rst.

thanks,

Signature · 1 line
~Randy