summaryrefslogtreecommitdiffstats
path: root/inittab.c
diff options
context:
space:
mode:
authorMichel Stam <m.stam@fugro.nl>2014-10-13 16:14:34 +0200
committerJohn Crispin <blogic@openwrt.org>2014-10-12 13:24:11 +0200
commit79872ea6ca5867631c1ec5405721af12bea818b2 (patch)
tree86fd9034e2940b00405cda98aca084fac6e3a4d5 /inittab.c
parentf45672d80bf2fec4ccb7363de1da6adb9e3f4421 (diff)
downloadunitd-79872ea6ca5867631c1ec5405721af12bea818b2.tar
unitd-79872ea6ca5867631c1ec5405721af12bea818b2.zip
Use one generic routine to access /proc/cmdline
Signed-off-by: Michel Stam <m.stam@fugro.nl>
Diffstat (limited to 'inittab.c')
-rw-r--r--inittab.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/inittab.c b/inittab.c
index c8540b1..2d9a1e0 100644
--- a/inittab.c
+++ b/inittab.c
@@ -25,6 +25,7 @@
#include <libubox/utils.h>
#include <libubox/list.h>
+#include "utils/utils.h"
#include "procd.h"
#include "rcS.h"
@@ -135,30 +136,20 @@ static void askfirst(struct init_action *a)
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);
@@ -171,9 +162,6 @@ static void askconsole(struct init_action *a)
a->proc.cb = child_exit;
fork_worker(a);
-
-err_out:
- regfree(&pat_cmdline);
}
static void rcrespawn(struct init_action *a)