diff options
Diffstat (limited to 'init')
-rw-r--r-- | init/devices.c | 34 | ||||
-rwxr-xr-x | init/init.c | 2 | ||||
-rw-r--r-- | init/init_parser.c | 3 | ||||
-rw-r--r-- | init/parser.c | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | init/util.c | 5 |
5 files changed, 19 insertions, 36 deletions
diff --git a/init/devices.c b/init/devices.c index e73efdf..eb5d84e 100644 --- a/init/devices.c +++ b/init/devices.c @@ -33,6 +33,8 @@ #include <asm/page.h> #include <sys/wait.h> +#include <cutils/uevent.h> + #include "devices.h" #include "util.h" #include "log.h" @@ -589,35 +591,9 @@ static void handle_firmware_event(struct uevent *uevent) #define UEVENT_MSG_LEN 1024 void handle_device_fd() { - for(;;) { - char msg[UEVENT_MSG_LEN+2]; - char cred_msg[CMSG_SPACE(sizeof(struct ucred))]; - struct iovec iov = {msg, sizeof(msg)}; - struct sockaddr_nl snl; - struct msghdr hdr = {&snl, sizeof(snl), &iov, 1, cred_msg, sizeof(cred_msg), 0}; - - ssize_t n = recvmsg(device_fd, &hdr, 0); - if (n <= 0) { - break; - } - - if ((snl.nl_groups != 1) || (snl.nl_pid != 0)) { - /* ignoring non-kernel netlink multicast message */ - continue; - } - - struct cmsghdr * cmsg = CMSG_FIRSTHDR(&hdr); - if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) { - /* no sender credentials received, ignore message */ - continue; - } - - struct ucred * cred = (struct ucred *)CMSG_DATA(cmsg); - if (cred->uid != 0) { - /* message from non-root user, ignore */ - continue; - } - + char msg[UEVENT_MSG_LEN+2]; + int n; + while ((n = uevent_checked_recv(device_fd, msg, UEVENT_MSG_LEN)) > 0) { if(n >= UEVENT_MSG_LEN) /* overflow -- discard */ continue; diff --git a/init/init.c b/init/init.c index 75ffb5c..f2a1d27 100755 --- a/init/init.c +++ b/init/init.c @@ -646,6 +646,8 @@ static int bootchart_init_action(int nargs, char **args) } else { NOTICE("bootcharting ignored\n"); } + + return 0; } #endif diff --git a/init/init_parser.c b/init/init_parser.c index d136c28..fafd732 100644 --- a/init/init_parser.c +++ b/init/init_parser.c @@ -187,7 +187,7 @@ static void parse_config(const char *fn, char *s) nargs = 0; state.filename = fn; - state.line = 1; + state.line = 0; state.ptr = s; state.nexttoken = 0; state.parse_line = parse_line_no_op; @@ -197,6 +197,7 @@ static void parse_config(const char *fn, char *s) state.parse_line(&state, 0, 0); return; case T_NEWLINE: + state.line++; if (nargs) { int kw = lookup_keyword(args[0]); if (kw_is(kw, SECTION)) { diff --git a/init/parser.c b/init/parser.c index 2f36ac7..3c2ec00 100644 --- a/init/parser.c +++ b/init/parser.c @@ -83,7 +83,6 @@ int next_token(struct parse_state *state) state->ptr = x; return T_EOF; case '\n': - state->line++; x++; state->ptr = x; return T_NEWLINE; @@ -94,9 +93,13 @@ int next_token(struct parse_state *state) continue; case '#': while (*x && (*x != '\n')) x++; - state->line++; - state->ptr = x; - return T_NEWLINE; + if (*x == '\n') { + state->ptr = x+1; + return T_NEWLINE; + } else { + state->ptr = x; + return T_EOF; + } default: goto text; } diff --git a/init/util.c b/init/util.c index 377754b..d8ec88e 100644..100755 --- a/init/util.c +++ b/init/util.c @@ -439,8 +439,9 @@ void get_hardware_name(char *hardware, unsigned int *revision) if (x) { x += 2; n = 0; - while (*x && !isspace(*x)) { - hardware[n++] = tolower(*x); + while (*x && *x != '\n') { + if (!isspace(*x)) + hardware[n++] = tolower(*x); x++; if (n == 31) break; } |