[PATCH 2/2] Remove our loadKeymap code from isys

Vratislav Podzimek vpodzime at redhat.com
Mon Jul 23 12:47:06 UTC 2012


It is used only in the text mode and it should be possible to replace
it with calling 'loadkeys' command in the new text mode.
---
 pyanaconda/isys/__init__.py |    6 ---
 pyanaconda/isys/isys.c      |    1 -
 pyanaconda/isys/lang.c      |  108 -------------------------------------------
 pyanaconda/isys/lang.h      |   18 --------
 4 files changed, 133 deletions(-)

diff --git a/pyanaconda/isys/__init__.py b/pyanaconda/isys/__init__.py
index fc766fc..63edbf6 100755
--- a/pyanaconda/isys/__init__.py
+++ b/pyanaconda/isys/__init__.py
@@ -171,12 +171,6 @@ def swapoff (path):
 def swapon (path):
     return _isys.swapon (path)
 
-## Load a keyboard layout for text mode installs.
-# @param keymap The keyboard layout to load.  This must be one of the values
-#               from rhpl.KeyboardModels.
-def loadKeymap(keymap):
-    return _isys.loadKeymap (keymap)
-
 def resetResolv():
     return _isys.resetresolv()
 
diff --git a/pyanaconda/isys/isys.c b/pyanaconda/isys/isys.c
index 8c4eb4b..35b2f33 100644
--- a/pyanaconda/isys/isys.c
+++ b/pyanaconda/isys/isys.c
@@ -126,7 +126,6 @@ static PyMethodDef isysModuleMethods[] = {
     { "resetresolv", (PyCFunction) doResetResolv, METH_VARARGS, NULL },
     { "swapon",  (PyCFunction) doSwapon, METH_VARARGS, NULL },
     { "swapoff",  (PyCFunction) doSwapoff, METH_VARARGS, NULL },
-    { "loadKeymap", (PyCFunction) doLoadKeymap, METH_VARARGS, NULL },
     { "vtActivate", (PyCFunction) doVtActivate, METH_VARARGS, NULL},
     { "isPseudoTTY", (PyCFunction) doisPseudoTTY, METH_VARARGS, NULL},
     { "isVioConsole", (PyCFunction) doisVioConsole, METH_NOARGS, NULL},
diff --git a/pyanaconda/isys/lang.c b/pyanaconda/isys/lang.c
index 07dee56..c38b1bb 100644
--- a/pyanaconda/isys/lang.c
+++ b/pyanaconda/isys/lang.c
@@ -56,111 +56,3 @@ int isysSetUnicodeKeymap(void) {
     return 0;
 }
 
-/* the file pointer must be at the beginning of the section already! */
-int loadKeymap(gzFile stream) {
-    int console;
-    int kmap, key;
-    struct kbentry entry;
-    int keymaps[MAX_NR_KEYMAPS];
-    int count = 0;
-    unsigned int magic;
-    short keymap[NR_KEYS];
-    struct stat sb;
-
-#if defined (__s390__) || defined (__s390x__)
-    return 0;
-#endif
-    if (isVioConsole())
-        return 0;
-
-    /* assume that if we're already on a pty loading a keymap is silly */
-    fstat(0, &sb);
-    if (major(sb.st_rdev) == 3 || major(sb.st_rdev) == 136)
-	return 0;
-
-    if (gzread(stream, &magic, sizeof(magic)) != sizeof(magic))
-	return -EIO;
-
-    if (magic != KMAP_MAGIC) return -EINVAL;
-
-    if (gzread(stream, keymaps, sizeof(keymaps)) != sizeof(keymaps))
-	return -EINVAL;
-
-    console = open("/dev/tty0", O_RDWR);
-    if (console < 0)
-	return -EACCES;
-
-    for (kmap = 0; kmap < MAX_NR_KEYMAPS; kmap++) {
-	if (!keymaps[kmap]) continue;
-
-	if (gzread(stream, keymap, sizeof(keymap)) != sizeof(keymap)) {
-	    close(console);
-	    return -EIO;
-	}
-
-	count++;
-	for (key = 0; key < NR_KEYS; key++) {
-	    entry.kb_index = key;
-	    entry.kb_table = kmap;
-	    entry.kb_value = keymap[key];
-	    if (KTYP(entry.kb_value) != KT_SPEC) {
-		if (ioctl(console, KDSKBENT, &entry)) {
-		    int ret = errno;
-		    close(console);
-		    return ret;
-		}
-	    }
-	}
-    }
-    close(console);
-    return 0;
-}
-
-int isysLoadKeymap(char * keymap) {
-    int num = -1;
-    int rc;
-    gzFile f;
-    struct kmapHeader hdr;
-    struct kmapInfo * infoTable;
-    char buf[16384]; 			/* I hope this is big enough */
-    int i;
-
-    f = gzopen("/etc/keymaps.gz", "r");
-    if (!f) return -EACCES;
-
-    if (gzread(f, &hdr, sizeof(hdr)) != sizeof(hdr)) {
-	gzclose(f);
-	return -EINVAL;
-    }
-
-    i = hdr.numEntries * sizeof(*infoTable);
-    infoTable = alloca(i);
-    if (gzread(f, infoTable, i) != i) {
-	gzclose(f);
-	return -EIO;
-    }
-
-    for (i = 0; i < hdr.numEntries; i++)
-	if (!strcmp(infoTable[i].name, keymap)) {
-	    num = i;
-	    break;
-	}
-
-    if (num == -1) {
-	gzclose(f);
-	return -ENOENT;
-    }
-
-    for (i = 0; i < num; i++) {
-	if (gzread(f, buf, infoTable[i].size) != infoTable[i].size) {
-	    gzclose(f);
-	    return -EIO;
-	}
-    }
-
-    rc = loadKeymap(f);
-
-    gzclose(f);
-
-    return rc;
-}
diff --git a/pyanaconda/isys/lang.h b/pyanaconda/isys/lang.h
index b5ff4da..aac821a 100644
--- a/pyanaconda/isys/lang.h
+++ b/pyanaconda/isys/lang.h
@@ -20,24 +20,6 @@
 #ifndef ISYS_LANG_H
 #define ISYS_LANG_H
 
-#include <zlib.h>
-
-/* define ask johnsonm at redhat.com where this came from */
-#define KMAP_MAGIC 0x8B39C07F
-#define KMAP_NAMELEN 40         /* including '\0' */
-
-struct kmapHeader {
-    int magic;
-    int numEntries;
-};
-        
-struct kmapInfo {
-    int size;
-    char name[KMAP_NAMELEN];
-};
-
-int loadKeymap(gzFile stream);
-int isysLoadKeymap(char * keymap);
 int isysSetUnicodeKeymap(void);
 
 #endif
-- 
1.7.10.4



More information about the anaconda-patches mailing list