Weirdness in TTY & VT

Edward Tomasz Napierała trasz at FreeBSD.org
Sat Sep 3 10:49:01 UTC 2016


On 0902T1712, Lundberg, Johannes wrote:
> ​Hi
> 
> I'm porting some Linux code and have some weird behavior.
> 
> In this (Linux) code fstat() and minor() is used on a /dev/tty file
> descriptor to get a tty number to map to. In FreeBSD this returns a number
> around 60-70 for st_rdev which means VT_ACTIVATE ioctl call will fail
> because it only allows values 0-12.
> 
> Should not this be compatible with FreeBSD? If not, what is the FreeBSD way
> to do this?
> 
> Is there some implementation missing in vt?

Device numbers don't really matter in FreeBSD.  To get the current
VT number, use VT_GETACTIVE ioctl.  Take a look at vidcontrol(1)
source to see how it's done ("vidcontrol -i active").



More information about the freebsd-current mailing list