diff --git a/applets/busybox.c b/applets/busybox.c
index 16ccce6..cb0e2a7 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -72,6 +72,9 @@
 #ifdef BB_LN			//bin
     {"ln", ln_main},
 #endif
+#ifdef BB_LOADFONT		//usr/bin
+    {"loadfont", loadfont_main},
+#endif
 #ifdef BB_LOADKMAP		//sbin
     {"loadkmap", loadkmap_main},
 #endif
diff --git a/busybox.c b/busybox.c
index 16ccce6..cb0e2a7 100644
--- a/busybox.c
+++ b/busybox.c
@@ -72,6 +72,9 @@
 #ifdef BB_LN			//bin
     {"ln", ln_main},
 #endif
+#ifdef BB_LOADFONT		//usr/bin
+    {"loadfont", loadfont_main},
+#endif
 #ifdef BB_LOADKMAP		//sbin
     {"loadkmap", loadkmap_main},
 #endif
diff --git a/busybox.def.h b/busybox.def.h
index 7ca522b..e379168 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -13,29 +13,30 @@
 #define BB_DD
 #define BB_DF
 #define BB_DMESG
-#define BB_DUTMP
+//#define BB_DUTMP
 #define BB_FALSE
 #define BB_FDFLUSH
 #define BB_FIND
 #define BB_GREP
-//#define BB_HALT
+#define BB_HALT
 #define BB_INIT
 #define BB_KILL
 //#define BB_LENGTH
 #define BB_LN
+#define BB_LOADFONT
 #define BB_LOADKMAP
 #define BB_LS
-#define BB_MAKEDEVS
+//#define BB_MAKEDEVS
 //#define BB_MATH
 #define BB_MKDIR
 #define BB_MKNOD
-//#define BB_MKSWAP
-#define BB_MNC
+#define BB_MKSWAP
+//#define BB_MNC
 #define BB_MORE
 #define BB_MOUNT
-//#define BB_MT
+#define BB_MT
 #define BB_MV
-#define BB_PRINTF
+//#define BB_PRINTF
 #define BB_PWD
 #define BB_REBOOT
 #define BB_RM
@@ -50,4 +51,4 @@
 #define BB_UPDATE
 #define BB_UTILITY
 #define BB_ZCAT
