[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ea60aefe-f294-7e58-b53c-5f1e72b7af9e@suse.com>
Date: Sun, 26 Apr 2020 09:08:33 +0200
From: Jiri Slaby <jslaby@...e.com>
To: Johannes Hostert <jojohostert@...il.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Eric Biggers <ebiggers@...gle.com>,
Eric Dumazet <edumazet@...gle.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] vt: vt_ioctl: Add new ioctl to read vt switch lock state
On 26. 04. 20, 1:14, Johannes Hostert wrote:
> The existing ioctls VT_LOCKSWITCH and VT_UNLOCKSWITCH can be used to
> allow/disallow switching the virtual terminal. However, no mechanism
> exists that allows software to read this lock state.
>
> Userspace programs that try to switch to another virtual terminal
> like chvt have no mechanism to figure out whether they will be able
> to actually switch the terminal. When eg. chvt is run while terminal
> switching is disabled, it simply sleeps forever waiting for the target
> terminal to become active.
>
> This commit introduces a new ioctl VT_GETLOCKSWITCH that allows
> reading the current state of the switch lock flag. Userspace
> software can then use that flag and handle not being able to switch
> virtual terminals.
>
> Example program using this:
>
> #include <linux/vt.h>
> #include <sys/ioctl.h>
> #include <fcntl.h>
> #include <stdio.h>
> #include <errno.h>
> #include <error.h>
> #include <unistd.h>
> const char* console_device = "/dev/tty0";
> int main(int argc, char* argv[]) {
> int fd;
> while ((fd = open(console_device, O_RDWR)) == -1 && errno == EINTR);
> if (fd < 0)
> error(1, errno, "Opening %s", console_device);
> int ret;
> while ((ret = ioctl(fd, VT_GETLOCKSWITCH, 1)) == -1 && errno == EINTR);
> if (ret == -1)
> error(1, errno, "%s: VT_GETLOCKSWITCH", console_device);
And now if you do VT_LOCKSWITCH even when VT_GETLOCKSWITCH returns 0,
vt_dont_switch can be 1 already.
So NACK.
Please don't add another racy ioctl. Introduce VT_LOCKSWITCH_NONBLOCK or
something like that instead (like respecting O_NONBLOCK).
thanks,
--
js
suse labs
Powered by blists - more mailing lists