From 55736aa8c17f762b15e9bcd7b3f68f8680b7cb33 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Fri, 21 Jan 2005 14:25:26 +0000 Subject: [PATCH] Alan Cox requested that we check the kernel version before we use kernel VGA font save/restore as the required features have been added to Linux 2.6.11 (Bugzilla #2277). --- hw/xfree86/os-support/linux/lnx_font.c | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/xfree86/os-support/linux/lnx_font.c b/hw/xfree86/os-support/linux/lnx_font.c index 10ea433c5..05bf7da67 100644 --- a/hw/xfree86/os-support/linux/lnx_font.c +++ b/hw/xfree86/os-support/linux/lnx_font.c @@ -112,10 +112,16 @@ getfont(int *width, int *height, } +#define VERSION_LEN 31 + Bool lnx_savefont(void) { unsigned char *fontdata; +#if CHECK_OS_VERSION + char kernel_version[VERSION_LEN + 1]; + int k_major, k_minor, k_release; +#endif int size; int fd; int width = 32, height = 32, charcount = 2048; @@ -123,6 +129,29 @@ lnx_savefont(void) #ifdef DEBUG ErrorF("SAVE font\n"); #endif + +#if CHECK_OS_VERSION + /* Check if the kernel has full support for this */ + if ((fd = open ("/proc/sys/kernel/osrelease",O_RDONLY)) == -1) { + close (fd); + return TRUE; + } + size = read(fd, kernel_version, VERSION_LEN); + close (fd); + + if (size < 0) + return TRUE; + + size = sscanf(kernel_version, "%d.%d.%d",&k_major,&k_minor,&k_release); + if (size < 3 + || (k_major < 2) + || ((k_major == 2) + && ((k_minor < 6) + || ( k_minor == 6 + && k_release < 11)))) + return TRUE; +#endif + /* if we are in fbdev mode we don't bother saving fonts */ if ((fd = open ("/dev/fb0",O_RDWR)) != -1) { close (fd);