return NULL;
}
-char* get_cmdline_val(const char* name, char* out, int len)
+char *get_cmdline_val_offset(const char *name, char *out, int len, int offset)
{
char line[CMDLINE_SIZE + 1], *c, *sptr;
- int fd = open("/proc/cmdline", O_RDONLY);
+ int i, fd = open("/proc/cmdline", O_RDONLY);
ssize_t r = read(fd, line, sizeof(line) - 1);
close(fd);
line[r] = 0;
- for (c = strtok_r(line, " \t\n", &sptr); c;
+ for (i = 0, c = strtok_r(line, " \t\n", &sptr); c;
c = strtok_r(NULL, " \t\n", &sptr)) {
char *sep = strchr(c, '=');
if (sep == NULL)
if (strncmp(name, c, klen) || name[klen] != 0)
continue;
+ if (i++ < offset)
+ continue;
strncpy(out, &sep[1], len);
out[len-1] = 0;
return out;
void blobmsg_list_free(struct blobmsg_list *list);
bool blobmsg_list_equal(struct blobmsg_list *l1, struct blobmsg_list *l2);
void blobmsg_list_move(struct blobmsg_list *list, struct blobmsg_list *src);
-char *get_cmdline_val(const char *name, char *out, int len);
+char *get_cmdline_val_offset(const char *name, char *out, int len, int offset);
char *get_active_console(char *out, int len);
+#define get_cmdline_val(name, out, len) \
+ get_cmdline_val_offset(name, out, len, 0)
+
int patch_fd(const char *device, int fd, int flags);
int patch_stdio(const char *device);