From 3fe2b2023ee79844908271e9467ec08af61adecd Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 29 Sep 2015 20:07:22 -0500 Subject: EXPERIMENTAL: Attempt to increase the VT limit to 48 --- tdm/backend/dm.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'tdm') diff --git a/tdm/backend/dm.c b/tdm/backend/dm.c index ed9299616..861037032 100644 --- a/tdm/backend/dm.c +++ b/tdm/backend/dm.c @@ -51,8 +51,8 @@ from the copyright holder. # include #endif -// Limited by short return data type of VT_ACTIVATE ioctl -#define MAX_VT_NUMBER 16 +// Limited by the number of VTs configured into the kernel or 256, whichever is less +#define MAX_VT_NUMBER 48 static void SigHandler( int n ); static int ScanConfigs( int force ); @@ -1260,21 +1260,31 @@ KickDisplay( struct display *d ) } #ifdef HAVE_VTS -static int active_vts; +static unsigned long active_vts; -static int -GetBusyVTs( void ) +static unsigned long +GetBusyVTs(void) { struct vt_stat vtstat; int con; if (active_vts == -1) { + unsigned short next_available_vt = 0; vtstat.v_state = 0; if ((con = open( "/dev/console", O_RDONLY )) >= 0) { - ioctl( con, VT_GETSTATE, &vtstat ); - close( con ); + ioctl(con, VT_GETSTATE, &vtstat); + ioctl(con, VT_OPENQRY, &next_available_vt); + close(con); } active_vts = vtstat.v_state; + if (next_available_vt > 0xf) { + // Assume all VTs less than the next available VT are busy + // This is due to limitations in the Linux console driver + int i; + for (i = 0x10; i < next_available_vt; i++) { + active_vts |= (1 << i); + } + } } return active_vts; } @@ -1326,7 +1336,7 @@ AllocateVT(struct display *d) } } } - if (!volun || !((1 << tvt) & GetBusyVTs())) { + if (!volun || !((1 << (unsigned long)tvt) & GetBusyVTs())) { d->serverVT = tvt; return; } -- cgit v1.2.1