-#define BB_GZIP
+//#define BB_GZIP
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
new file mode 100644
index 0000000..a10fa8a
--- /dev/null
+++ b/console-tools/loadfont.c
@@ -0,0 +1,234 @@
+/*
+ * loadfont.c - Eugene Crosser & Andries Brouwer
+ *
+ * Version 0.96bb
+ *
+ * Loads the console font, and possibly the corresponding screen map(s).
+ * (Adapted for busybox by Matej Vela.)
+ */
+#include "internal.h"
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <memory.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/kd.h>
+#include <endian.h>
+
+#define PSF_MAGIC1	0x36
+#define PSF_MAGIC2	0x04
+
+#define PSF_MODE512    0x01
+#define PSF_MODEHASTAB 0x02
+#define PSF_MAXMODE    0x03
+#define PSF_SEPARATOR  0xFFFF
+
+static const char loadfont_usage[] = "loadfont\n"
+"\n"
+"\tLoad a console font from standard input.\n"
+"\n";
+
+struct psf_header
+{
+  unsigned char magic1, magic2;	/* Magic number */
+  unsigned char mode;		/* PSF font mode */
+  unsigned char charsize;	/* Character size */
+};
+
+#define PSF_MAGIC_OK(x)	((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
+
+static void loadnewfont(int fd);
+
+extern int
+loadfont_main(int argc, char **argv)
+{
+	int fd;
+
+	fd = open("/dev/tty0", O_RDWR);
+	if (fd < 0) {
+	    fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
+	    return 1;
+	}
+	loadnewfont(fd);
+
+	return 0;
+}
+
+static void
+do_loadfont(int fd, char *inbuf, int unit, int fontsize) {
+	char buf[16384];
+	int i;
+
+	memset(buf,0,sizeof(buf));
+
+	if (unit < 1 || unit > 32) {
+	    fprintf(stderr, "Bad character size %d\n", unit);
+	    exit(1);
+	}
+
+	for (i = 0; i < fontsize; i++)
+	    memcpy(buf+(32*i), inbuf+(unit*i), unit);
+
+#if defined( PIO_FONTX ) && !defined( sparc )
+	{
+	    struct consolefontdesc cfd;
+
+	    cfd.charcount = fontsize;
+	    cfd.charheight = unit;
+	    cfd.chardata = buf;
+
+	    if (ioctl(fd, PIO_FONTX, &cfd) == 0)
+	      return;		/* success */
+	    perror("PIO_FONTX ioctl error (trying PIO_FONT)");
+	}
+#endif
+	if (ioctl(fd, PIO_FONT, buf)) {
+	    perror("PIO_FONT ioctl error");
+	    exit(1);
+	}
+}
+
+static void
+do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) {
+	struct unimapinit advice;
+	struct unimapdesc ud;
+	struct unipair *up;
+	int ct = 0, maxct;
+	int glyph;
+	u_short unicode;
+
+	maxct = tailsz;		/* more than enough */
+	up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
+	if (!up) {
+	    fprintf(stderr, "Out of memory?\n");
+	    exit(1);
+	}
+	for (glyph = 0; glyph < fontsize; glyph++) {
+	    while (tailsz >= 2) {
+		unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
+		tailsz -= 2;
+		inbuf += 2;
+		if (unicode == PSF_SEPARATOR)
+		    break;
+		up[ct].unicode = unicode;
+		up[ct].fontpos = glyph;
+		ct++;
+	    }
+	}
+
+	/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
+	   this printf did not work on many kernels */
+
+	advice.advised_hashsize = 0;
+	advice.advised_hashstep = 0;
+	advice.advised_hashlevel = 0;
+	if(ioctl(fd, PIO_UNIMAPCLR, &advice)) {
+#ifdef ENOIOCTLCMD
+	    if (errno == ENOIOCTLCMD) {
+		fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
+		fprintf(stderr, "No Unicode mapping table loaded.\n");
+	    } else
+#endif
+	      perror("PIO_UNIMAPCLR");
+	    exit(1);
+	}
+	ud.entry_ct = ct;
+	ud.entries = up;
+	if(ioctl(fd, PIO_UNIMAP, &ud)) {
+#if 0
+	    if (errno == ENOMEM) {
+		/* change advice parameters */
+	    }
+#endif
+	    perror("PIO_UNIMAP");
+	    exit(1);
+	}
+}
+
+static void
+loadnewfont(int fd) {
+	int unit;
+	char inbuf[32768];	/* primitive */
+	int inputlth, offset;
+
+	/*
+	 * We used to look at the length of the input file
+	 * with stat(); now that we accept compressed files,
+	 * just read the entire file.
+	 */
+	inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
+	if (ferror(stdin)) {
+		perror("Error reading input font");
+		exit(1);
+	}
+	/* use malloc/realloc in case of giant files;
+	   maybe these do not occur: 16kB for the font,
+	   and 16kB for the map leaves 32 unicode values
+	   for each font position */
+	if (!feof(stdin)) {
+		perror("Font too large");
+		exit(1);
+	}
+
+	/* test for psf first */
+	{
+	    struct psf_header psfhdr;
+	    int fontsize;
+	    int hastable;
+	    int head0, head;
+
+	    if (inputlth < sizeof(struct psf_header))
+		goto no_psf;
+
+	    psfhdr = * (struct psf_header *) &inbuf[0];
+
+	    if (!PSF_MAGIC_OK(psfhdr))
+		goto no_psf;
+
+	    if (psfhdr.mode > PSF_MAXMODE) {
+		fprintf(stderr, "Unsupported psf file mode\n");
+		exit(1);
+	    }
+	    fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
+#if !defined( PIO_FONTX ) || defined( sparc )
+	    if (fontsize != 256) {
+		fprintf(stderr, "Only fontsize 256 supported\n");
+		exit(1);
+	    }
+#endif
+	    hastable = (psfhdr.mode & PSF_MODEHASTAB);
+	    unit = psfhdr.charsize;
+	    head0 = sizeof(struct psf_header);
+	    head = head0 + fontsize*unit;
+	    if (head > inputlth || (!hastable && head != inputlth)) {
+		fprintf(stderr, "Input file: bad length\n");
+		exit(1);
+	    }
+	    do_loadfont(fd, inbuf + head0, unit, fontsize);
+	    if (hastable)
+	      do_loadtable(fd, inbuf + head, inputlth-head, fontsize);
+	    return;
+	}
+      no_psf:
+
+	/* file with three code pages? */
+	if (inputlth == 9780) {
+	    offset = 40;
+	    unit = 16;
+	} else {
+	    /* bare font */
+	    if (inputlth & 0377) {
+		fprintf(stderr, "Bad input file size\n");
+		exit(1);
+	    }
+	    offset = 0;
+	    unit = inputlth/256;
+	}
+	do_loadfont(fd, inbuf+offset, unit, 256);
+}
diff --git a/findutils/grep.c b/findutils/grep.c
index 657bb25..de1c820 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -1,17 +1,25 @@
 /*
- * Copyright (c) 1999 by David I. Bell
- * Permission is granted to use, distribute, or modify this source,
- * provided that this copyright notice remains intact.
+ * Mini grep implementation for busybox
  *
- * The "grep" command, taken from sash.
- * This provides basic file searching.
+ * Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
  *
- * Permission to distribute this code under the GPL has been granted.
- * Modified for busybox by Erik Andersen <andersee@debian.org> <andersen@lineo.com>
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
  */
 
 #include "internal.h"
