#include <stdlib.h>
#include <unistd.h>
#include <regex.h>
+#include <ctype.h>
#include <libubox/utils.h>
#include <libubox/list.h>
+#include "utils/utils.h"
#include "procd.h"
#include "rcS.h"
static void askconsole(struct init_action *a)
{
struct stat s;
- char line[256], *tty;
- int i, r, fd = open("/proc/cmdline", O_RDONLY);
- regex_t pat_cmdline;
- regmatch_t matches[2];
-
- if (fd < 0)
- return;
-
- r = read(fd, line, sizeof(line) - 1);
- line[r] = '\0';
- close(fd);
-
- regcomp(&pat_cmdline, "console=([a-zA-Z0-9]*)", REG_EXTENDED);
- if (regexec(&pat_cmdline, line, 2, matches, 0))
- goto err_out;
- line[matches[1].rm_eo] = '\0';
- tty = &line[matches[1].rm_so];
+ char line[256], *tty, *split;
+ int i;
+ tty = get_cmdline_val("console", line, sizeof(line));
+ split=strchr(tty, ',');
+ if (split != NULL)
+ split = '\0';
+
chdir("/dev");
i = stat(tty, &s);
chdir("/");
if (i) {
DEBUG(4, "skipping %s\n", tty);
- goto err_out;
+ return;
}
console = strdup(tty);
a->proc.cb = child_exit;
fork_worker(a);
-
-err_out:
- regfree(&pat_cmdline);
}
static void rcrespawn(struct init_action *a)
return;
}
- regcomp(&pat_inittab, "([a-zA-Z0-9]*):([a-zA-Z0-9]*):([a-zA-Z0-9]*):([a-zA-Z0-9/[.-.]. ]*)", REG_EXTENDED);
+ regcomp(&pat_inittab, "([a-zA-Z0-9]*):([a-zA-Z0-9]*):([a-zA-Z0-9]*):(.*)", REG_EXTENDED);
line = malloc(LINE_LEN);
a = malloc(sizeof(struct init_action));
memset(a, 0, sizeof(struct init_action));
char *tags[TAG_PROCESS + 1];
char *tok;
int i;
+ int len = strlen(line);
+
+ while (isspace(line[len - 1]))
+ len--;
+ line[len] = 0;
if (*line == '#')
continue;
};
tok = strtok(tags[TAG_PROCESS], " ");
- for (i = 0; i < (MAX_ARGS - i - 1) && tok; i++) {
+ for (i = 0; i < (MAX_ARGS - 1) && tok; i++) {
a->argv[i] = tok;
tok = strtok(NULL, " ");
}