[Toybox] [CLEANUP] openvt/deallocvt

Isaac Dunham ibid.ag at gmail.com
Tue Jun 24 14:55:49 PDT 2014


On Tue, Jun 24, 2014 at 06:48:02AM -0500, Rob Landley wrote:
> vivek: could you answer the KDGKBTYPE vs VT_GETSTATE question at the end?
<snip>
> query: the if (!FLAG_c) bit is doing a very similar "try fd 0-3, open
> /dev/console" thing to open_console(), the difference is that's calling
> ioctl(KDGKBTYPE) and this is calling ioctl(VT_GETSTATE). If the purpose
> of KDGKBTYPE is to confirm this is a tty: will VT_GETSTATE do that?
> 
> I'm wondering because I'd like to collapse the two codepaths together,
> but I don't understand what the code is doing well enough.
> (Documentation on ioctls is hard to come by, man ioctl_list doesn't even
> show KDGKBTYPE, let alone explain what VT_GETSTATE actually _does_.
> Would calling VT_GETSTATE sufficiently identify "we have a tty"
> especially since we're trying to call it on /dev/console and such?)

Trivial point: I think we're looking for a vt, not just a tty.

Anyhow, KDGKBTYPE stores keyboard type to the third arg; 
https://www.kernel.org/pub/linux/kernel/people/aeb/kbdbook.tmpl
says that "the main use...is is to test the validity of the fd
argument...for doing keyboard or console ioctl's."

VT_GETSTATE will also fail under the same circumstances.

HTH,
Isaac Dunham

 1403646949.0


More information about the Toybox mailing list