First stage of getting imgact_gzip reentrant:

1) cut this up into /sys/sys/inflate.h, sys/kern/inflate.c
sys/kern/ingact_gzip.c
2) make a lot more things static
3) make a lot of globals const
4) make some args const
5) first stage of making globals into a struct (not used yet)

The vm_allocate() call which was introduced between revisions 1.4 and
1.5 of imagact_gzip.c broke things.  I have backed that out for the time
being.  (Davidg: help please)

WARNING: if you have gzip enabled in your kernel, you must now run
config again, as another source file has been added.  Otherwise your
kernel compile will fall over.

This is all still WIP.  More commits to come.

Suggestions from: phk.
This commit is contained in:
Geoff Rehmet 1994-10-07 22:27:00 +00:00
parent 26dc463449
commit ee38c19853
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3417
4 changed files with 1319 additions and 1211 deletions

View File

@ -37,6 +37,7 @@ kdb/kdb_sym.c optional kadb
kdb/kdb_trap.c optional kadb
kern/imgact_aout.c standard
kern/imgact_gzip.c optional gzip
kern/inflate.c optional gzip
kern/imgact_shell.c standard
kern/init_main.c standard
kern/init_sysent.c standard

File diff suppressed because it is too large Load Diff

1228
sys/kern/inflate.c Normal file

File diff suppressed because it is too large Load Diff

81
sys/sys/inflate.h Normal file
View File

@ -0,0 +1,81 @@
/*
* Parts of this file are not covered by:
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@login.dknet.dk> 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
* ----------------------------------------------------------------------------
*
* $Id: imgact_gzip.c,v 1.4 1994/10/04 06:51:42 phk Exp $
*
* This module handles execution of a.out files which have been run through
* "gzip -9".
*
* For now you need to use exactly this command to compress the binaries:
*
* gzip -9 -v < /bin/sh > /tmp/sh
*
* TODO:
* text-segments should be made R/O after being filled
* is the vm-stuff safe ?
* should handle the entire header of gzip'ed stuff.
* inflate isn't quite reentrant yet...
* error-handling is a mess...
* so is the rest...
* tidy up unnecessary includes
*/
#ifndef _SYS_INFLATE_H_
#define _SYS_INFLATE_H_
#ifdef KERNEL
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/resourcevar.h>
#include <sys/exec.h>
#include <sys/mman.h>
#include <sys/malloc.h>
#include <sys/imgact.h>
#include <sys/imgact_aout.h>
#include <sys/kernel.h>
#include <sys/sysent.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#define WSIZE 0x8000
struct gzip {
struct image_params *ip;
struct exec a_out;
int error;
int where;
u_char *inbuf;
u_long offset;
u_long output;
u_long len;
int idx;
u_long virtual_offset, file_offset, file_end, bss_size;
unsigned gz_wp;
u_char *gz_slide;
};
/*
* Global variables used by inflate and friends.
* This structure is used in order to make inflate() reentrant.
*/
struct gz_global {
int foo;
};
int inflate __P((struct gzip *, struct gz_global *));
#define slide (gz->gz_slide)
#define wp (gz->gz_wp)
#endif /* KERNEL */
#endif /* ! _SYS_INFLATE_H_ */