patch-2.1.35 linux/arch/i386/boot/compressed/xtract.c
Next file: linux/arch/i386/boot/setup.S
Previous file: linux/arch/i386/boot/compressed/piggyback.c
Back to the patch index
Back to the overall index
- Lines: 87
- Date:
Wed Dec 31 16:00:00 1969
- Orig file:
v2.1.34/linux/arch/i386/boot/compressed/xtract.c
- Orig date:
Thu Jan 5 03:55:40 1995
diff -u --recursive --new-file v2.1.34/linux/arch/i386/boot/compressed/xtract.c linux/arch/i386/boot/compressed/xtract.c
@@ -1,86 +0,0 @@
-/*
- * linux/zBoot/xtract.c
- *
- * Copyright (C) 1993 Hannu Savolainen
- *
- * Extracts the system image and writes it to the stdout.
- * based on tools/build.c by Linus Torvalds
- */
-
-#include <stdio.h> /* fprintf */
-#include <string.h>
-#include <stdlib.h> /* contains exit */
-#include <sys/types.h> /* unistd.h needs this */
-#include <sys/stat.h>
-#include <sys/sysmacros.h>
-#include <unistd.h> /* contains read/write */
-#include <fcntl.h>
-#include <a.out.h>
-
-#define N_MAGIC_OFFSET 1024
-
-static int GCC_HEADER = sizeof(struct exec);
-
-#define STRINGIFY(x) #x
-
-void die(char * str)
-{
- fprintf(stderr,"%s\n",str);
- exit(1);
-}
-
-void usage(void)
-{
- die("Usage: xtract system [ | gzip | piggyback > piggy.s]");
-}
-
-int main(int argc, char ** argv)
-{
- int i,c,id, sz;
- char buf[1024];
- char major_root, minor_root;
- struct stat sb;
-
- struct exec *ex = (struct exec *)buf;
-
- if (argc != 2)
- usage();
-
- if ((id=open(argv[1],O_RDONLY,0))<0)
- die("Unable to open 'system'");
- if (read(id,buf,GCC_HEADER) != GCC_HEADER)
- die("Unable to read header of 'system'");
- if (N_MAGIC(*ex) == ZMAGIC) {
- GCC_HEADER = N_MAGIC_OFFSET;
- lseek(id, GCC_HEADER, SEEK_SET);
- } else if (N_MAGIC(*ex) != QMAGIC)
- die("Non-GCC header of 'system'");
-
- sz = N_SYMOFF(*ex) - GCC_HEADER + 4; /* +4 to get the same result than tools/build */
-
- fprintf(stderr, "System size is %d\n", sz);
-
- while (sz)
- {
- int l, n;
-
- l = sz;
- if (l > sizeof(buf)) l = sizeof(buf);
-
- if ((n=read(id, buf, l)) !=l)
- {
- if (n == -1)
- perror(argv[1]);
- else
- fprintf(stderr, "Unexpected EOF\n");
-
- die("Can't read system");
- }
-
- write(1, buf, l);
- sz -= l;
- }
-
- close(id);
- return(0);
-}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov