systemd/1013-serial-console-names-and-index.patch

50 lines
1.4 KiB
Diff

--- systemd-208/src/getty-generator/getty-generator.c
+++ systemd-208/src/getty-generator/getty-generator.c 2013-12-05 14:55:31.178235334 +0000
@@ -128,7 +128,7 @@ int main(int argc, char *argv[]) {
/* Automatically add in a serial getty on all active
* kernel consoles */
FOREACH_WORD(w, l, active, state) {
- char *tty;
+ char *tty, *p;
int k;
tty = strndup(w, l);
@@ -144,6 +144,37 @@ int main(int argc, char *argv[]) {
continue;
}
+ if (asprintf(&p, "/sys/class/tty/%s", tty) < 0) {
+ log_oom();
+ r = EXIT_FAILURE;
+ goto finish;
+ }
+
+ k = access(p, F_OK);
+ free(p);
+
+ if (k < 0) {
+ char *t;
+ int n;
+ if ((p = strchr(tty, '-')) == NULL)
+ continue;
+ t = p+1;
+ if (*t < '1' || *t > '9')
+ continue;
+ k = safe_atoi(t, &n);
+ if (k < 0)
+ continue;
+ n--;
+ *p = '\0';
+ if (asprintf(&t, "%s%d", tty, n) < 0) {
+ log_oom();
+ r = EXIT_FAILURE;
+ goto finish;
+ }
+ free(tty);
+ tty = t;
+ }
+
/* We assume that gettys on virtual terminals are
* started via manual configuration and do this magic
* only for non-VC terminals. */