summaryrefslogtreecommitdiffstats
path: root/meta-initramfs
diff options
context:
space:
mode:
authorAndrea Adami <andrea.adami@gmail.com>2014-11-24 00:17:44 +0100
committerMartin Jansa <Martin.Jansa@gmail.com>2014-12-09 11:34:42 +0100
commit102486523b2b2506c31ca2dcfe9fc08001f60e95 (patch)
treeeb84c730295a1eb484aa2dc9485bf4d7a2f91847 /meta-initramfs
parentd6afd2bdb631e2fba76e987370883a7337c440d5 (diff)
downloadmeta-openembedded-102486523b2b2506c31ca2dcfe9fc08001f60e95.tar.gz
kexecboot: apply OE specific fixes (pending upstream)
After 78ee4d8b1782445caecce8331e68efe83fc32044 in oe-core the kernel is an *absolute* symlink in /boot. Unfortunately this implies the stock images built with OE can not be booted. The last patch of this commit fixes this issue. The other patches are fixing build when S!=B, autotools-brokensep and configure warnings. Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-initramfs')
-rw-r--r--meta-initramfs/recipes-bsp/kexecboot/files/0001-kexecboot-fix-build-when-S-B.patch61
-rw-r--r--meta-initramfs/recipes-bsp/kexecboot/files/0002-kexecboot-fix-configure-warnings.patch33
-rw-r--r--meta-initramfs/recipes-bsp/kexecboot/files/0003-kexecboot-do-not-hardcode-MOUNTPOINT.patch97
-rw-r--r--meta-initramfs/recipes-bsp/kexecboot/files/0004-kexecboot.c-workaround-for-absolute-kernel-and-initr.patch135
-rw-r--r--meta-initramfs/recipes-bsp/kexecboot/kexecboot_0.6.bb9
5 files changed, 334 insertions, 1 deletions
diff --git a/meta-initramfs/recipes-bsp/kexecboot/files/0001-kexecboot-fix-build-when-S-B.patch b/meta-initramfs/recipes-bsp/kexecboot/files/0001-kexecboot-fix-build-when-S-B.patch
new file mode 100644
index 000000000..6d3270f89
--- /dev/null
+++ b/meta-initramfs/recipes-bsp/kexecboot/files/0001-kexecboot-fix-build-when-S-B.patch
@@ -0,0 +1,61 @@
1From 8519d61a7097498b0ee93fb8dc8262286825f3e5 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Thu, 1 May 2014 23:58:51 +0200
4Subject: [PATCH 1/4] kexecboot: fix build when S != B
5
6* fatal error: ../config.h: No such file or directory
7
8Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
9---
10 machine/zaurus.c | 2 +-
11 res/theme-gui.h | 2 +-
12 res/theme-tui.h | 4 ++--
13 3 files changed, 4 insertions(+), 4 deletions(-)
14
15diff --git a/machine/zaurus.c b/machine/zaurus.c
16index ea21047..83be13b 100644
17--- a/machine/zaurus.c
18+++ b/machine/zaurus.c
19@@ -25,7 +25,7 @@
20 *
21 */
22
23-#include "../config.h"
24+#include "config.h"
25
26 #ifdef USE_ZAURUS
27
28diff --git a/res/theme-gui.h b/res/theme-gui.h
29index f8fef7f..79bed39 100644
30--- a/res/theme-gui.h
31+++ b/res/theme-gui.h
32@@ -15,7 +15,7 @@
33 *
34 */
35
36-#include "../config.h"
37+#include "config.h"
38
39 #ifdef USE_ICONS
40 /** Icons **/
41diff --git a/res/theme-tui.h b/res/theme-tui.h
42index 94e7693..909be56 100644
43--- a/res/theme-tui.h
44+++ b/res/theme-tui.h
45@@ -15,11 +15,11 @@
46 *
47 */
48
49-#include "../config.h"
50+#include "config.h"
51
52 #ifdef USE_TEXTUI
53 /** TEXT UI colors **/
54-#include "../termseq.h"
55+#include "termseq.h"
56
57 /* Background color pair */
58 #define TUI_CLR_BG TERM_CSI TERM_BG_BLACK ";" TERM_FG_WHITE TERM_SGR
59--
601.9.1
61
diff --git a/meta-initramfs/recipes-bsp/kexecboot/files/0002-kexecboot-fix-configure-warnings.patch b/meta-initramfs/recipes-bsp/kexecboot/files/0002-kexecboot-fix-configure-warnings.patch
new file mode 100644
index 000000000..ecf422b72
--- /dev/null
+++ b/meta-initramfs/recipes-bsp/kexecboot/files/0002-kexecboot-fix-configure-warnings.patch
@@ -0,0 +1,33 @@
1From b8938acc3f1ab35273fa9a2fa7728050ef72ff65 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Fri, 2 May 2014 00:19:24 +0200
4Subject: [PATCH 2/4] kexecboot: fix configure warnings
5
6Makefile.am:5: warning: source file 'fstype/fstype.c' is in a subdirectory,
7Makefile.am:5: but option 'subdir-objects' is disabled
8automake: warning: possible forward-incompatibility.
9...
10Makefile.am:5: warning: source file 'machine/zaurus.c' is in a subdirectory,
11...
12
13Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
14---
15 configure.ac | 2 +-
16 1 file changed, 1 insertion(+), 1 deletion(-)
17
18diff --git a/configure.ac b/configure.ac
19index 0ca4b81..66ec54e 100644
20--- a/configure.ac
21+++ b/configure.ac
22@@ -1,7 +1,7 @@
23 AC_PREREQ(2.53)
24 AC_INIT([kexecboot], [0.6], [kexecboot-devel@linuxtogo.org])
25 AC_CANONICAL_HOST
26-AM_INIT_AUTOMAKE([-Wall foreign])
27+AM_INIT_AUTOMAKE([-Wall foreign] [subdir-objects])
28 AC_CONFIG_SRCDIR(kexecboot.c)
29 AC_CONFIG_HEADERS(config.h)
30 AM_MAINTAINER_MODE
31--
321.9.1
33
diff --git a/meta-initramfs/recipes-bsp/kexecboot/files/0003-kexecboot-do-not-hardcode-MOUNTPOINT.patch b/meta-initramfs/recipes-bsp/kexecboot/files/0003-kexecboot-do-not-hardcode-MOUNTPOINT.patch
new file mode 100644
index 000000000..4caa0d5f0
--- /dev/null
+++ b/meta-initramfs/recipes-bsp/kexecboot/files/0003-kexecboot-do-not-hardcode-MOUNTPOINT.patch
@@ -0,0 +1,97 @@
1From 800dae0d34f8629a34c638a612166b76dda03e27 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sat, 2 Aug 2014 01:13:08 +0200
4Subject: [PATCH 3/4] kexecboot: do not hardcode MOUNTPOINT
5
6Avoid to hardcode it: could be requested as a new configure option.
7
8Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
9---
10 cfgparser.c | 6 +++---
11 kexecboot.c | 18 ++++++++++--------
12 2 files changed, 13 insertions(+), 11 deletions(-)
13
14diff --git a/cfgparser.c b/cfgparser.c
15index 8f6688c..dec27b1 100644
16--- a/cfgparser.c
17+++ b/cfgparser.c
18@@ -141,7 +141,7 @@ static int set_kernel(struct cfgdata_t *cfgdata, char *value)
19 return -1;
20 }
21
22- strcpy(sc->kernelpath, "/mnt");
23+ strcpy(sc->kernelpath, MOUNTPOINT);
24 strcat(sc->kernelpath, value);
25 return 0;
26 }
27@@ -155,7 +155,7 @@ static int set_icon(struct cfgdata_t *cfgdata, char *value)
28
29 dispose(sc->iconpath);
30 /* Add our mountpoint, since the enduser won't know it */
31- sc->iconpath = malloc(sizeof(MOUNTPOINT)+strlen(value));
32+ sc->iconpath = malloc(strlen(MOUNTPOINT)+strlen(value)+1);
33 if (NULL == sc->iconpath) {
34 DPRINTF("Can't allocate memory to store iconpath '%s'", value);
35 return -1;
36@@ -194,7 +194,7 @@ static int set_initrd(struct cfgdata_t *cfgdata, char *value)
37 return -1;
38 }
39
40- strcpy(sc->initrd, "/mnt");
41+ strcpy(sc->initrd, MOUNTPOINT);
42 strcat(sc->initrd, value);
43 return 0;
44 }
45diff --git a/kexecboot.c b/kexecboot.c
46index d6657a0..7268d6b 100644
47--- a/kexecboot.c
48+++ b/kexecboot.c
49@@ -57,20 +57,22 @@
50 #endif
51
52 #ifdef USE_MACHINE_KERNEL
53-/* Machine-dependent kernel patch */
54+/* Machine-dependent kernel path */
55 char *machine_kernel = NULL;
56 #endif
57
58+#define PREPEND_MOUNTPATH(string) MOUNTPOINT""string
59+
60 /* NULL-terminated array of kernel search paths
61 * First item should be filled with machine-dependent path */
62 char *default_kernels[] = {
63 #ifdef USE_ZIMAGE
64- "/mnt/boot/zImage",
65- "/mnt/zImage",
66+ PREPEND_MOUNTPATH("/boot/zImage"),
67+ PREPEND_MOUNTPATH("/zImage"),
68 #endif
69 #ifdef USE_UIMAGE
70- "/mnt/boot/uImage",
71- "/mnt/uImage",
72+ PREPEND_MOUNTPATH("/boot/uImage"),
73+ PREPEND_MOUNTPATH("/uImage"),
74 #endif
75 NULL
76 };
77@@ -149,14 +151,14 @@ char *get_machine_kernelpath() {
78 ++tmp;
79 }
80
81- /* Prepend "/mnt/boot/zImage-" to hw */
82- tmp = malloc(strlen(hw) + 17 + 1); /* strlen("/mnt/boot/zImage-") */
83+ /* Prepend MOUNTPOINT"/boot/zImage-" to hw */
84+ tmp = malloc(strlen(PREPEND_MOUNTPATH("/boot/zImage-")) + strlen(hw) + 1);
85 if (NULL == tmp) {
86 DPRINTF("Can't allocate memory for machine-specific kernel path");
87 return NULL;
88 }
89
90- strcpy(tmp, "/mnt/boot/zImage-");
91+ strcpy(tmp, PREPEND_MOUNTPATH("/boot/zImage-"));
92 strcat(tmp, hw);
93
94 return tmp;
95--
961.9.1
97
diff --git a/meta-initramfs/recipes-bsp/kexecboot/files/0004-kexecboot.c-workaround-for-absolute-kernel-and-initr.patch b/meta-initramfs/recipes-bsp/kexecboot/files/0004-kexecboot.c-workaround-for-absolute-kernel-and-initr.patch
new file mode 100644
index 000000000..6d81d8357
--- /dev/null
+++ b/meta-initramfs/recipes-bsp/kexecboot/files/0004-kexecboot.c-workaround-for-absolute-kernel-and-initr.patch
@@ -0,0 +1,135 @@
1From de9a6284df8add6ec03e1d9981d0b6d0595bbc69 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Mon, 10 Nov 2014 23:37:23 +0100
4Subject: [PATCH 4/4] kexecboot.c: workaround for absolute kernel and initrd
5 symlinks
6
7Add MOUNTPOINT prefix if the kernel/initrd symlinks start with '/'.
8Do nothing if the path is a relative symbolic link or not a symlink.
9
10Fix following situation:
11
12root@mizar:/var/tmp# ls -al boot/
13total 2076
14drwxr-xr-x 2 root root 4096 lug 5 01:38 .
15drwxrwxrwt 4 root root 4096 lug 5 12:26 ..
16-rw-r--r-- 1 root root 831 lug 5 01:24 boot.cfg
17-rw-r--r-- 1 root root 1322 lug 5 01:24 icon.xpm
18lrwxrwxrwx 1 root root 34 lug 5 12:26 zImage ->
19/boot/zImage-3.14.5-yocto-standard
20-rw-r--r-- 1 root root 2106832 lug 5 01:20 zImage-3.14.5-yocto-standard
21
22Cannot open `/mnt/boot/zImage': No such file or directory
23Nothing has been loaded!
24
25Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
26---
27 kexecboot.c | 53 ++++++++++++++++++++++++++++++++++++++++++++---------
28 1 file changed, 44 insertions(+), 9 deletions(-)
29
30diff --git a/kexecboot.c b/kexecboot.c
31index 7268d6b..8a7a7d2 100644
32--- a/kexecboot.c
33+++ b/kexecboot.c
34@@ -208,11 +208,16 @@ void start_kernel(struct params_t *params, int choice)
35 const char *load_argv[] = { NULL, "-l", NULL, NULL, NULL, NULL };
36 const char *exec_argv[] = { NULL, "-e", NULL, NULL};
37
38- char *cmdline_arg = NULL, *initrd_arg = NULL;
39+ char *cmdline_arg = NULL, *initrd_arg = NULL, *kernel_arg = NULL;
40 int n, idx, u;
41 struct stat sinfo;
42 struct boot_item_t *item;
43
44+ /* buffer for readlink (could be truncated) */
45+ char buf[512];
46+ int len;
47+
48+
49 item = params->bootcfg->list[choice];
50
51 exec_argv[0] = kexec_path;
52@@ -306,10 +311,17 @@ void start_kernel(struct params_t *params, int choice)
53 }
54 }
55
56+ /* Mount boot device */
57+ if ( -1 == mount(mount_dev, mount_point, mount_fstype,
58+ MS_RDONLY, NULL) ) {
59+ perror("Can't mount boot device");
60+ exit(-1);
61+ }
62+
63 /* fill '--initrd' option */
64 if (item->initrd) {
65 /* allocate space */
66- n = sizeof(str_initrd_start) + strlen(item->initrd);
67+ n = sizeof(str_initrd_start) + strlen(item->initrd) + 1 + sizeof(mount_point) + sizeof(buf);
68
69 initrd_arg = (char *)malloc(n);
70 if (NULL == initrd_arg) {
71@@ -317,24 +329,46 @@ void start_kernel(struct params_t *params, int choice)
72 } else {
73 strcpy(initrd_arg, str_initrd_start); /* --initrd= */
74 strcat(initrd_arg, item->initrd);
75+
76+ if ((len = readlink(item->initrd, buf, sizeof(buf)-1)) != -1) {
77+ buf[len] = '\0';
78+ /* Fix absolute symlinks: prepend MOUNTPOINT */
79+ if (buf[0] == '/') {
80+ strcpy(initrd_arg, str_initrd_start); /* --initrd= */
81+ strcat(initrd_arg, mount_point);
82+ strcat(initrd_arg, buf);
83+ }
84+ }
85 load_argv[idx] = initrd_arg;
86 ++idx;
87 }
88 }
89
90 /* Append kernelpath as last arg of kexec */
91- load_argv[idx] = item->kernelpath;
92+ /* allocate space */
93+ n = strlen(item->kernelpath) + 1 + sizeof(mount_point) + sizeof(buf);
94+
95+ kernel_arg = (char *)malloc(n);
96+ if (NULL == kernel_arg) {
97+ perror("Can't allocate memory for kernel_arg");
98+ } else {
99+ strcpy(kernel_arg, item->kernelpath);
100+
101+ if ((len = readlink(item->kernelpath, buf, sizeof(buf)-1)) != -1) {
102+ buf[len] = '\0';
103+ /* Fix absolute symlinks: prepend MOUNTPOINT */
104+ if (buf[0] == '/') {
105+ strcpy(kernel_arg, mount_point);
106+ strcat(kernel_arg, buf);
107+ }
108+ }
109+ load_argv[idx] = kernel_arg;
110+ }
111
112 DPRINTF("load_argv: %s, %s, %s, %s, %s", load_argv[0],
113 load_argv[1], load_argv[2],
114 load_argv[3], load_argv[4]);
115
116- /* Mount boot device */
117- if ( -1 == mount(mount_dev, mount_point, mount_fstype,
118- MS_RDONLY, NULL) ) {
119- perror("Can't mount boot device");
120- exit(-1);
121- }
122
123 /* Load kernel */
124 n = fexecw(kexec_path, (char *const *)load_argv, envp);
125@@ -347,6 +381,7 @@ void start_kernel(struct params_t *params, int choice)
126
127 dispose(cmdline_arg);
128 dispose(initrd_arg);
129+ dispose(kernel_arg);
130
131 /* Check /proc/sys/net presence */
132 if ( -1 == stat("/proc/sys/net", &sinfo) ) {
133--
1341.9.1
135
diff --git a/meta-initramfs/recipes-bsp/kexecboot/kexecboot_0.6.bb b/meta-initramfs/recipes-bsp/kexecboot/kexecboot_0.6.bb
index 1fb5f0da5..9061c272f 100644
--- a/meta-initramfs/recipes-bsp/kexecboot/kexecboot_0.6.bb
+++ b/meta-initramfs/recipes-bsp/kexecboot/kexecboot_0.6.bb
@@ -42,7 +42,14 @@ SRC_URI = "https://github.com/kexecboot/kexecboot/archive/v${PV}.tar.gz"
42SRC_URI[md5sum] = "46b7c1a6f20531be56445ebb8669a2b8" 42SRC_URI[md5sum] = "46b7c1a6f20531be56445ebb8669a2b8"
43SRC_URI[sha256sum] = "6b360b8aa59bc5d68a96705349a0dd416f8ed704e931fa0ac7849298258f0f15" 43SRC_URI[sha256sum] = "6b360b8aa59bc5d68a96705349a0dd416f8ed704e931fa0ac7849298258f0f15"
44 44
45inherit autotools-brokensep 45SRC_URI += "\
46 file://0001-kexecboot-fix-build-when-S-B.patch \
47 file://0002-kexecboot-fix-configure-warnings.patch \
48 file://0003-kexecboot-do-not-hardcode-MOUNTPOINT.patch \
49 file://0004-kexecboot.c-workaround-for-absolute-kernel-and-initr.patch \
50 "
51
52inherit autotools
46 53
47EXTRA_OECONF = "--enable-delay=2 --enable-evdev-rate=1000,250" 54EXTRA_OECONF = "--enable-delay=2 --enable-evdev-rate=1000,250"
48 55