-
 #include <stdio.h>
 #include <dirent.h>
 #include <errno.h>
@@ -22,95 +30,53 @@
 
 
 const char grep_usage[] =
-    "Search the input file(s) for lines matching the given pattern.\n"
-    "\tI search stdin if no files are given.\n"
-    "\tI can't grok full regular expressions.\n"
-    "usage: grep [in] PATTERN [FILES]...\n"
-    "\ti=ignore case, n=list line numbers\n";
-
+"grep [-ihn]... PATTERN [FILE]...\n"
+"Search for PATTERN in each FILE or standard input.\n\n"
+"\t-h\tsuppress the prefixing filename on output\n"
+"\t-i\tignore case distinctions\n"
+"\t-n\tprint line number with output lines\n\n"
+"This version of grep matches strings (not full regexps).\n";
 
 
 /*
- * See if the specified word is found in the specified string.
+ * See if the specified needle is found in the specified haystack.
  */
-static int search (const char *string, const char *word, int ignoreCase)
+static int search (const char *haystack, const char *needle, int ignoreCase)
 {
-    const char *cp1;
-    const char *cp2;
-    int len;
-    int lowFirst;
-    int ch1;
-    int ch2;
 
-    len = strlen (word);
-
-    if (!ignoreCase) {
-	while (TRUE) {
-	    string = strchr (string, word[0]);
-
-	    if (string == NULL)
-		return FALSE;
-
-	    if (memcmp (string, word, len) == 0)
-		return TRUE;
-
-	    string++;
-	}
-    }
-
-    /* 
-     * Here if we need to check case independence.
-     * Do the search by lower casing both strings.
-     */
-    lowFirst = *word;
-
-    if (isupper (lowFirst))
-	lowFirst = tolower (lowFirst);
-
-    while (TRUE) {
-	while (*string && (*string != lowFirst) &&
-	       (!isupper (*string) || (tolower (*string) != lowFirst))) {
-	    string++;
-	}
-
-	if (*string == '\0')
+    if (ignoreCase == FALSE) {
+	haystack = strstr (haystack, needle);
+	if (haystack == NULL)
 	    return FALSE;
+	return TRUE;
+    } else {
+	int i;
+	char needle1[BUF_SIZE];
+	char haystack1[BUF_SIZE];
 
-	cp1 = string;
-	cp2 = word;
-
-	do {
-	    if (*cp2 == '\0')
-		return TRUE;
-
-	    ch1 = *cp1++;
-
-	    if (isupper (ch1))
-		ch1 = tolower (ch1);
-
-	    ch2 = *cp2++;
-
-	    if (isupper (ch2))
-		ch2 = tolower (ch2);
-
-	}
-	while (ch1 == ch2);
-
-	string++;
+	strncpy( haystack1, haystack, sizeof(haystack1));
+	strncpy( needle1, needle, sizeof(needle1));
+	for( i=0; i<sizeof(haystack1) && haystack1[i]; i++)
+	    haystack1[i]=tolower( haystack1[i]);
+	for( i=0; i<sizeof(needle1) && needle1[i]; i++)
+	    needle1[i]=tolower( needle1[i]);
+	haystack = strstr (haystack1, needle1);
+	if (haystack == NULL)
+	    return FALSE;
+	return TRUE;
     }
-    return (TRUE);
 }
 
 
 extern int grep_main (int argc, char **argv)
 {
     FILE *fp;
-    const char *word;
+    const char *needle;
     const char *name;
     const char *cp;
-    int tellName;
-    int ignoreCase;
-    int tellLine;
+    int tellName=TRUE;
+    int ignoreCase=FALSE;
+    int tellLine=FALSE;
     long line;
     char buf[BUF_SIZE];
 
@@ -120,8 +86,7 @@
     argc--;
     argv++;
     if (argc < 1) {
-	fprintf (stderr, "%s", grep_usage);
-	return 1;
+	usage(grep_usage);
     }
 
     if (**argv == '-') {
@@ -134,29 +99,28 @@
 		ignoreCase = TRUE;
 		break;
 
+	    case 'h':
+		tellName = FALSE;
+		break;
+
 	    case 'n':
 		tellLine = TRUE;
 		break;
 
 	    default:
-		fprintf (stderr, "Unknown option\n");
-		return 1;
+		usage(grep_usage);
 	    }
     }
 
-    word = *argv++;
+    needle = *argv++;
     argc--;
 
-    tellName = (argc > 1);
-
     while (argc-- > 0) {
 	name = *argv++;
 
 	fp = fopen (name, "r");
-
 	if (fp == NULL) {
 	    perror (name);
-
 	    continue;
 	}
 
@@ -164,17 +128,16 @@
 
 	while (fgets (buf, sizeof (buf), fp)) {
 	    line++;
-
 	    cp = &buf[strlen (buf) - 1];
 
 	    if (*cp != '\n')
 		fprintf (stderr, "%s: Line too long\n", name);
 
-	    if (search (buf, word, ignoreCase)) {
-		if (tellName)
+	    if (search (buf, needle, ignoreCase)==TRUE) {
+		if (tellName==TRUE)
 		    printf ("%s: ", name);
 
-		if (tellLine)
+		if (tellLine==TRUE)
 		    printf ("%ld: ", line);
 
 		fputs (buf, stdout);
@@ -186,7 +149,7 @@
 
 	fclose (fp);
     }
-    return 0;
+    exit( TRUE);
 }
 
 
diff --git a/grep.c b/grep.c
index 657bb25..de1c820 100644
--- a/grep.c
+++ b/grep.c
@@ -1,17 +1,25 @@
 /*
- * Copyright (c) 1999 by David I. Bell
- * Permission is granted to use, distribute, or modify this source,
- * provided that this copyright notice remains intact.
+ * Mini grep implementation for busybox
  *
- * The "grep" command, taken from sash.
- * This provides basic file searching.
+ * Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
  *
- * Permission to distribute this code under the GPL has been granted.
- * Modified for busybox by Erik Andersen <andersee@debian.org> <andersen@lineo.com>
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
  */
 
 #include "internal.h"
-
 #include <stdio.h>
 #include <dirent.h>
 #include <errno.h>
@@ -22,95 +30,53 @@
 
 
 const char grep_usage[] =
-    "Search the input file(s) for lines matching the given pattern.\n"
-    "\tI search stdin if no files are given.\n"
-    "\tI can't grok full regular expressions.\n"
-    "usage: grep [in] PATTERN [FILES]...\n"
-    "\ti=ignore case, n=list line numbers\n";
-
+"grep [-ihn]... PATTERN [FILE]...\n"
+"Search for PATTERN in each FILE or standard input.\n\n"
+"\t-h\tsuppress the prefixing filename on output\n"
+"\t-i\tignore case distinctions\n"
+"\t-n\tprint line number with output lines\n\n"
+"This version of grep matches strings (not full regexps).\n";
 
 
 /*
- * See if the specified word is found in the specified string.
+ * See if the specified needle is found in the specified haystack.
  */
-static int search (const char *string, const char *word, int ignoreCase)
+static int search (const char *haystack, const char *needle, int ignoreCase)
 {
-    const char *cp1;
-    const char *cp2;
-    int len;
-    int lowFirst;
-    int ch1;
-    int ch2;
 
-    len = strlen (word);
-
-    if (!ignoreCase) {
-	while (TRUE) {
-	    string = strchr (string, word[0]);
-
-	    if (string == NULL)
-		return FALSE;
-
-	    if (memcmp (string, word, len) == 0)
-		return TRUE;
-
-	    string++;
-	}
-    }
-
-    /* 
-     * Here if we need to check case independence.
-     * Do the search by lower casing both strings.
-     */
-    lowFirst = *word;
-
-    if (isupper (lowFirst))
-	lowFirst = tolower (lowFirst);
-
-    while (TRUE) {
-	while (*string && (*string != lowFirst) &&
-	       (!isupper (*string) || (tolower (*string) != lowFirst))) {
-	    string++;
-	}
-
-	if (*string == '\0')
+    if (ignoreCase == FALSE) {
+	haystack = strstr (haystack, needle);
+	if (haystack == NULL)
 	    return FALSE;
+	return TRUE;
+    } else {
+	int i;
+	char needle1[BUF_SIZE];
+	char haystack1[BUF_SIZE];
 
-	cp1 = string;
-	cp2 = word;
-
-	do {
-	    if (*cp2 == '\0')
-		return TRUE;
-
-	    ch1 = *cp1++;
-
-	    if (isupper (ch1))
-		ch1 = tolower (ch1);
-
-	    ch2 = *cp2++;
-
-	    if (isupper (ch2))
-		ch2 = tolower (ch2);
-
-	}
-	while (ch1 == ch2);
-
-	string++;
+	strncpy( haystack1, haystack, sizeof(haystack1));
+	strncpy( needle1, needle, sizeof(needle1));
+	for( i=0; i<sizeof(haystack1) && haystack1[i]; i++)
+	    haystack1[i]=tolower( haystack1[i]);
+	for( i=0; i<sizeof(needle1) && needle1[i]; i++)
+	    needle1[i]=tolower( needle1[i]);
+	haystack = strstr (haystack1, needle1);
+	if (haystack == NULL)
+	    return FALSE;
+	return TRUE;
     }
-    return (TRUE);
 }
 
 
 extern int grep_main (int argc, char **argv)
 {
     FILE *fp;
-    const char *word;
+    const char *needle;
     const char *name;
     const char *cp;
-    int tellName;
-    int ignoreCase;
-    int tellLine;
+    int tellName=TRUE;
+    int ignoreCase=FALSE;
+    int tellLine=FALSE;
     long line;
     char buf[BUF_SIZE];
 
@@ -120,8 +86,7 @@
     argc--;
     argv++;
     if (argc < 1) {
-	fprintf (stderr, "%s", grep_usage);
-	return 1;
+	usage(grep_usage);
     }
 
     if (**argv == '-') {
@@ -134,29 +99,28 @@
 		ignoreCase = TRUE;
 		break;
 
+	    case 'h':
+		tellName = FALSE;
+		break;
+
 	    case 'n':
 		tellLine = TRUE;
 		break;
 
 	    default:
-		fprintf (stderr, "Unknown option\n");
-		return 1;
+		usage(grep_usage);
 	    }
     }
 
-    word = *argv++;
+    needle = *argv++;
     argc--;
 
-    tellName = (argc > 1);
-
     while (argc-- > 0) {
 	name = *argv++;
 
 	fp = fopen (name, "r");
-
 	if (fp == NULL) {
 	    perror (name);
-
 	    continue;
 	}
 
@@ -164,17 +128,16 @@
 
 	while (fgets (buf, sizeof (buf), fp)) {
 	    line++;
-
 	    cp = &buf[strlen (buf) - 1];
 
 	    if (*cp != '\n')
 		fprintf (stderr, "%s: Line too long\n", name);
 
-	    if (search (buf, word, ignoreCase)) {
-		if (tellName)
+	    if (search (buf, needle, ignoreCase)==TRUE) {
+		if (tellName==TRUE)
 		    printf ("%s: ", name);
 
-		if (tellLine)
+		if (tellLine==TRUE)
 		    printf ("%ld: ", line);
 
 		fputs (buf, stdout);
@@ -186,7 +149,7 @@
 
 	fclose (fp);
     }
-    return 0;
+    exit( TRUE);
 }
 
 
diff --git a/internal.h b/internal.h
index a77ac38..8bf9c3e 100644
--- a/internal.h
+++ b/internal.h
@@ -76,6 +76,7 @@
 extern int kill_main(int argc, char** argv);
 extern int length_main(int argc, char** argv);
 extern int ln_main(int argc, char** argv);
+extern int loadfont_main(int argc, char** argv);
 extern int loadkmap_main(int argc, char** argv);
 extern int losetup_main(int argc, char** argv);
 extern int ls_main(int argc, char** argv);
diff --git a/loadfont.c b/loadfont.c
new file mode 100644
index 0000000..a10fa8a
--- /dev/null
+++ b/loadfont.c
@@ -0,0 +1,234 @@
+/*
+ * loadfont.c - Eugene Crosser & Andries Brouwer
+ *
+ * Version 0.96bb
+ *
+ * Loads the console font, and possibly the corresponding screen map(s).
+ * (Adapted for busybox by Matej Vela.)
+ */
+#include "internal.h"
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <memory.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <sys/kd.h>
+#include <endian.h>
+
+#define PSF_MAGIC1	0x36
+#define PSF_MAGIC2	0x04
+
+#define PSF_MODE512    0x01
+#define PSF_MODEHASTAB 0x02
+#define PSF_MAXMODE    0x03
+#define PSF_SEPARATOR  0xFFFF
+
+static const char loadfont_usage[] = "loadfont\n"
+"\n"
+"\tLoad a console font from standard input.\n"
+"\n";
+
+struct psf_header
+{
+  unsigned char magic1, magic2;	/* Magic number */
+  unsigned char mode;		/* PSF font mode */
+  unsigned char charsize;	/* Character size */
+};
+
+#define PSF_MAGIC_OK(x)	((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
+
+static void loadnewfont(int fd);
+
+extern int
+loadfont_main(int argc, char **argv)
+{
+	int fd;
+
+	fd = open("/dev/tty0", O_RDWR);
+	if (fd < 0) {
+	    fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
+	    return 1;
+	}
+	loadnewfont(fd);
+
+	return 0;
+}
+
+static void
+do_loadfont(int fd, char *inbuf, int unit, int fontsize) {
+	char buf[16384];
+	int i;
+
+	memset(buf,0,sizeof(buf));
+
+	if (unit < 1 || unit > 32) {
+	    fprintf(stderr, "Bad character size %d\n", unit);
+	    exit(1);
+	}
+
+	for (i = 0; i < fontsize; i++)
+	    memcpy(buf+(32*i), inbuf+(unit*i), unit);
+
+#if defined( PIO_FONTX ) && !defined( sparc )
+	{
+	    struct consolefontdesc cfd;
+
+	    cfd.charcount = fontsize;
+	    cfd.charheight = unit;
+	    cfd.chardata = buf;
+
+	    if (ioctl(fd, PIO_FONTX, &cfd) == 0)
+	      return;		/* success */
+	    perror("PIO_FONTX ioctl error (trying PIO_FONT)");
+	}
+#endif
+	if (ioctl(fd, PIO_FONT, buf)) {
+	    perror("PIO_FONT ioctl error");
+	    exit(1);
+	}
+}
+
+static void
+do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) {
+	struct unimapinit advice;
+	struct unimapdesc ud;
+	struct unipair *up;
+	int ct = 0, maxct;
+	int glyph;
+	u_short unicode;
+
+	maxct = tailsz;		/* more than enough */
+	up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
+	if (!up) {
+	    fprintf(stderr, "Out of memory?\n");
+	    exit(1);
+	}
+	for (glyph = 0; glyph < fontsize; glyph++) {
+	    while (tailsz >= 2) {
+		unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
+		tailsz -= 2;
+		inbuf += 2;
+		if (unicode == PSF_SEPARATOR)
+		    break;
+		up[ct].unicode = unicode;
+		up[ct].fontpos = glyph;
+		ct++;
+	    }
+	}
+
+	/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
+	   this printf did not work on many kernels */
+
+	advice.advised_hashsize = 0;
+	advice.advised_hashstep = 0;
+	advice.advised_hashlevel = 0;
+	if(ioctl(fd, PIO_UNIMAPCLR, &advice)) {
+#ifdef ENOIOCTLCMD
+	    if (errno == ENOIOCTLCMD) {
+		fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
+		fprintf(stderr, "No Unicode mapping table loaded.\n");
+	    } else
+#endif
+	      perror("PIO_UNIMAPCLR");
+	    exit(1);
+	}
+	ud.entry_ct = ct;
+	ud.entries = up;
+	if(ioctl(fd, PIO_UNIMAP, &ud)) {
+#if 0
+	    if (errno == ENOMEM) {
+		/* change advice parameters */
+	    }
+#endif
+	    perror("PIO_UNIMAP");
+	    exit(1);
+	}
+}
+
+static void
+loadnewfont(int fd) {
+	int unit;
+	char inbuf[32768];	/* primitive */
+	int inputlth, offset;
+
+	/*
+	 * We used to look at the length of the input file
+	 * with stat(); now that we accept compressed files,
+	 * just read the entire file.
+	 */
+	inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
+	if (ferror(stdin)) {
+		perror("Error reading input font");
+		exit(1);
+	}
+	/* use malloc/realloc in case of giant files;
+	   maybe these do not occur: 16kB for the font,
+	   and 16kB for the map leaves 32 unicode values
+	   for each font position */
+	if (!feof(stdin)) {
+		perror("Font too large");
+		exit(1);
+	}
+
+	/* test for psf first */
+	{
+	    struct psf_header psfhdr;
+	    int fontsize;
+	    int hastable;
+	    int head0, head;
+
+	    if (inputlth < sizeof(struct psf_header))
+		goto no_psf;
+
+	    psfhdr = * (struct psf_header *) &inbuf[0];
+
+	    if (!PSF_MAGIC_OK(psfhdr))
+		goto no_psf;
+
+	    if (psfhdr.mode > PSF_MAXMODE) {
+		fprintf(stderr, "Unsupported psf file mode\n");
+		exit(1);
+	    }
+	    fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
+#if !defined( PIO_FONTX ) || defined( sparc )
+	    if (fontsize != 256) {
+		fprintf(stderr, "Only fontsize 256 supported\n");
+		exit(1);
+	    }
+#endif
+	    hastable = (psfhdr.mode & PSF_MODEHASTAB);
+	    unit = psfhdr.charsize;
+	    head0 = sizeof(struct psf_header);
+	    head = head0 + fontsize*unit;
+	    if (head > inputlth || (!hastable && head != inputlth)) {
+		fprintf(stderr, "Input file: bad length\n");
+		exit(1);
+	    }
+	    do_loadfont(fd, inbuf + head0, unit, fontsize);
+	    if (hastable)
+	      do_loadtable(fd, inbuf + head, inputlth-head, fontsize);
+	    return;
+	}
+      no_psf:
+
+	/* file with three code pages? */
+	if (inputlth == 9780) {
+	    offset = 40;
+	    unit = 16;
+	} else {
+	    /* bare font */
+	    if (inputlth & 0377) {
+		fprintf(stderr, "Bad input file size\n");
+		exit(1);
+	    }
+	    offset = 0;
+	    unit = inputlth/256;
+	}
+	do_loadfont(fd, inbuf+offset, unit, 256);
+}
