[BusyBox] Passing arguments to init when loading the kernel?
Erik Gustavsson
cyrano at algonet.se
Tue Feb 20 17:11:35 UTC 2001
On Tue, 20 Feb 2001, Erik Andersen wrote:
> >
> > - char *environment[] = {
> > + char *environment[MAXENV+1] = {
> > "HOME=/",
> > "PATH=/usr/bin:/bin:/usr/sbin:/sbin",
> > "SHELL=/bin/sh",
> > - termType,
> > - "USER=root",
> > - 0
> > + "USER=root"
> > };
>
> What about termType? Presumably with your patch we are now setting the
> terminal type to whatever the kernel passes to init (defaults to "TERM=linux").
> The variable termType is no longer used for anything in your patch and could be
> deleted. My concern is, are you sure this will work? For example, busybox
> init was setting "TERM=vt102" for serial consoles. I see nothing in the kernel
> that will change this when using a serial console, so either busybox has a bug
> now (i.e. I shouldn't be messing with TERM for serial consoles) which your
> patch fixes, or you just added a bug. It has been over a year since I wrote
> that part of the code, so I'm not sure which it is. Could you reassure me a bit
> on this point? Other then this, I am prepared to commmit your patch.
>
Hmmm. No I must admit I hadn't thought of that. I simply noticed that TERM
was already set by the kernel and removed it.
Ok, last try... Ignores TERM from the environment, also done a little more
according to "./docs/style-guide.txt".
/cyr
-------------- next part --------------
--- ../bborig/init.c Tue Feb 20 07:14:07 2001
+++ init.c Tue Feb 20 18:06:09 2001
@@ -134,6 +134,7 @@
#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */
#endif
+static const int MAXENV = 16; /* Number of env. vars */
static const int LOG = 0x1;
static const int CONSOLE = 0x2;
@@ -394,7 +395,8 @@
static pid_t run(char *command, char *terminal, int get_enter)
{
- int i, fd;
+ int i=0, j=0;
+ int fd;
pid_t pid;
char *tmpCmd;
char *cmd[255], *cmdpath;
@@ -406,14 +408,20 @@
#endif
"\nPlease press Enter to activate this console. ";
- char *environment[] = {
+ char *environment[MAXENV+1] = {
"HOME=/",
"PATH=/usr/bin:/bin:/usr/sbin:/sbin",
"SHELL=/bin/sh",
termType,
- "USER=root",
- 0
+ "USER=root"
};
+
+ while (environment[i]) i++;
+ while ((environ[j]) && (i < MAXENV)) {
+ if (strncmp(environ[j], "TERM=", 5))
+ environment[i++] = environ[j];
+ j++;
+ }
if ((pid = fork()) == 0) {
/* Clean up */
More information about the busybox
mailing list