- char line[256], *tty;
- int i, r, fd = open("/proc/cmdline", O_RDONLY);
- regex_t pat_cmdline;
- regmatch_t matches[2];
-
- if (!fd)
- 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];