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).
This commit is contained in:
Egbert Eich 2005-01-21 14:25:26 +00:00
parent d7263b11f0
commit 55736aa8c1

View File

@ -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);