[oe-commits] org.oe.dev kexecboot: add patch to read mtdparts from /proc/cmdline

ant, commit oe at amethyst.openembedded.net
Thu Sep 4 10:20:50 UTC 2008


kexecboot: add patch to read mtdparts from /proc/cmdline
initramfs-kexecboot: add rotation parameter for c7x0
linux-kexecboot_2.6.26: change defconfigs

Author: ant,
Branch: org.openembedded.dev
Revision: 0d3b0d788fccfc1c07e0da07e8f8596c062e2ef2
ViewMTN: http://monotone.openembedded.org/revision/info/0d3b0d788fccfc1c07e0da07e8f8596c062e2ef2
Files:
1
packages/kexecboot/files/rootdelay.patch
packages/kexecboot/files/kexecboot-rewrite.patch
packages/kexecboot/initramfs-kexecboot_1.0.bb
packages/kexecboot/kexecboot_0.3.bb
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-akita
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-bootcdx86
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-c7x0
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-htcuniversal
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-hx2000
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-poodle
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-qemuarm
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-qemux86
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-spitz
packages/kexecboot/linux-kexecboot-2.6.26/defconfig-zylonite
packages/kexecboot/linux-kexecboot.inc
packages/kexecboot/linux-kexecboot_2.6.26.bb
Diffs:

