mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Change tty default baud rate: 38400 -> 0, i.e. keep kernel default
This is a more sane default, and also what systems expect, and what other getty implementations support. I.e., unless specified, or set to 0, the tty baud rate is zero -- which means do not change speed at all. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
af45166814
commit
b7c1a2a198
3 files changed
+15
-11
No files matched your search
+6
-4
@@ -301,8 +301,9 @@ Syntax
|
|||||||
`tty [LVLS] <CMD> <ARGS> [noclear] [nowait]`
|
`tty [LVLS] <CMD> <ARGS> [noclear] [nowait]`
|
||||||
The first variant of this option uses the built-in getty on the given
|
The first variant of this option uses the built-in getty on the given
|
||||||
TTY device DEV, in the given runlevels. The DEV may be the special
|
TTY device DEV, in the given runlevels. The DEV may be the special
|
||||||
keyword `@console`, which is very useful on embedded systems. Default
|
keyword `@console`, or `console`, useful on embedded systems.
|
||||||
baud rate is `38400`.
|
|
||||||
|
The default baud rate is 0, i.e., keep kernel default.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```conf
|
```conf
|
||||||
@@ -340,11 +341,12 @@ Syntax
|
|||||||
Embedded systems may want to enable automatic `DEV` by supplying the
|
Embedded systems may want to enable automatic `DEV` by supplying the
|
||||||
special `@console` device. This works regardless weather the system
|
special `@console` device. This works regardless weather the system
|
||||||
uses `ttyS0`, `ttyAMA0`, `ttyMXC0`, or anything else. Finit figures
|
uses `ttyS0`, `ttyAMA0`, `ttyMXC0`, or anything else. Finit figures
|
||||||
it out by querying sysfs: `/sys/class/tty/console/active`.
|
it out by querying sysfs: `/sys/class/tty/console/active`. The speed
|
||||||
|
can be omitted to keep the kernel default.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
```conf
|
```conf
|
||||||
tty [12345] @console 115200 noclear vt220
|
tty [12345] @console noclear vt220
|
||||||
```
|
```
|
||||||
|
|
||||||
On really bare bones systems Finit offers a fallback shell, which
|
On really bare bones systems Finit offers a fallback shell, which
|
||||||
|
|||||||
+5
-7
@@ -369,15 +369,12 @@ pid_t run_getty(char *tty, char *baud, char *term, int noclear, int nowait, stru
|
|||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
speed_t speed = B38400;
|
speed_t speed;
|
||||||
|
|
||||||
if (baud && baud[0]) {
|
|
||||||
speed = stty_parse_speed(baud);
|
|
||||||
if (B0 == speed)
|
|
||||||
logit(LOG_CRIT, "TTY %s: Invalid speed %s", tty, baud);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
speed = stty_parse_speed(baud);
|
||||||
|
logit(LOG_INFO, "Starting built-in getty on %s, speed %u", tty, speed);
|
||||||
prepare_tty(tty, speed, "tty", rlimit);
|
prepare_tty(tty, speed, "tty", rlimit);
|
||||||
|
|
||||||
if (activate_console(noclear, nowait))
|
if (activate_console(noclear, nowait))
|
||||||
_exit(getty(tty, speed, term, NULL));
|
_exit(getty(tty, speed, term, NULL));
|
||||||
}
|
}
|
||||||
@@ -415,6 +412,7 @@ pid_t run_getty2(char *tty, char *cmd, char *args[], int noclear, int nowait, st
|
|||||||
dup2(fd, STDERR_FILENO);
|
dup2(fd, STDERR_FILENO);
|
||||||
|
|
||||||
/* Dunno speed, tell stty() to not mess with it */
|
/* Dunno speed, tell stty() to not mess with it */
|
||||||
|
logit(LOG_INFO, "Starting external getty on %s, speed %u", tty, B0);
|
||||||
prepare_tty(tty, B0, "getty", rlimit);
|
prepare_tty(tty, B0, "getty", rlimit);
|
||||||
|
|
||||||
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
|
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <sys/ttydefaults.h> /* Not included by default in musl libc */
|
#include <sys/ttydefaults.h> /* Not included by default in musl libc */
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
|
||||||
|
/* B0 means; keep kernel default */
|
||||||
speed_t stty_parse_speed(char *baud)
|
speed_t stty_parse_speed(char *baud)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
@@ -66,6 +67,9 @@ speed_t stty_parse_speed(char *baud)
|
|||||||
{ 4000000, B4000000 },
|
{ 4000000, B4000000 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!baud || !baud[0])
|
||||||
|
return B0;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
val = strtoul(baud, &ptr, 10);
|
val = strtoul(baud, &ptr, 10);
|
||||||
if (errno || ptr == baud)
|
if (errno || ptr == baud)
|
||||||
|
|||||||
Reference in new issue
Block a user