commit 895ecc80544b7877427d495e87864af12d879ae7
parent 5933cb06bf773a91f41dc82ad0f0720f33cba651
Author: xplshn <anto@xplshn.com.ar>
Date: Tue, 24 Nov 2026 14:38:04 -0300
getty: console and TERM from the tty backend
Diffstat:
4 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/cmd/pseudo/getty.c b/cmd/pseudo/getty.c
@@ -23,8 +23,7 @@
#include "util.h"
#include "wexec.h"
-static char *tty = "/dev/tty1";
-static char *defaultterm = "linux";
+static const char *tty;
static void
usage(void)
@@ -56,7 +55,8 @@ main(int argc, char *argv[])
}
ARGEND;
- strlcpy(term, defaultterm, sizeof(term));
+ tty = ttyconsole();
+ strlcpy(term, ttyconsterm(), sizeof(term));
if (argc > 0) {
tty = argv[0];
if (argc > 1)
diff --git a/shared/libutil/tty_linux.c b/shared/libutil/tty_linux.c
@@ -99,4 +99,17 @@ err0:
return r;
}
+
+/* the first virtual console, and the TERM it speaks */
+const char *
+ttyconsole(void)
+{
+ return ARUU_PATH_DEV "/tty1";
+}
+
+const char *
+ttyconsterm(void)
+{
+ return "linux";
+}
#endif
diff --git a/shared/libutil/tty_other.c b/shared/libutil/tty_other.c
@@ -1,5 +1,6 @@
/* see LICENSE file for copyright and license details */
#include "../filesystem.h"
+#include "../paths.h"
#include "../util.h"
#include <stddef.h>
@@ -25,4 +26,16 @@ ttytostr(int tty_maj, int tty_min, char *str, size_t n)
str[1] = '\0';
return 0;
}
+
+const char *
+ttyconsole(void)
+{
+ return ARUU_PATH_DEVCONSOLE;
+}
+
+const char *
+ttyconsterm(void)
+{
+ return "vt100";
+}
#endif
diff --git a/shared/util.h b/shared/util.h
@@ -112,8 +112,10 @@ unsigned long estrtoul(const char *, int);
#undef explicit_bzero
void explicit_bzero(void *, size_t);
void recurse_dir(const char *, void (*)(const char *));
-void devtotty(int, int *, int *);
-int ttytostr(int, int, char *, size_t);
+void devtotty(int, int *, int *);
+int ttytostr(int, int, char *, size_t);
+const char *ttyconsole(void);
+const char *ttyconsterm(void);
/* getopt starts over on a new argument list, the way each system's libc
* is told to: a getopt_<os>.c per system */