#
# mt diff -r2e853a59a8c459403ea34cd969fa9fcc331fd892 -r0d3b0d788fccfc1c07e0da07e8f8596c062e2ef2
#
#
#
# delete "packages/kexecboot/files/rootdelay.patch"
# 
# add_file "packages/kexecboot/files/kexecboot-rewrite.patch"
#  content [c170a72f30755508c630b99d3fd340fc32776280]
# 
# patch "packages/kexecboot/initramfs-kexecboot_1.0.bb"
#  from [d3cfea5e56d92934495f6342d176e974b5c9baf3]
#    to [f558f2a042364b5409d377c478b4b9e541fda455]
# 
# patch "packages/kexecboot/kexecboot_0.3.bb"
#  from [549463678e80781a4efa57e3c566d8668953cb08]
#    to [4457d2c86b13054d5904309706de64d592eb0f3e]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-akita"
#  from [064c36530b213dae882be1b6bb2cbab8615906f8]
#    to [00830ed0414849cf715b07e153eb67fac87aef14]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-bootcdx86"
#  from [83dbfc0474bb18348ca67718d27d2dcc262095a3]
#    to [0960055873f1123a6ae52f2a7abe375f01994cdb]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-c7x0"
#  from [9840eec605b360f4cdcf976973331ce274a89b6f]
#    to [d15a5f05587c98203f9ee732dd0be56761cf05ee]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-htcuniversal"
#  from [afcff96c3bba46e09d06200f4431c95fdb419893]
#    to [6c9ef9588353eeb60af452de25604dbe0f35763f]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-hx2000"
#  from [8d4023e3a924b2d01a60011c6aa81cca7bc83d06]
#    to [b491304337aae46a85a5c7c191e03a79d45c11b3]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-poodle"
#  from [823d2a1579f2e5312396ba4c0d40a7405bcebd4f]
#    to [2e731fc9d5746cb9b2b147d9da0bb2c6c7bbcf25]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-qemuarm"
#  from [19a7a240f8a4fd58732db1ccb11767dac8fc7221]
#    to [9adc75c32cc284f318660b9d75d14b29fe350e7d]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-qemux86"
#  from [8f2d48208eb79e7a2e00941efcaee2cad2d34737]
#    to [677db0668430d8b88a0da1a72b719bb9a3b6e0e7]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-spitz"
#  from [121ce2ca2da79de4072c338f63ad9e345f2674bb]
#    to [a02d87cbebf6c43d557d077d9c6f64313fe0fc1b]
# 
# patch "packages/kexecboot/linux-kexecboot-2.6.26/defconfig-zylonite"
#  from [71cf26b625ad773ac5468869fe7052854759f70f]
#    to [8c64e0a32731e6a643f99ed460377cc59dbd487f]
# 
# patch "packages/kexecboot/linux-kexecboot.inc"
#  from [01dd6603a2a2fb2e9c3c56c171153b59ac8ec096]
#    to [47955a0785e93132f8a4394a9ae8191654a2fc62]
# 
# patch "packages/kexecboot/linux-kexecboot_2.6.26.bb"
#  from [c81d28c54ee3911d010f1fe10568274d5cba04ca]
#    to [af32ba85c12b9255c62cb27b05b4ca1a50cb72d4]
#
============================================================
--- packages/kexecboot/files/kexecboot-rewrite.patch	c170a72f30755508c630b99d3fd340fc32776280
+++ packages/kexecboot/files/kexecboot-rewrite.patch	c170a72f30755508c630b99d3fd340fc32776280
@@ -0,0 +1,344 @@
+--- kexecboot-0.3.orig/kexecboot.h	2008-09-03 02:35:40.000000000 +0400
++++ kexecboot-0.3/kexecboot.h	2008-09-03 02:36:04.000000000 +0400
+@@ -24,6 +24,10 @@
+ #include <string.h>
+ #include <linux/input.h>
+ #include <termios.h>
++#include <unistd.h>
++#include <signal.h>
++#include <sys/wait.h>
++#include <ctype.h>
+ #include "fb.h"
+ #include "devicescan.h"
+ #include "res/logo-img.h"
+@@ -33,4 +37,14 @@
+ #include "res/memory-img.h"
+ #include "res/radeon-font.h"
+ 
++/* Macro for dealing with NULL strings */
++#define strlenn(s)	( (NULL != s) ? (strlen(s)) : 0 )
++
++/* Tags we want from /proc/cmdline */
++char *wanted_tags[] = {
++	"mtdparts",
++	NULL
++};
++
++
+ #endif
+--- kexecboot-0.3.orig/kexecboot.c	2008-09-03 02:35:40.000000000 +0400
++++ kexecboot-0.3/kexecboot.c	2008-09-03 03:33:05.000000000 +0400
+@@ -78,20 +78,293 @@
+ 	fb_render(fb);
+ }
+ 
++/*
++ * Function: get_extra_cmdline()
++ * It gets wanted tags from original cmdline.
++ * Takes 2 args:
++ * - extra_cmdline - buffer to store cmdline parameters;
++ * - extra_cmdline_size - size of buffer
++ *   (inc. terminating '\0').
++ * Return values:
++ * - length of extra_cmdline on success (w/o term. zero);
++ * - -1 on error;
++ * - (- length of extra_cmdline - 1)  on insufficient buffer space.
++ */
++
++int get_extra_cmdline(char *const extra_cmdline, const size_t extra_cmdline_size)
++{
++	char *p, *t, *tag = NULL;
++	char line[COMMAND_LINE_SIZE];
++	int i, len, sp_size;
++	int sum_len = 0;
++	int wanted_tag_found = 0;
++	int overflow = 0;
++
++	const char proc_cmdline_path[] = "/proc/cmdline";
++	
++	/* Open /proc/cmdline and read cmdline */
++	FILE *f = fopen(proc_cmdline_path, "r");
++	if (NULL == f) {
++		perror("Can't open /proc/cmdline");
++		return -1;
++	}
++
++	if ( NULL == fgets(line, sizeof(line), f) ) {
++		perror("Can't read /proc/cmdline");
++		fclose(f);
++		return -1;
++	}
++
++	fclose(f);
++	
++	/* clean up buffer before parsing */
++	t = extra_cmdline;
++	*t = '\0';
++	
++	p = line-1;		/* because of ++p below */
++
++	sp_size = 0;	/* size of (first) space */
++	
++	do {
++		++p;
++		
++		if ( (NULL == tag) && (isalnum(*p)) ) {
++			/* new tag found */
++			tag = p;
++		} else if (tag) {
++			/* we are working on some tag */
++
++			if (isspace(*p) || ('\0' == *p) || ('=' == *p) ) {
++				/* end of tag or '=' found */
++				
++				if (!wanted_tag_found) {
++					/* search in wanted_tags */
++					for (i = 0; wanted_tags[i] != NULL; i++) {
++						if ( 0 == strncmp(wanted_tags[i], tag, p-tag) ) {
++							/* match found */
++							wanted_tag_found = 1;
++							break;
++						}
++					}
++				}
++				
++				if ( ('=' != *p) && wanted_tag_found ) {
++					/* end of wanted tag found -> copy */
++					
++					len = p - tag;
++					if ( (sum_len + len + sp_size) < extra_cmdline_size ) {
++						if (sp_size) {
++							/* prepend space when have tags already */
++							*t = ' ';
++							++t;
++							*t = '\0';
++							++sum_len;
++						} else {
++							sp_size = sizeof(char);
++						}
++			
++						/* NOTE: tag is not null-terminated so copy only
++						 * len chars and terminate it directly
++						 */
++						strncpy(t, tag, len);
++						/* move pointer to position after copied tag */
++						t += len ;
++						/* null-terminate */
++						*t = '\0';
++						/* update summary length */
++						sum_len += len;
++					} else {
++						/* we have no space - skip this tag */
++						overflow = 1;
++					}
++
++					/* reset wanted_tag_found */
++					wanted_tag_found = 0;
++				}
++				
++				/* reset tag */
++				if (!wanted_tag_found) tag = NULL;
++
++			}
++		}
++
++	} while ('\0' != *p);
++
++	if (overflow) return -sum_len-1;
++	return sum_len;
++}
++
++/*
++ * Function: kexec_execw()
++ * (execve and wait)
++ * kexecboot's replace of system() call without /bin/sh invocation.
++ * During execution  of the command, SIGCHLD will be blocked,
++ * and SIGINT and SIGQUIT will be ignored (like system() does).
++ * Takes 2 args (execve()-like):
++ * - path - full path to executable file
++ * - argv[] - array of args for executed file (command options e.g.)
++ * - envp[] - array of environment strings ("key=value")
++ * Return value:
++ * - command exit status on success
++ * - -1 on error (e.g. fork() failed)
++ */
++int kexec_execw(const char *path, char *const argv[], char *const envp[])
++{
++	pid_t pid;
++	struct sigaction ignore, old_int, old_quit;
++	sigset_t masked, oldmask;
++	int status;
++
++	/* Block SIGCHLD and ignore SIGINT and SIGQUIT */
++	/* Do this before the fork() to avoid races */
++
++	ignore.sa_handler = SIG_IGN;
++	sigemptyset(&ignore.sa_mask);
++	ignore.sa_flags = 0;
++	sigaction(SIGINT, &ignore, &old_int);
++	sigaction(SIGQUIT, &ignore, &old_quit);
++
++	sigemptyset(&masked);
++	sigaddset(&masked, SIGCHLD);
++	sigprocmask(SIG_BLOCK, &masked, &oldmask);
++
++	pid = fork();
++
++	if (pid < 0)
++		/* can't fork */
++		return -1;
++	else if (pid == 0) {
++		/* it is child */
++		sigaction(SIGINT, &old_int, NULL);
++		sigaction(SIGQUIT, &old_quit, NULL);
++		sigprocmask(SIG_SETMASK, &oldmask, NULL);
++
++		/* replace child with executed file */
++		execve(path, (char *const *)argv, (char *const *)envp);
++		/* should not happens but... */
++		_exit(127);
++	}
++
++	/* it is parent */
++
++	/* wait for our child and store status */
++	waitpid(pid, &status, 0);
++
++	/* restore signal handlers */
++	sigaction(SIGINT, &old_int, NULL);
++	sigaction(SIGQUIT, &old_quit, NULL);
++	sigprocmask(SIG_SETMASK, &oldmask, NULL);
++
++	return status;
++}
++
+ void start_kernel(struct boot *boot)
+ {
+-	//kexec --command-line="CMDLINE" -l /mnt/boot/zImage
+-	char command[COMMAND_LINE_SIZE + 60];
+-	mount(boot->device, "/mnt", boot->fstype, MS_RDONLY, NULL);
+-	if( boot->cmdline )
+-		sprintf(command,"/usr/sbin/kexec --command-line=\"%s root=%s rootfstype=%s\" -l %s", 
+-			boot->cmdline, boot->device, boot->fstype, boot->kernelpath);
+-	else
+-		sprintf(command,"kexec -l %s", boot->kernelpath);
+-	system(command);
+-//	puts(command);		
+-	umount("/mnt");
+-	system("/usr/sbin/kexec -e");
++	/* we use var[] instead of *var because sizeof(var) using */
++	const char mount_point[] = "/mnt";
++	const char kexec_path[] = "/usr/sbin/kexec";
++
++	const char str_cmdline_start[] = "--command-line=";
++	const char str_root[] = " root=";
++	const char str_rootfstype[] = " rootfstype=";
++	const char str_rootwait[] = " rootwait";
++
++	/* empty environment */
++	char *const envp[] = { NULL };
++
++	const char *kexec_load_argv[] = { NULL, "-l", NULL, NULL, NULL };
++	const char *kexec_exec_argv[] = { NULL, "-e", NULL};
++
++	char extra_cmdline_buffer[COMMAND_LINE_SIZE];
++	char *extra_cmdline, *cmdline_arg = NULL;
++	int n, idx;
++	
++	kexec_exec_argv[0] = kexec_path;
++	kexec_load_argv[0] = kexec_path;
++
++	/* --command-line arg generation */
++	idx = 2;	/* kexec_load_argv current option index */
++
++	/* get some parts of cmdline from boot loader (e.g. mtdparts) */
++	n = get_extra_cmdline( extra_cmdline_buffer,
++			sizeof(extra_cmdline_buffer) );
++	if ( -1 == n ) {
++		/* clean up extra_cmdline on error */
++		extra_cmdline = NULL;
++/*	} else if ( n < -1 ) { */
++		/* Do something when we have no space to get all wanted tags */
++		/* Now do nothing ;) */
++	} else {
++		extra_cmdline = extra_cmdline_buffer;
++	}
++
++	/* fill '--command-line' option */
++	if (boot->cmdline || extra_cmdline || boot->device) {
++		/* allocate space */
++		n = strlenn(str_cmdline_start) + strlenn(boot->cmdline) +
++				sizeof(char) + strlenn(extra_cmdline) +
++				strlenn(str_root) + strlenn(boot->device) +
++				strlenn(str_rootfstype) + strlenn(boot->fstype) +
++				strlenn(str_rootwait) + sizeof(char);
++		
++		cmdline_arg = (char *)malloc(n);
++		if (NULL == cmdline_arg) {
++			perror("Can't allocate memory for cmdline_arg");
++			/*  Should we exit?
++			exit(-1);
++			*/
++		} else {
++			strcat(cmdline_arg, str_cmdline_start);
++			if (extra_cmdline)
++				strcat(cmdline_arg, extra_cmdline);
++			if (boot->cmdline && extra_cmdline)
++				strcat(cmdline_arg, " ");
++			if (boot->cmdline)
++				strcat(cmdline_arg, boot->cmdline);
++			if (boot->device) {
++				strcat(cmdline_arg, str_root);
++				strcat(cmdline_arg, boot->device);
++				if (boot->fstype) {
++					strcat(cmdline_arg, str_rootfstype);
++					strcat(cmdline_arg, boot->fstype);
++				}
++			}
++			strcat(cmdline_arg, str_rootwait);
++
++			kexec_load_argv[idx] = cmdline_arg;
++			++idx;
++		}
++	}
++
++	/* Append kernelpath as last arg of kexec */
++	kexec_load_argv[idx] = boot->kernelpath;
++
++	/* Debug
++	fprintf(stderr, "%s\n%s\n%s\n%s\n", kexec_load_argv[0],
++			kexec_load_argv[1], kexec_load_argv[2],
++			kexec_load_argv[3]); */
++
++	/* Mount boot device */
++	if ( -1 == mount(boot->device, mount_point, boot->fstype,
++			MS_RDONLY, NULL) ) {
++		perror("Can't mount boot device");
++		exit(-1);
++	}
++
++	/* Load kernel */
++	n = kexec_execw(kexec_path, (char *const *)kexec_load_argv, envp);
++	if (-1 == n) {
++		perror("Kexec can't load kernel");
++		exit(-1);
++	}
++
++	if (cmdline_arg)
++		free(cmdline_arg);
++
++	umount(mount_point);
++
++	/* Boot new kernel */
++	execve(kexec_path, (char *const *)kexec_exec_argv, envp);
+ }
+ 
+ int main(int argc, char **argv)
+@@ -219,5 +492,6 @@
+ 	tcsetattr(fileno(stdin), TCSANOW, &old);
+ 	fb_destroy(fb);
+ 	start_kernel(bl->list[choice]);
+-	return 0;
++	/* When we reach this point then some error was occured */
++	return -1;
+ }
============================================================
--- packages/kexecboot/initramfs-kexecboot_1.0.bb	d3cfea5e56d92934495f6342d176e974b5c9baf3
+++ packages/kexecboot/initramfs-kexecboot_1.0.bb	f558f2a042364b5409d377c478b4b9e541fda455
@@ -1,8 +1,9 @@ DESCRIPTON = "A init script that mounts 
 DESCRIPTON = "A init script that mounts a device and kexecs a new kernel from it."
-PR = "r7"
+PR = "r8"
 RDEPENDS = "kexecboot klibc-utils-static-mount klibc-utils-static-sh klibc-utils-static-sleep"
 
 FBANGLE = "270"
+FBANGLE_c7x0 = "0"
 INPUTDEV = "/dev/event0"
 
 
============================================================
--- packages/kexecboot/kexecboot_0.3.bb	549463678e80781a4efa57e3c566d8668953cb08
+++ packages/kexecboot/kexecboot_0.3.bb	4457d2c86b13054d5904309706de64d592eb0f3e
@@ -1,21 +1,21 @@ LICENSE = "GPL"
 LICENSE = "GPL"
-PR = "r1"
+PR = "r2"
 DEPENDS = "klibc"
 RDEPENDS = "kexec-static"
+
 inherit autotools
 
 # You can create your own *-img.h by doing
 # ./make-image-header.sh <file>.png HAND
 
 SRC_URI = "http://projects.linuxtogo.org/frs/download.php/221/kexecboot-${PV}.tar.gz \
-	   file://rootdelay.patch;patch=1"
-S = "${WORKDIR}/kexecboot-${PV}"
+	   file://kexecboot-rewrite.patch;patch=1"
 
+S = "${WORKDIR}/kexecboot-${PV}"
 
 export CC=${TARGET_PREFIX}klcc
 
 # standart oe cflags don't work with klcc
