diff options
author | H. Peter Anvin <hpa@zytor.com> | 2005-01-08 02:55:15 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2005-01-08 02:55:15 +0000 |
commit | 530903748615256cd88613358064c536396010c4 (patch) | |
tree | d73b1d2d7f8ad5d957f3149be3c976b27d2e43dc | |
parent | ba9ac5610d9427f382f1225df3e442927d5bb422 (diff) | |
download | klibc-530903748615256cd88613358064c536396010c4.tar.gz |
Thayne Harbaugh:klibc-0.195
>* 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().
The get_arg() simplification causes "int i" to be unused.
-rw-r--r-- | kinit/kinit.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/kinit/kinit.c b/kinit/kinit.c index 27cf621324c38..b3be538b1e28b 100644 --- a/kinit/kinit.c +++ b/kinit/kinit.c @@ -202,7 +202,6 @@ int main(int argc, char *argv[]) int ret = 0; int cmdc; int fd; - int i; /* Default parameters for anything init-like we execute */ init_argc = argc; @@ -246,8 +245,9 @@ int main(int argc, char *argv[]) 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 +255,8 @@ int main(int argc, char *argv[]) ret = 2; goto bail; } + /* the below chdir() is recommended after a pivot_root() */ + chdir("/"); if (mnt_procfs == 1) umount2("/proc", 0); @@ -262,18 +264,12 @@ int main(int argc, char *argv[]) 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"; |