[klibc] [PATCH] kinit/kinit.c
Thayne Harbaugh
tharbaugh at lnxi.com
Wed Jan 5 14:58:26 PST 2005
A patch for a few more hiccups and trivialities in kinit.c:
* The check_path() calls check for "/root" and "/old_root" - I believe
that should be "/root" and "/root/old_root".
* chdir("/") is recommended after pivot_root()
* init_argv[0] isn't set properly to the basename pointed to by char *s
- this fix also eliminates six lines of unecessary code and improves
readability by using get_arg().
--- klibc-0.194/kinit/kinit.c.orig 2005-01-05 15:40:15.468305608 -0700
+++ klibc-0.194/kinit/kinit.c 2005-01-05 15:41:44.400785816 -0700
@@ -246,8 +251,9 @@
do_ipconfig(cmdc, cmdv);
check_path("/root");
- check_path("/old_root");
do_mounts(cmdc, cmdv);
+ /* do_mounts cd's to /root so below tests /root/old_root */
+ check_path("old_root");
#ifndef INI_DEBUG
if (pivot_root(".", "old_root") == -1) {
@@ -255,6 +261,8 @@
ret = 2;
goto bail;
}
+ /* the below chdir() is good style after a pivot_root() */
+ chdir("/");
if (mnt_procfs == 1)
umount2("/proc", 0);
@@ -262,18 +270,12 @@
if (mnt_sysfs == 1)
umount2("/sys", 0);
- for (i = 1; i < cmdc; i++) {
- if (strncmp(cmdv[i], "kinit=", 6) == 0) {
- kinit = cmdv[i] + 6;
- }
- }
-
- if (kinit) {
+ if ((kinit = get_arg(cmdc, cmdv, "kinit="))) {
char *s = strrchr(kinit, '/');
if (s) {
s++;
}
- init_argv[0] = kinit;
+ init_argv[0] = s;
execv(kinit, init_argv);
}
init_argv[0] = "init";
--
Thayne Harbaugh
Linux Networx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.zytor.com/pipermail/klibc/attachments/20050105/bb97b7ab/attachment.bin
More information about the klibc
mailing list