1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00

logind: explicitly check for /dev/tty0

This commit is contained in:
Lennart Poettering 2012-04-13 17:54:33 +02:00
parent 41807efb15
commit 74afee9c18

View File

@ -945,14 +945,16 @@ static int manager_connect_console(Manager *m) {
assert(m); assert(m);
assert(m->console_active_fd < 0); assert(m->console_active_fd < 0);
/* On certain architectures (S390 and Xen, and containers),
/dev/tty0 does not exist, so don't fail if we can't open
it. */
if (access("/dev/tty0", F_OK) < 0) {
m->console_active_fd = -1;
return 0;
}
m->console_active_fd = open("/sys/class/tty/tty0/active", O_RDONLY|O_NOCTTY|O_CLOEXEC); m->console_active_fd = open("/sys/class/tty/tty0/active", O_RDONLY|O_NOCTTY|O_CLOEXEC);
if (m->console_active_fd < 0) { if (m->console_active_fd < 0) {
/* On certain architectures (S390 and Xen), /dev/tty0
does not exist, so don't fail if we can't open it.*/
if (errno == ENOENT)
return 0;
log_error("Failed to open /sys/class/tty/tty0/active: %m"); log_error("Failed to open /sys/class/tty/tty0/active: %m");
return -errno; return -errno;
} }