This is a weird fix. One would think that this is automatically reset when
calling close() on the fd but, suprise, it's not. So lets reset this
manually, otherwise when we close the VT but our application is still
active, the user will never be able to leave the VT again.
Again a hilarious example why the VT API sucks. Really... Get rid of it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This actually incorporates the fakevt tool into kmscon. That is, if the
user presses ctrl+mod4+F12, we activate or deactivate the fake VT.
This is for debugging only and needs to be made more configurable. Use it
on your own risk.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
/dev/tty may be available even though CONFIG_VT is not set. Therefore,
check for /dev/tty0 instead which is guaranteed to be not available with
CONFIG_VT=n.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This adds a very limited non-multi-seat-capable fake-VT logic. If you use
this in production it will break your multi-seat systems so do not use it
except for debugging.
On SIGUSR1 we activate fake VTs and on SIGUSR2 we deactivate them. The
signals must be sent from a priviledged process. Kernel signals are
ignored.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
If using real linux VTs, we must ignore all signals that are not sent from
the kernel. Otherwise, we might get problems if we reuse SIGUSR for other
functionality.
Note that we already check that we are the active VT before handling
SIGUSR. However, this hardens this check to be more sure that this is
really the signal we want.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
To avoid useless checks wether a vt is valid we simply mark it as dead and
centralize the checks in the API entry point.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This register the SIGUSR1/2 signal handlers even though we are no real VT.
This is needed to implement other fake-VT helpers for systems were real
VTs are not available.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Instead of using the old kmscon_vt_* names we now prefix everything that
implements real linux VTs with real_*. An internal flag specifies which
mode the VT is in so we can check whether we are a real VT or a fake one.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This removes both functions and merges them into the callers. They're
small enough to be directly included.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We always open a new VT as there is no need for us to open an existing VT.
Hard-code this behavior but keep the open_tty() backend accepting
VT-numbers just in case we want this some time in the future.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This enum is not needed as the uterm-vt code already has enums for
vt-actions. Replace it with UTERM_VT_ACTIVATE/DEACTIVATE.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This merges both files so we can reduce the code overhead here. This is
still some very old code that was never correctly merged into new
uterm_vt.c subsystem. This should help doing it now.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Instead of having a global symbol, we simply move the check to uterm-vt
and can remove it from global namespace. Furthermore, we cache the result
so we can reuse it on the VT-master if required.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The vt allocation returns a referenced object so deallocation should
correctly drop it again. We already depend on this behavior so fix it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We need to return "true", not "false" if a mode is unknown. Otherwise, we
will block the VT subsystem.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We initialize the variable to "true" to silence gcc warnings that we might
get an uninitialized variable (which we really cannot get here).
Anyway, in the future, if the number of types may increase, the correct
way to deal with unknown types is returning "true" so do this by default
now.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Small stuff that is not worth putting into a separate library is no moved
into the "static" library which is statically linked into all our
subsystems.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When emulating the VT layer we need to pass our own data to the internal
callbacks. We currently pass the user data which is really useless here.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The uterm VT API is designed to support new user-space implementations of
vt-master APIs. If we are on seat0 and CONFIG_VT is enabled, we use the
kernel VT API. In all other cases we currently simply fall back to a
non-op but will implement in the future dbus based APIs or similar to
support VT switching, that is multi-session, on all seats.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>