aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorwiktor w brodlo <wiktor@brodlo.net>2011-06-15 16:59:54 +0000
committerwiktor w brodlo <wiktor@brodlo.net>2011-06-15 16:59:54 +0000
commit2590d96369d0217e31dc2812690dde61dac417b5 (patch)
tree82276f787b08a28548e342c7921486f1acefab9f /utils
parentfirst commit (diff)
downloadanaconda-2590d96369d0217e31dc2812690dde61dac417b5.tar.gz
anaconda-2590d96369d0217e31dc2812690dde61dac417b5.tar.bz2
anaconda-2590d96369d0217e31dc2812690dde61dac417b5.zip
Initial import from Sabayon (ver 0.9.9.56)
Diffstat (limited to 'utils')
-rw-r--r--utils/.gitignore10
-rw-r--r--utils/Makefile.am35
-rwxr-xr-xutils/filtermoddeps25
-rw-r--r--utils/geninitrdsz.c62
-rwxr-xr-xutils/genmodinfo76
-rw-r--r--utils/mapshdr.c59
-rw-r--r--utils/mk-s390-cdboot.c284
-rw-r--r--utils/modlist.c146
-rw-r--r--utils/readmap.c119
-rw-r--r--utils/snarffont.c97
-rwxr-xr-xutils/trimpciids80
11 files changed, 993 insertions, 0 deletions
diff --git a/utils/.gitignore b/utils/.gitignore
new file mode 100644
index 0000000..f50c9f1
--- /dev/null
+++ b/utils/.gitignore
@@ -0,0 +1,10 @@
+modlist
+moddeps
+genhdlist
+mapshdr
+snarffont
+readmap
+.utils
+.depend
+moduledeps.c
+moduleinfo.c
diff --git a/utils/Makefile.am b/utils/Makefile.am
new file mode 100644
index 0000000..54a9da8
--- /dev/null
+++ b/utils/Makefile.am
@@ -0,0 +1,35 @@
+# utils/Makefile.am for anaconda
+#
+# Copyright (C) 2009 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: David Cantrell <dcantrell@redhat.com>
+
+utilsdir = $(libexecdir)/$(PACKAGE_NAME)
+
+utils_PROGRAMS = modlist mapshdr readmap
+dist_utils_SCRIPTS = genmodinfo trimpciids
+noinst_PROGRAMS = snarffont
+dist_noinst_SCRIPTS = filtermoddeps
+
+if IS_S390
+utils_PROGRAMS += geninitrdsz mk-s390-cdboot
+endif
+
+modlist_CFLAGS = -I$(top_srcdir)/loader $(GLIB_CFLAGS)
+modlist_LDADD = $(GLIB_LIBS)
+modlist_SOURCES = modlist.c $(top_srcdir)/loader/moduleinfo.c
+
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/utils/filtermoddeps b/utils/filtermoddeps
new file mode 100755
index 0000000..3deeed0
--- /dev/null
+++ b/utils/filtermoddeps
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# filtermoddeps
+#
+# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+perl -e 'while (<>) { if (/\\\n/) { chop; s/\\$//; print;} else { print $_; } }' | grep ':.*ko' | sed -e '
+s/\.ko//g
+s,/[^: ]*/,,g
+s/[ ][ ]*/ /g'
+
diff --git a/utils/geninitrdsz.c b/utils/geninitrdsz.c
new file mode 100644
index 0000000..6dfd976
--- /dev/null
+++ b/utils/geninitrdsz.c
@@ -0,0 +1,62 @@
+/*
+ * geninitrdsz.c
+ * Generate initrd.size file for zSeries platforms.
+ * Takes an integer argument and writes out the binary representation of
+ * that value to the initrd.size file.
+ * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=197773
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+int main(int argc,char **argv) {
+ unsigned int zero = 0;
+ int fd;
+ unsigned int size;
+ mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
+
+ if (argc != 3) {
+ printf("Usage: %s [integer size] [output file]\n", basename(argv[0]));
+ printf("Example: %s 12288475 initrd.size\n", basename(argv[0]));
+ return 0;
+ }
+
+ size = htonl(atoi(argv[1]));
+ fd = open(argv[2], O_CREAT | O_RDWR, mode);
+
+ if (write(fd, &zero, sizeof(int)) == -1) {
+ perror("writing initrd.size (zero)");
+ return errno;
+ }
+
+ if (write(fd, &size, sizeof(int)) == -1) {
+ perror("writing initrd.size (size)");
+ return errno;
+ }
+
+ close(fd);
+ return 0;
+}
diff --git a/utils/genmodinfo b/utils/genmodinfo
new file mode 100755
index 0000000..44c8247
--- /dev/null
+++ b/utils/genmodinfo
@@ -0,0 +1,76 @@
+#!/usr/bin/python
+#
+# genmodinfo
+#
+# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import commands
+import os
+import string
+import sys
+
+uname = os.uname()[2]
+
+if len(sys.argv) > 1:
+ path = sys.argv[1]
+else:
+ path = '/lib/modules/%s' % (uname,)
+
+mods = {}
+for root, dirs, files in os.walk(path):
+ for file in files:
+ mods[file] = os.path.join(root,file)
+
+modules = { 'scsi_hostadapter' : [ 'block' ], 'eth' : [ 'networking'] }
+blacklist = ("floppy", "scsi_mod", "libiscsi")
+
+list = {}
+
+for modtype in modules.keys():
+ list[modtype] = {}
+ for file in modules[modtype]:
+ try:
+ f = open('%s/modules.%s' % (path,file),'r')
+ except:
+ continue
+ lines = f.readlines()
+ f.close()
+ for line in lines:
+ line = line.strip()
+ if mods.has_key(line):
+ desc = commands.getoutput("modinfo -F description %s" % (mods[line])).split("\n")[0]
+ desc = desc.strip()
+ modname = line[:-3]
+ if modname in blacklist:
+ continue
+ if desc and len(desc) > 65:
+ desc = desc[:65]
+ if not desc:
+ desc = "%s driver" % (modname,)
+ modinfo = """
+%s
+ %s
+ "%s"
+""" % (modname, modtype, desc)
+ list[modtype][modname] = modinfo
+
+print "Version 0"
+for type in list.keys():
+ modlist = list[type].keys()
+ modlist.sort()
+ for m in modlist:
+ print list[type][m]
diff --git a/utils/mapshdr.c b/utils/mapshdr.c
new file mode 100644
index 0000000..f2209c7
--- /dev/null
+++ b/utils/mapshdr.c
@@ -0,0 +1,59 @@
+/*
+ * mapshdr.c
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "../isys/lang.h"
+
+int main(int argc, char ** argv) {
+ struct kmapHeader h;
+ struct kmapInfo info;
+ int i, x;
+ struct stat sb;
+ char * chptr;
+
+ h.magic = KMAP_MAGIC;
+ h.numEntries = argc - 1;
+ x = write(1, &h, sizeof(h));
+
+ for (i = 1; i < argc; i++) {
+ if (stat(argv[i], &sb)) {
+ fprintf(stderr, "stat error for %s: %s\n", argv[i],
+ strerror(errno));
+ exit(1);
+ }
+
+ memset(info.name, 0, KMAP_NAMELEN);
+ strncpy(info.name, argv[i], KMAP_NAMELEN - 1);
+
+ chptr = info.name + strlen(info.name) - 1;
+ while (*chptr != '.') *chptr-- = '\0';
+ *chptr = '\0';
+
+ info.size = sb.st_size;
+ x = write(1, &info, sizeof(info));
+ }
+
+ return 0;
+}
diff --git a/utils/mk-s390-cdboot.c b/utils/mk-s390-cdboot.c
new file mode 100644
index 0000000..4a58258
--- /dev/null
+++ b/utils/mk-s390-cdboot.c
@@ -0,0 +1,284 @@
+/*
+ * mk-s390-cdboot -- creates one big image using a kernel, a ramdisk and
+ * a parmfile
+ *
+ * 2003-07-24 Volker Sameske <sameske@de.ibm.com>
+ * 2008-09-22 Updated by David Cantrell <dcantrell@redhat.com>
+ *
+ * compile with:
+ * gcc -Wall -o mk-s390-cdboot mk-s390-cdboot.c
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <libgen.h>
+
+#define BUFFER_LEN 1024
+#define INITRD_START 0x0000000000800000LL
+#define START_PSW_ADDRESS 0x80010000
+
+static struct option getopt_long_options[]= {
+ { "image", 1, 0, 'i'},
+ { "ramdisk", 1, 0, 'r'},
+ { "parmfile", 1, 0, 'p'},
+ { "outfile", 1, 0, 'o'},
+ { "help", 0, 0, 'h'},
+ {0, 0, 0, 0}
+};
+
+static void usage(char *cmd) {
+ printf("%s [-h] [-v] -i <kernel> -r <ramdisk> -p <parmfile> -o <outfile>\n", cmd);
+}
+
+int main (int argc, char **argv) {
+ char *cmd = basename(argv[0]);
+ FILE *fd1 = NULL;
+ FILE *fd2 = NULL;
+ FILE *fd3 = NULL;
+ FILE *fd4 = NULL;
+ char buffer[BUFFER_LEN];
+ int wc, rc, oc, index;
+ unsigned long long initrd_start = INITRD_START;
+ unsigned long long initrd_size;
+ char *image = NULL;
+ char *ramdisk = NULL;
+ char *parmfile = NULL;
+ char *outfile = NULL;
+ int image_specified = 0;
+ int ramdisk_specified = 0;
+ int parmfile_specified = 0;
+ int outfile_specified = 0;
+ int start_psw_address = START_PSW_ADDRESS;
+
+ opterr = 0;
+ while (1) {
+ oc = getopt_long(argc, argv, "i:r:p:o:h?", getopt_long_options, &index);
+ if (oc == -1) {
+ break;
+ }
+
+ switch (oc) {
+ case '?':
+ case 'h':
+ usage(cmd);
+ exit(0);
+ case 'i':
+ image = strdup(optarg);
+ image_specified = 1;
+ break;
+ case 'r':
+ ramdisk = strdup(optarg);
+ ramdisk_specified = 1;
+ break;
+ case 'p':
+ parmfile = strdup(optarg);
+ parmfile_specified = 1;
+ break;
+ case 'o':
+ outfile = strdup(optarg);
+ outfile_specified = 1;
+ break;
+ default:
+ usage(cmd);
+ exit(0);
+ }
+ }
+
+ if (!image_specified || !ramdisk_specified ||
+ !parmfile_specified || !outfile_specified) {
+ usage(cmd);
+ exit(0);
+ }
+
+ printf("Creating bootable CD-ROM image...\n");
+ printf("kernel is : %s\n", image);
+ printf("ramdisk is : %s\n", ramdisk);
+ printf("parmfile is: %s\n", parmfile);
+ printf("outfile is : %s\n", outfile);
+
+ if ((fd1 = fopen(outfile, "w")) == NULL) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if ((fd2 = fopen(image, "r")) == NULL) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if ((fd3 = fopen(ramdisk, "r")) == NULL) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if ((fd4 = fopen(parmfile, "r")) == NULL) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ printf("writing kernel...\n");
+ while (1) {
+ rc = fread(buffer, 1, 1, fd2);
+
+ if (rc == 0) {
+ break;
+ }
+
+ if (feof(fd2) || ferror(fd2)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ wc = fwrite(buffer, 1, 1, fd1);
+ if (feof(fd1) || ferror(fd1)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if (wc != rc) {
+ fprintf(stderr, "could only write %i of %i bytes of kernel\n",
+ wc, rc);
+ }
+ }
+
+ printf("writing initrd...\n");
+ fseek(fd1, initrd_start, SEEK_SET);
+ while (1) {
+ rc = fread(buffer, 1, 1, fd3);
+
+ if (rc == 0) {
+ break;
+ }
+
+ if (feof(fd3) || ferror(fd3)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ wc = fwrite(buffer, 1, 1, fd1);
+ if (feof(fd1) || ferror(fd1)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if (wc != rc) {
+ fprintf(stderr, "could only write %i of %i bytes of initrd\n",
+ wc, rc);
+ }
+ }
+
+ if (fseek(fd3, 0, SEEK_END) == -1) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if ((initrd_size = ftell(fd3)) == -1) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ printf("changing start PSW address to 0x%08x...\n", start_psw_address);
+ if (fseek(fd1, 0x4, SEEK_SET) == -1) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ wc = fwrite(&start_psw_address, 1, 4, fd1);
+ if (feof(fd1) || ferror(fd1)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if (wc != 4) {
+ fprintf(stderr, "could only write %i of %i bytes of PSW address\n",
+ wc, 4);
+ }
+
+ printf("writing initrd address and size...\n");
+ printf("INITRD start: 0x%016llx\n", initrd_start);
+ printf("INITRD size : 0x%016llx\n", initrd_size);
+
+ if (fseek(fd1, 0x10408, SEEK_SET) == -1) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ wc = fwrite(&initrd_start, 1, 8, fd1);
+ if (feof(fd1) || ferror(fd1)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if (wc != 8) {
+ fprintf(stderr, "could only write %i of %i bytes of INITRD start\n",
+ wc, 8);
+ }
+
+ if (fseek(fd1, 0x10410, SEEK_SET) == -1) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ wc = fwrite(&initrd_size, 1, 8, fd1);
+ if (feof(fd1) || ferror(fd1)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if (wc != 8) {
+ fprintf(stderr, "could only write %i of %i bytes of INITRD size\n",
+ wc, 8);
+ }
+
+ printf("writing parmfile...\n");
+ if (fseek(fd1, 0x10480, SEEK_SET) == -1) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ while (1) {
+ rc = fread(buffer, 1, 1, fd4);
+
+ if (rc == 0) {
+ break;
+ }
+
+ if (feof(fd4) || ferror(fd4)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ wc = fwrite(buffer, 1, 1, fd1);
+ if (feof(fd1) || ferror(fd1)) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ abort();
+ }
+
+ if (wc != 1) {
+ fprintf(stderr, "could only write %i of %i bytes of parmfile\n",
+ wc, 1);
+ }
+ }
+
+ if (fclose(fd1) == EOF) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ }
+
+ if (fclose(fd2) == EOF) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ }
+
+ if (fclose(fd3) == EOF) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ }
+
+ if (fclose(fd4) == EOF) {
+ fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/utils/modlist.c b/utils/modlist.c
new file mode 100644
index 0000000..7aff567
--- /dev/null
+++ b/utils/modlist.c
@@ -0,0 +1,146 @@
+/*
+ * modlist.c
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include "../isys/isys.h"
+#include "moduleinfo.h"
+
+int main(int argc, char ** argv) {
+ GOptionContext *optCon = g_option_context_new(NULL);
+ GError *optErr = NULL;
+ gchar *modInfoFile = "/boot/module-info";
+ gboolean ignoreMissing = FALSE, showModInfo = FALSE;
+ gchar **remaining = NULL;
+ enum driverMajor major;
+ const char * type;
+ const char * mod;
+ struct moduleInfo * list, * m;
+ int i, arg = 0;
+ moduleInfoSet mis;
+ struct moduleInfo * mi;
+ GOptionEntry optionTable[] = {
+ { "ignore-missing", 'I', 0, G_OPTION_ARG_NONE, &ignoreMissing,
+ "Ignore modules not in modinfo file for --modinfo", NULL },
+ { "modinfo", 'm', 0, G_OPTION_ARG_NONE, &showModInfo,
+ "Give output in module-info file for listed args", NULL },
+ { "modinfo-file", 'f', 0, G_OPTION_ARG_STRING, &modInfoFile,
+ "Module info file to use", NULL },
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining,
+ NULL, NULL },
+ { NULL },
+ };
+
+ g_option_context_add_main_entries(optCon, optionTable, NULL);
+
+ if (!g_option_context_parse(optCon, &argc, &argv, &optErr)) {
+ fprintf(stderr, "bad option: %s\n", optErr->message);
+ g_error_free(optErr);
+ g_option_context_free(optCon);
+ g_strfreev(remaining);
+ exit(1);
+ }
+
+ g_option_context_free(optCon);
+
+ if (remaining == NULL) {
+ exit(1);
+ }
+
+ mis = newModuleInfoSet();
+ if (readModuleInfo(modInfoFile, mis, NULL, 0)) {
+ fprintf(stderr, "Failed to read %s\n", modInfoFile);
+ exit(1);
+ }
+
+ if (showModInfo) {
+ printf("Version 0\n");
+ while ((mod = remaining[arg]) != NULL) {
+ mi = findModuleInfo(mis, mod);
+ if (mi) {
+ printf("%s\n", mi->moduleName);
+ switch (mi->major) {
+ case DRIVER_CDROM: printf("\tcdrom\n"); break;
+ case DRIVER_SCSI: printf("\tscsi\n"); break;
+ case DRIVER_FS: printf("\tfs\n"); break;
+ case DRIVER_PCMCIA: printf("\tpcmcia\n"); break;
+ case DRIVER_IDE: printf("\tide\n"); break;
+ case DRIVER_OTHER: printf("\tother\n"); break;
+ case DRIVER_NET:
+ switch (mi->minor) {
+ case DRIVER_MINOR_ETHERNET: printf("\teth\n"); break;
+ case DRIVER_MINOR_TR: printf("\ttr\n"); break;
+
+ default:
+ fprintf(stderr, "unknown net minor type for %s\n",
+ mi->moduleName);
+ g_strfreev(remaining);
+ exit(1);
+ }
+ break;
+
+ default:
+ fprintf(stderr, "unknown device type for %s (%d)\n",
+ mi->moduleName, mi->major);
+ g_strfreev(remaining);
+ exit(1);
+
+ }
+ printf("\t\"%s\"\n", mi->description);
+ for (i = 0; i < mi->numArgs; i++) {
+ printf("\t%s \"%s\"\n", mi->args[i].arg,
+ mi->args[i].description);
+ }
+ } else if (!ignoreMissing) {
+ fprintf(stderr, "I know nothing about %s\n", mod);
+ g_strfreev(remaining);
+ exit(1);
+ }
+ arg++;
+ }
+ } else {
+ while ((type = remaining[arg]) != NULL) {
+ if (!strcasecmp(type, "scsi")) {
+ major = DRIVER_SCSI;
+ } else if (!strcasecmp(type, "net")) {
+ major = DRIVER_NET;
+ } else if (!strcasecmp(type, "fs")) {
+ major = DRIVER_FS;
+ } else if (!strcasecmp(type, "cdrom")) {
+ major = DRIVER_CDROM;
+ } else {
+ fprintf(stderr, "type must be one of scsi, net, fs, cdrom\n");
+ g_strfreev(remaining);
+ exit(1);
+ }
+
+ list = getModuleList(mis, major);
+ for (m = list; m && m->moduleName; m++)
+ printf("%s\n", m->moduleName);
+ free(list);
+ arg++;
+ }
+ }
+
+ g_strfreev(remaining);
+ return 0;
+}
diff --git a/utils/readmap.c b/utils/readmap.c
new file mode 100644
index 0000000..7d65636
--- /dev/null
+++ b/utils/readmap.c
@@ -0,0 +1,119 @@
+/*
+ * readmap.c
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/keyboard.h>
+#ifdef NR_KEYS
+#undef NR_KEYS
+#define NR_KEYS 128
+#endif
+
+#include <linux/kd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "../isys/lang.h"
+
+int main(int argc, char ** argv) {
+ int console;
+ int kmap, key;
+ struct kbentry entry;
+ int keymaps[MAX_NR_KEYMAPS];
+ int count = 0;
+ int out;
+ short keymap[NR_KEYS];
+ int magic = KMAP_MAGIC;
+ int verbose = 0;
+
+ if (argc != 2) {
+ printf("bad usage\n");
+ exit(1);
+ }
+
+ if (getenv("DEBUG") != NULL)
+ verbose = 1;
+
+ memset(keymaps, 0, sizeof(keymaps));
+
+ console = open("/dev/tty0", O_RDWR);
+ if (console < 0) {
+ perror("open VGA+KBD");
+ exit(1);
+ }
+
+ for (kmap = 0; kmap < MAX_NR_KEYMAPS; kmap++) {
+ for (key = 0; key < NR_KEYS; key++) {
+ entry.kb_index = key;
+ entry.kb_table = kmap;
+ if (ioctl(console, KDGKBENT, &entry)) {
+ perror("ioctl failed");
+ exit(1);
+ } else if (KTYP(entry.kb_value) != KT_SPEC) {
+ keymaps[kmap] = 1;
+ count++;
+ break;
+ }
+ }
+ }
+
+ if (verbose) fprintf(stderr, "found %d valid keymaps\n", count);
+
+ if (verbose) fprintf(stderr, "creating keymap file %s\n", argv[1]);
+ if ((out = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 1) {
+ perror("open keymap");
+ exit(1);
+ }
+
+ if (write(out, &magic, sizeof(magic)) != sizeof(magic)) {
+ perror("write magic");
+ exit(1);
+ }
+
+ if (write(out, keymaps, sizeof(keymaps)) != sizeof(keymaps)) {
+ perror("write header");
+ exit(1);
+ }
+
+ for (kmap = 0; kmap < MAX_NR_KEYMAPS; kmap++) {
+ if (!keymaps[kmap]) continue;
+ for (key = 0; key < NR_KEYS; key++) {
+ entry.kb_index = key;
+ entry.kb_table = kmap;
+ if (ioctl(console, KDGKBENT, &entry)) {
+ perror("ioctl failed");
+ exit(1);
+ } else {
+ keymap[key] = entry.kb_value;
+ }
+ }
+
+ if (write(out, keymap, sizeof(keymap)) != sizeof(keymap)) {
+ perror("write keymap");
+ exit(1);
+ }
+ }
+
+ close(out);
+
+ return 0;
+}
diff --git a/utils/snarffont.c b/utils/snarffont.c
new file mode 100644
index 0000000..49bad6e
--- /dev/null
+++ b/utils/snarffont.c
@@ -0,0 +1,97 @@
+/*
+ * snarffont.c
+ *
+ * Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/kd.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define MAXFONTSIZE 65536
+
+int main(void) {
+ unsigned char buf[MAXFONTSIZE];
+ struct console_font_op cfo;
+ unsigned short map[E_TABSZ];
+ struct unipair descs[2048];
+ struct unimapdesc d;
+ int fd;
+
+ if ((fd = open("/dev/tty0", O_RDONLY)) < 0) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ cfo.op = KD_FONT_OP_GET;
+ cfo.flags = 0;
+ cfo.width = 8;
+ cfo.height = 16;
+ cfo.charcount = 512;
+ cfo.data = buf;
+ if (ioctl(fd, KDFONTOP, &cfo)) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ if (ioctl(fd, GIO_UNISCRNMAP, map)) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ d.entry_ct = 2048;
+ d.entries = descs;
+ if (ioctl(fd, GIO_UNIMAP, &d)) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ if (write(1, &cfo, sizeof(cfo)) == -1) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ if (write(1, &cfo, sizeof(cfo)) == -1) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ if (write(1, buf, sizeof(buf)) == -1) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ if (write(1, map, sizeof(map)) == -1) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ if (write(1, &d.entry_ct, sizeof(d.entry_ct)) == -1) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ if (write(1, descs, d.entry_ct * sizeof(descs[0])) == -1) {
+ fprintf(stderr, "%s: %m", __func__);
+ return EXIT_FAILURE;
+ }
+
+ return 0;
+}
diff --git a/utils/trimpciids b/utils/trimpciids
new file mode 100755
index 0000000..ba94629
--- /dev/null
+++ b/utils/trimpciids
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+#
+# trimpciids
+#
+# Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import sys
+import os
+import string
+
+vendors = []
+devices = []
+
+f = open(sys.argv[1])
+if f:
+ pcitable = f.readlines()
+ f.close()
+ for line in pcitable:
+ if not line.startswith("alias pci:"):
+ continue
+ vend = "0x%s" % (line[15:19],)
+ dev = "0x%s" % (line[24:28],)
+ vend = vend.upper()
+ dev = dev.upper()
+ if vend not in vendors:
+ vendors.append(vend)
+ if (vend, dev) not in devices:
+ devices.append( (vend, dev) )
+
+for file in sys.argv[2:]:
+ if not os.path.exists(file):
+ sys.stderr.write("WARNING: non-existent file %s for trimpciids\n" %(file,))
+ continue
+ f = open(file)
+ if f:
+ pcitable = f.readlines()
+ f.close()
+ for line in pcitable:
+ if not line.startswith("alias pcivideo:"):
+ continue
+ vend = "0x%s" % (line[20:24],)
+ dev = "0x%s" % (line[29:33],)
+ vend = vend.upper()
+ dev = dev.upper()
+ if vend not in vendors:
+ vendors.append(vend)
+ if (vend, dev) not in devices:
+ devices.append( (vend, dev) )
+
+pciids = sys.stdin.readlines()
+current_vend = 0
+for line in pciids:
+ if line.startswith("#") or line == "\n":
+ continue
+ if line.startswith("\t\t"):
+ continue
+ if not line.startswith("\t"):
+ current_vend = "0x%s" % line.split()[0]
+ current_vend = current_vend.upper()
+ if current_vend in vendors:
+ print line,
+ continue
+ dev = "0x%s" % line.split()[0]
+ dev = dev.upper()
+ if (current_vend, dev) in devices:
+ print line,