From 477ef2a43902f79f5c96a284a9c98e6e8f66a441 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 10 Mar 2012 09:57:49 +0100 Subject: [PATCH] Remove the old (and broken) kzip(8) utility. --- Makefile_upgrade.inc | 3 + usr.bin/Makefile | 1 - usr.bin/kzip/Makefile | 8 - usr.bin/kzip/kzip.8 | 80 ---------- usr.bin/kzip/kzip.c | 336 ------------------------------------------ 5 files changed, 3 insertions(+), 425 deletions(-) delete mode 100644 usr.bin/kzip/Makefile delete mode 100644 usr.bin/kzip/kzip.8 delete mode 100644 usr.bin/kzip/kzip.c diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index 19a1167101..66fdd823b0 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -1981,6 +1981,9 @@ TO_REMOVE+=/usr/share/man/cat4/bfq.4.gz TO_REMOVE+=/usr/share/man/man4/bfq.4.gz TO_REMOVE+=/usr/include/bus/pci/dc21040reg.h TO_REMOVE+=/usr/lib/profile/libtinfo.aa +TO_REMOVE+=/usr/bin/kzip +TO_REMOVE+=/usr/share/man/cat8/kzip.8.gz +TO_REMOVE+=/usr/share/man/man8/kzip.8.gz .if ${MACHINE_ARCH} == "x86_64" TO_REMOVE+=/usr/libdata/stallion/2681.sys diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 35bebcdec8..62e973ec94 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -92,7 +92,6 @@ SUBDIR= alias \ killall \ ktrace \ ktrdump \ - kzip \ lam \ last \ lastcomm \ diff --git a/usr.bin/kzip/Makefile b/usr.bin/kzip/Makefile deleted file mode 100644 index 2e4a73fec9..0000000000 --- a/usr.bin/kzip/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $FreeBSD: src/usr.bin/kzip/Makefile,v 1.6.2.1 2001/04/25 11:29:25 ru Exp $ -# $DragonFly: src/usr.bin/kzip/Makefile,v 1.3 2007/08/27 16:50:55 pavalos Exp $ - -PROG= kzip -MAN= kzip.8 -WARNS?= 2 - -.include diff --git a/usr.bin/kzip/kzip.8 b/usr.bin/kzip/kzip.8 deleted file mode 100644 index c421e31710..0000000000 --- a/usr.bin/kzip/kzip.8 +++ /dev/null @@ -1,80 +0,0 @@ -.\" -.\" Copyright (c) 1996 David E. O'Brien -.\" -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD: src/usr.bin/kzip/kzip.8,v 1.7.2.1 2000/12/27 13:50:36 ru Exp $ -.\" -.Dd August 15, 1996 -.Dt KZIP 8 -.Os -.Sh NAME -.Nm kzip -.Nd compresses kernels -.Sh SYNOPSIS -.Nm -.Op Fl v -.Op Fl l Ar loadaddr -.Ar kernel -.Sh DESCRIPTION -This program compresses a kernel using -.Xr gzip 1 -to reduce its disk storage requirements. -It does not reduce the memory footprint once loaded into memory. -You lose all the symbols, so usability is limited. -Its main usage is making kernels for install and fixit floppies, etc. -.Pp -The following options are available: -.Bl -tag -width flag -.It Fl v -Verbose mode, reports how much memory is being used by the kernel -after compression. Also allows you to check to make sure your kernel -is not going past the 4MB boundary. -.It Fl l Ar loadaddr -Specify the address to load the kernel into memory at. -.El -.Sh DIAGNOSTICS -The -.Nm -utility returns with exit code 1 if given invalid arguments. -Exit code two means -.Nm -was unable to read or process the kernel file. -.Sh SEE ALSO -.Xr gzip 1 -.\" .Sh STANDARDS -.Sh HISTORY -The -.Nm -command appeared in -.Fx 2.0.5 . -Obtained from Linux via -.Bx 386 --- based on tools/build.c by Linus Torvalds, -and ported to -.Bx 386 -by Serge Vakulenko. -.Sh AUTHORS -This man page was written by -.An David E. O'Brien . -.\" .Sh BUGS diff --git a/usr.bin/kzip/kzip.c b/usr.bin/kzip/kzip.c deleted file mode 100644 index 2c213de1cb..0000000000 --- a/usr.bin/kzip/kzip.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * Copyright (C) 1993 Hannu Savolainen - * Ported to 386bsd by Serge Vakulenko - * based on tools/build.c by Linus Torvalds - * - * $FreeBSD: src/usr.bin/kzip/kzip.c,v 1.13.2.2 2000/07/20 10:35:20 kris Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * This is the limit because a kzip'ed kernel loads at 3Mb and - * ends up at 1Mb - */ -#define MAXIMAGE (2*1024*1024) - -static char string_names[] = {"_input_data\0_input_len\0"}; - -static struct nlist var_names[2] = { /* Symbol table */ - { { (char*) 4 }, N_EXT|N_TEXT, 0, 0, 0 }, /* _input_data */ - { { (char*) 16 }, N_EXT|N_TEXT, 0, 0, 0 }, /* _input_len */ -}; - -static int -extract(char *file) -{ - int sz; - char buf[BUFSIZ]; - struct exec hdr; - - if (read(0, (char *)&hdr, sizeof(hdr)) != sizeof(hdr)) - err(2, "%s", file); - if (hdr.a_magic != ZMAGIC) - errx(2, "bad magic in file %s, probably not a kernel", file); - if (lseek(0, N_TXTOFF(hdr), 0) < 0) - err(2, "%s", file); - - sz = N_SYMOFF(hdr) - N_TXTOFF(hdr); - - while (sz) { - size_t l; - ssize_t n; - - l = sz; - if (l > sizeof(buf)) - l = sizeof(buf); - - n = read(0, buf, l); - if (n != l) { - if (n == -1) - err(1, "%s", file); - else - errx(1, "unexpected EOF"); - } - - write(1, buf, l); - sz -= l; - } - exit(0); -} - -static int -piggyback(char *file) -{ - int n, len; - struct exec hdr; /* object header */ - char image[MAXIMAGE]; /* kernel image buffer */ - - len = 0; - while ((n = read(0, &image[len], sizeof(image)-len+1)) > 0) - len += n; - - if (n < 0) - err(1, "stdin"); - - if (len >= sizeof(image)) - errx(1, "input too large"); - - /* - * Output object header - */ - memset(&hdr,0,sizeof hdr); - hdr.a_magic = OMAGIC; - hdr.a_text = len + sizeof(long); - hdr.a_syms = sizeof(var_names); - write(1, (char *)&hdr, sizeof(hdr)); - - /* - * Output text segment (compressed system & len) - */ - write(1, image, len); - write(1, (char *)&len, sizeof(len)); - - /* - * Output symbol table - */ - var_names[1].n_value = len; - write(1, (char *)&var_names, sizeof(var_names)); - - /* - * Output string table - */ - len = sizeof(string_names) + sizeof(len); - write(1, (char *)&len, sizeof(len)); - write(1, string_names, sizeof(string_names)); - - return (0); -} - -static void -usage(void) -{ - fprintf(stderr, "usage: kzip [-v] [ -l loadaddr] kernel\n"); - exit(1); -} - -int -main(int argc, char **argv) -{ - pid_t Pext, Pgzip, Ppiggy, Pld; - int pipe1[2], pipe2[2]; - int status, fdi, fdo, fdn, c, verbose; - int size; - struct exec hdr; - int zip_size, offset; - struct stat st; - u_long forceaddr = 0, entry; - char *kernname; - char obj[MAXPATHLEN + 1]; - char out[MAXPATHLEN + 1]; - char base[32]; - - while ((c = getopt(argc, argv, "l:v")) != -1) { - switch (c) { - case 'l': - forceaddr = strtoul(optarg, NULL, 0); - if (forceaddr == 0) - errx(1, "invalid load address"); - break; - case 'v': - verbose++; - break; - default: - usage(); - } - } - - if ((argc - optind) != 1) - usage(); - - argc -= optind; - argv += optind; - - kernname = argv[0]; - - if (strlen(kernname) > MAXPATHLEN - 3) - errx(1, "%s: File name too long", kernname); - strcpy(obj, kernname); strcat(obj,".o"); - strcpy(out, kernname); strcat(out,".kz"); - - fdi = open(kernname ,O_RDONLY); - if(fdi<0) { - warn("%s", kernname); - return 2; - } - - /* figure out how big the uncompressed image will be */ - if (read(fdi, (char *)&hdr, sizeof(hdr)) != sizeof(hdr)) - err(2, "%s", argv[1]); - - size = hdr.a_text + hdr.a_data + hdr.a_bss; - entry = hdr.a_entry & 0x00FFFFFF; - - lseek(fdi, 0, SEEK_SET); - - if (verbose) { - printf("real kernel start address will be: 0x%lx\n", entry); - printf("real kernel end address will be: 0x%lx\n", entry+size); - } - - - fdo = open(obj,O_WRONLY|O_TRUNC|O_CREAT,0666); - if(fdo<0) { - warn("%s", obj); - return 2; - } - - if (pipe(pipe1) < 0) { perror("pipe()"); return 1; } - - if (pipe(pipe2) < 0) { perror("pipe()"); return 1; } - - Pext = fork(); - if (Pext < 0) { perror("fork()"); return 1; } - if (!Pext) { - dup2(fdi,0); - dup2(pipe1[1],1); - close(pipe1[0]); close(pipe1[1]); - close(pipe2[0]); close(pipe2[1]); - close(fdi); close(fdo); - extract(kernname); - exit(0); - } - - Pgzip = fork(); - if (Pgzip < 0) { perror("fork()"); return 1; } - if (!Pgzip) { - dup2(pipe1[0],0); - dup2(pipe2[1],1); - close(pipe1[0]); close(pipe1[1]); - close(pipe2[0]); close(pipe2[1]); - close(fdi); close(fdo); - execlp("gzip", "gzip", "-9", "-n", NULL); - exit(0); - } - - Ppiggy = fork(); - if (Ppiggy < 0) { warn("fork()"); return 1; } - if (!Ppiggy) { - dup2(pipe2[0],0); - dup2(fdo,1); - close(pipe1[0]); close(pipe1[1]); - close(pipe2[0]); close(pipe2[1]); - close(fdi); close(fdo); - piggyback(obj); - exit(0); - } - - close(pipe1[0]); close(pipe1[1]); - close(pipe2[0]); close(pipe2[1]); - close(fdi); close(fdo); - - if (waitpid(Pext, &status,0) < 0) - { warn("waitpid(Pextract)"); return 1; } - - if(status) { - warnx("extract returned %x",status); - return 3; - } - - if (waitpid(Pgzip, &status,0) < 0) - { perror("waitpid(Pgzip)"); return 1; } - - if(status) { - warnx("gzip returned %x",status); - return 3; - } - - if (waitpid(Ppiggy, &status,0) < 0) - { warn("waitpid(Ppiggy)"); return 1; } - - if(status) { - warnx("piggyback returned %x",status); - return 3; - } - - if (forceaddr) - offset = forceaddr; - else { - /* a kludge to dynamically figure out where to start it */ - if (stat(obj, &st) < 0) { - warn("cannot get size of compressed data"); - return 3; - } - zip_size = (int)st.st_size; - offset = entry + size - zip_size + 0x8000; /* fudge factor */ - } - sprintf(base, "0x%x", roundup(offset, 4096)); - - Pld = fork(); - if (Pld < 0) { warn("fork()"); return 1; } - if (!Pld) { - execlp("ld", - "ld", - "-aout", - "-Bstatic", - "-Z", - "-T", - base, - "-o", - out, - "/usr/lib/aout/kzhead.o", - obj, - "/usr/lib/aout/kztail.o", - NULL); - exit(2); - } - - if (waitpid(Pld, &status,0) < 0) - { warn("waitpid(Pld)"); return 1; } - - if(status) { - warnx("ld returned %x",status); - return 3; - } - - if (verbose) { - - fdn = open(obj ,O_RDONLY); - if(fdn<0) { - warn("%s", obj); - return 3; - } - - /* figure out how big the compressed image is */ - if (read(fdn, (char *)&hdr, sizeof(hdr)) != sizeof(hdr)) { - warn("%s", obj); - return 3; - } - close(fdn); - - size = hdr.a_text + hdr.a_data + hdr.a_bss; - - printf("kzip data start address will be: 0x%x\n",offset); - printf("kzip data end address will be: 0x%x\n",offset+size); - } - - unlink(obj); - exit(0); -} -- 2.41.0