logind: make use of vtnr_from_tty() in seat_read_active_vt() (#9923)
No functional changes.
This commit is contained in:
parent
593a5213ce
commit
49679ff70f
|
@ -355,8 +355,7 @@ int seat_active_vt_changed(Seat *s, unsigned int vtnr) {
|
|||
int seat_read_active_vt(Seat *s) {
|
||||
char t[64];
|
||||
ssize_t k;
|
||||
unsigned int vtnr;
|
||||
int r;
|
||||
int vtnr;
|
||||
|
||||
assert(s);
|
||||
|
||||
|
@ -375,17 +374,9 @@ int seat_read_active_vt(Seat *s) {
|
|||
t[k] = 0;
|
||||
truncate_nl(t);
|
||||
|
||||
if (!startswith(t, "tty")) {
|
||||
log_error("Hm, /sys/class/tty/tty0/active is badly formatted.");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
r = safe_atou(t+3, &vtnr);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse VT number \"%s\": %m", t+3);
|
||||
|
||||
if (!vtnr) {
|
||||
log_error("VT number invalid: %s", t+3);
|
||||
vtnr = vtnr_from_tty(t);
|
||||
if (vtnr < 0) {
|
||||
log_error_errno(vtnr, "Hm, /sys/class/tty/tty0/active is badly formatted: %m");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue