mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.com>
To: Johannes Hostert <jojohostert@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Eric Biggers <ebiggers@google.com>,
	Eric Dumazet <edumazet@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vt: vt_ioctl: Add new ioctl to read vt switch lock state
Date: Sun, 26 Apr 2020 09:08:33 +0200	[thread overview]
Message-ID: <ea60aefe-f294-7e58-b53c-5f1e72b7af9e@suse.com> (raw)
In-Reply-To: <20200425231436.535671-1-jojohostert@gmail.com>

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

      reply	other threads:[~2020-04-26  7:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-25 23:14 Johannes Hostert
2020-04-26  7:08 ` Jiri Slaby [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea60aefe-f294-7e58-b53c-5f1e72b7af9e@suse.com \
    --to=jslaby@suse.com \
    --cc=ebiggers@google.com \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jojohostert@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®