+export CFLAGS = ""
+export CPPFLAGS = ""
+export LDFLAGS = ""
-export CFLAGS=""
-export CPPFLAGS=""
-export LDFLAGS=""
-
============================================================
--- packages/kexecboot/linux-kexecboot-2.6.26/defconfig-akita	064c36530b213dae882be1b6bb2cbab8615906f8
+++ packages/kexecboot/linux-kexecboot-2.6.26/defconfig-akita	00830ed0414849cf715b07e153eb67fac87aef14
@@ -53,7 +53,8 @@ CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_FAIR_CGROUP_SCHED is not set
 CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
-# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE="initramfs.cpio.gz"
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
============================================================
--- packages/kexecboot/linux-kexecboot-2.6.26/defconfig-bootcdx86	83dbfc0474bb18348ca67718d27d2dcc262095a3
+++ packages/kexecboot/linux-kexecboot-2.6.26/defconfig-bootcdx86	0960055873f1123a6ae52f2a7abe375f01994cdb
@@ -72,7 +72,7 @@ CONFIG_BLK_DEV_INITRD=y
 CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE=""
+CONFIG_INITRAMFS_SOURCE="initramfs.cpio.gz"
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
============================================================
--- packages/kexecboot/linux-kexecboot-2.6.26/defconfig-c7x0	9840eec605b360f4cdcf976973331ce274a89b6f
+++ packages/kexecboot/linux-kexecboot-2.6.26/defconfig-c7x0	d15a5f05587c98203f9ee732dd0be56761cf05ee
@@ -53,7 +53,8 @@ CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_FAIR_CGROUP_SCHED is not set
 CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
-# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE="initramfs.cpio.gz"
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
============================================================
--- packages/kexecboot/linux-kexecboot-2.6.26/defconfig-htcuniversal	afcff96c3bba46e09d06200f4431c95fdb419893
+++ packages/kexecboot/linux-kexecboot-2.6.26/defconfig-htcuniversal	6c9ef9588353eeb60af452de25604dbe0f35763f
@@ -53,7 +53,8 @@ CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_FAIR_CGROUP_SCHED is not set
 CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
-# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE="initramfs.cpio.gz"
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
 CONFIG_EMBEDDED=y
============================================================
--- packages/kexecboot/linux-kexecboot-2.6.26/defconfig-hx2000	8d4023e3a924b2d01a60011c6aa81cca7bc83d06
+++ packages/kexecboot/linux-kexecboot-2.6.26/defconfig-hx2000	b491304337aae46a85a5c7c191e03a79d45c11b3
@@ -54,7 +54,7 @@ CONFIG_BLK_DEV_INITRD=y
 C%s
>>> DIFF TRUNCATED @ 16K






More information about the Openembedded-commits mailing list