2005-01-06 23:35:40 +00:00
|
|
|
/*-
|
2017-11-30 20:33:45 +00:00
|
|
|
* SPDX-License-Identifier: Beerware
|
|
|
|
*
|
1994-10-03 05:23:01 +00:00
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
2002-03-25 13:52:45 +00:00
|
|
|
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
|
1994-10-03 05:23:01 +00:00
|
|
|
* 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
|
|
|
|
* ----------------------------------------------------------------------------
|
2005-01-06 23:35:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1994-10-03 05:23:01 +00:00
|
|
|
* This module handles execution of a.out files which have been run through
|
1994-10-22 11:40:38 +00:00
|
|
|
* "gzip". This saves diskspace, but wastes cpu-cycles and VM.
|
1994-10-03 05:23:01 +00:00
|
|
|
*
|
|
|
|
* 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...
|
2013-04-17 11:42:40 +00:00
|
|
|
* tidy up unnecessary includes
|
1994-10-03 05:23:01 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-11 00:56:59 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1994-10-22 11:40:38 +00:00
|
|
|
#include <sys/param.h>
|
1994-10-03 05:23:01 +00:00
|
|
|
#include <sys/exec.h>
|
|
|
|
#include <sys/imgact.h>
|
|
|
|
#include <sys/imgact_aout.h>
|
|
|
|
#include <sys/kernel.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lock.h>
|
1994-10-11 11:29:17 +00:00
|
|
|
#include <sys/mman.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/mutex.h>
|
1996-05-01 02:43:13 +00:00
|
|
|
#include <sys/proc.h>
|
2011-04-05 20:23:59 +00:00
|
|
|
#include <sys/racct.h>
|
1994-10-11 11:29:17 +00:00
|
|
|
#include <sys/resourcevar.h>
|
1994-10-03 05:23:01 +00:00
|
|
|
#include <sys/sysent.h>
|
1994-10-11 11:29:17 +00:00
|
|
|
#include <sys/systm.h>
|
1996-05-01 02:43:13 +00:00
|
|
|
#include <sys/vnode.h>
|
1994-10-22 11:40:38 +00:00
|
|
|
#include <sys/inflate.h>
|
1994-10-03 05:23:01 +00:00
|
|
|
|
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/vm_param.h>
|
|
|
|
#include <vm/pmap.h>
|
|
|
|
#include <vm/vm_map.h>
|
1994-10-03 05:23:01 +00:00
|
|
|
#include <vm/vm_kern.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/vm_extern.h>
|
1994-10-03 05:23:01 +00:00
|
|
|
|
1994-10-22 11:40:38 +00:00
|
|
|
struct imgact_gzip {
|
|
|
|
struct image_params *ip;
|
|
|
|
struct exec a_out;
|
|
|
|
int error;
|
1999-06-21 16:23:13 +00:00
|
|
|
int gotheader;
|
1994-10-22 11:40:38 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2002-03-19 21:25:46 +00:00
|
|
|
static int exec_gzip_imgact(struct image_params *imgp);
|
|
|
|
static int NextByte(void *vp);
|
|
|
|
static int do_aout_hdr(struct imgact_gzip *);
|
|
|
|
static int Flush(void *vp, u_char *, u_long siz);
|
1994-10-22 11:40:38 +00:00
|
|
|
|
1995-12-02 16:32:03 +00:00
|
|
|
static int
|
2018-03-12 15:45:50 +00:00
|
|
|
exec_gzip_imgact(struct image_params *imgp)
|
1994-10-03 05:23:01 +00:00
|
|
|
{
|
2012-02-17 23:47:16 +00:00
|
|
|
int error;
|
1996-08-31 16:52:44 +00:00
|
|
|
const u_char *p = (const u_char *) imgp->image_header;
|
1994-10-22 11:40:38 +00:00
|
|
|
struct imgact_gzip igz;
|
|
|
|
struct inflate infl;
|
1996-08-01 22:00:14 +00:00
|
|
|
struct vmspace *vmspace;
|
1994-10-03 05:23:01 +00:00
|
|
|
|
1994-10-04 03:09:13 +00:00
|
|
|
/* If these four are not OK, it isn't a gzip file */
|
1994-10-22 11:40:38 +00:00
|
|
|
if (p[0] != 0x1f)
|
|
|
|
return -1; /* 0 Simply magic */
|
|
|
|
if (p[1] != 0x8b)
|
|
|
|
return -1; /* 1 Simply magic */
|
|
|
|
if (p[2] != 0x08)
|
|
|
|
return -1; /* 2 Compression method */
|
|
|
|
if (p[9] != 0x03)
|
|
|
|
return -1; /* 9 OS compressed on */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this one contains anything but a comment or a filename marker,
|
|
|
|
* we don't want to chew on it
|
1994-10-04 03:09:13 +00:00
|
|
|
*/
|
1994-10-22 11:40:38 +00:00
|
|
|
if (p[3] & ~(0x18))
|
|
|
|
return ENOEXEC; /* 3 Flags */
|
1994-10-04 03:09:13 +00:00
|
|
|
|
|
|
|
/* These are of no use to us */
|
1994-10-22 11:40:38 +00:00
|
|
|
/* 4-7 Timestamp */
|
|
|
|
/* 8 Extra flags */
|
|
|
|
|
|
|
|
bzero(&igz, sizeof igz);
|
|
|
|
bzero(&infl, sizeof infl);
|
|
|
|
infl.gz_private = (void *) &igz;
|
|
|
|
infl.gz_input = NextByte;
|
|
|
|
infl.gz_output = Flush;
|
|
|
|
|
1995-11-06 12:52:37 +00:00
|
|
|
igz.ip = imgp;
|
1994-10-22 11:40:38 +00:00
|
|
|
igz.idx = 10;
|
|
|
|
|
|
|
|
if (p[3] & 0x08) { /* skip a filename */
|
|
|
|
while (p[igz.idx++])
|
|
|
|
if (igz.idx >= PAGE_SIZE)
|
|
|
|
return ENOEXEC;
|
1994-10-04 03:09:13 +00:00
|
|
|
}
|
1994-10-22 11:40:38 +00:00
|
|
|
if (p[3] & 0x10) { /* skip a comment */
|
|
|
|
while (p[igz.idx++])
|
|
|
|
if (igz.idx >= PAGE_SIZE)
|
|
|
|
return ENOEXEC;
|
1994-10-04 03:09:13 +00:00
|
|
|
}
|
1996-08-01 22:00:14 +00:00
|
|
|
igz.len = imgp->attr->va_size;
|
1994-10-04 03:09:13 +00:00
|
|
|
|
1994-10-22 11:40:38 +00:00
|
|
|
error = inflate(&infl);
|
1994-10-04 03:09:13 +00:00
|
|
|
|
1999-06-21 16:23:13 +00:00
|
|
|
/*
|
|
|
|
* The unzipped file may not even have been long enough to contain
|
|
|
|
* a header giving Flush() a chance to return error. Check for this.
|
|
|
|
*/
|
|
|
|
if ( !igz.gotheader )
|
|
|
|
return ENOEXEC;
|
|
|
|
|
1996-08-01 22:00:14 +00:00
|
|
|
if ( !error ) {
|
|
|
|
vmspace = imgp->proc->p_vmspace;
|
|
|
|
error = vm_map_protect(&vmspace->vm_map,
|
|
|
|
(vm_offset_t) vmspace->vm_taddr,
|
|
|
|
(vm_offset_t) (vmspace->vm_taddr +
|
|
|
|
(vmspace->vm_tsize << PAGE_SHIFT)) ,
|
|
|
|
VM_PROT_READ|VM_PROT_EXECUTE,0);
|
|
|
|
}
|
|
|
|
|
2012-02-17 23:47:16 +00:00
|
|
|
if (igz.inbuf)
|
2013-08-07 06:21:20 +00:00
|
|
|
kmap_free_wakeup(exec_map, (vm_offset_t)igz.inbuf, PAGE_SIZE);
|
2012-02-17 23:47:16 +00:00
|
|
|
if (igz.error || error) {
|
1994-10-22 11:40:38 +00:00
|
|
|
printf("Output=%lu ", igz.output);
|
2012-02-17 23:47:16 +00:00
|
|
|
printf("Inflate_error=%d igz.error=%d where=%d\n",
|
|
|
|
error, igz.error, igz.where);
|
1994-10-04 03:09:13 +00:00
|
|
|
}
|
1994-10-22 11:40:38 +00:00
|
|
|
if (igz.error)
|
|
|
|
return igz.error;
|
|
|
|
if (error)
|
|
|
|
return ENOEXEC;
|
|
|
|
return 0;
|
1994-10-03 05:23:01 +00:00
|
|
|
}
|
|
|
|
|
1994-10-22 11:40:38 +00:00
|
|
|
static int
|
|
|
|
do_aout_hdr(struct imgact_gzip * gz)
|
1994-10-03 05:23:01 +00:00
|
|
|
{
|
1994-10-22 11:40:38 +00:00
|
|
|
int error;
|
1997-04-13 01:48:35 +00:00
|
|
|
struct vmspace *vmspace;
|
1996-03-19 15:03:00 +00:00
|
|
|
vm_offset_t vmaddr;
|
1994-10-22 11:40:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set file/virtual offset based on a.out variant. We do two cases:
|
|
|
|
* host byte order and network byte order (for NetBSD compatibility)
|
|
|
|
*/
|
2012-06-28 07:33:43 +00:00
|
|
|
switch ((int) (gz->a_out.a_midmag & 0xffff)) {
|
1994-10-03 05:23:01 +00:00
|
|
|
case ZMAGIC:
|
1994-10-22 11:40:38 +00:00
|
|
|
gz->virtual_offset = 0;
|
|
|
|
if (gz->a_out.a_text) {
|
1996-05-02 10:43:17 +00:00
|
|
|
gz->file_offset = PAGE_SIZE;
|
1994-10-22 11:40:38 +00:00
|
|
|
} else {
|
|
|
|
/* Bill's "screwball mode" */
|
|
|
|
gz->file_offset = 0;
|
|
|
|
}
|
|
|
|
break;
|
1994-10-03 05:23:01 +00:00
|
|
|
case QMAGIC:
|
1996-05-02 10:43:17 +00:00
|
|
|
gz->virtual_offset = PAGE_SIZE;
|
1994-10-22 11:40:38 +00:00
|
|
|
gz->file_offset = 0;
|
|
|
|
break;
|
1994-10-03 05:23:01 +00:00
|
|
|
default:
|
1994-10-22 11:40:38 +00:00
|
|
|
/* NetBSD compatibility */
|
2012-06-28 07:33:43 +00:00
|
|
|
switch ((int) (ntohl(gz->a_out.a_midmag) & 0xffff)) {
|
1994-10-22 11:40:38 +00:00
|
|
|
case ZMAGIC:
|
|
|
|
case QMAGIC:
|
1996-05-02 10:43:17 +00:00
|
|
|
gz->virtual_offset = PAGE_SIZE;
|
1994-10-22 11:40:38 +00:00
|
|
|
gz->file_offset = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gz->where = __LINE__;
|
|
|
|
return (-1);
|
|
|
|
}
|
1994-10-03 05:23:01 +00:00
|
|
|
}
|
|
|
|
|
1996-05-02 10:43:17 +00:00
|
|
|
gz->bss_size = roundup(gz->a_out.a_bss, PAGE_SIZE);
|
1994-10-03 05:23:01 +00:00
|
|
|
|
1994-10-22 11:40:38 +00:00
|
|
|
/*
|
|
|
|
* Check various fields in header for validity/bounds.
|
|
|
|
*/
|
|
|
|
if ( /* entry point must lay with text region */
|
|
|
|
gz->a_out.a_entry < gz->virtual_offset ||
|
|
|
|
gz->a_out.a_entry >= gz->virtual_offset + gz->a_out.a_text ||
|
1994-10-03 05:23:01 +00:00
|
|
|
|
|
|
|
/* text and data size must each be page rounded */
|
1996-05-02 10:43:17 +00:00
|
|
|
gz->a_out.a_text & PAGE_MASK || gz->a_out.a_data & PAGE_MASK) {
|
1994-10-22 11:40:38 +00:00
|
|
|
gz->where = __LINE__;
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* text/data/bss must not exceed limits
|
|
|
|
*/
|
2004-02-04 21:52:57 +00:00
|
|
|
PROC_LOCK(gz->ip->proc);
|
1994-10-22 11:40:38 +00:00
|
|
|
if ( /* text can't exceed maximum text size */
|
2001-10-10 23:06:54 +00:00
|
|
|
gz->a_out.a_text > maxtsiz ||
|
1994-10-03 05:23:01 +00:00
|
|
|
|
|
|
|
/* data + bss can't exceed rlimit */
|
1994-10-22 11:40:38 +00:00
|
|
|
gz->a_out.a_data + gz->bss_size >
|
2015-06-10 10:48:12 +00:00
|
|
|
lim_cur_proc(gz->ip->proc, RLIMIT_DATA) ||
|
2011-04-05 20:23:59 +00:00
|
|
|
racct_set(gz->ip->proc, RACCT_DATA,
|
|
|
|
gz->a_out.a_data + gz->bss_size) != 0) {
|
2004-02-04 21:52:57 +00:00
|
|
|
PROC_UNLOCK(gz->ip->proc);
|
1994-10-22 11:40:38 +00:00
|
|
|
gz->where = __LINE__;
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
2004-02-04 21:52:57 +00:00
|
|
|
PROC_UNLOCK(gz->ip->proc);
|
1994-10-22 11:40:38 +00:00
|
|
|
/* Find out how far we should go */
|
|
|
|
gz->file_end = gz->file_offset + gz->a_out.a_text + gz->a_out.a_data;
|
|
|
|
|
2005-12-24 04:57:50 +00:00
|
|
|
/*
|
|
|
|
* Avoid a possible deadlock if the current address space is destroyed
|
|
|
|
* and that address space maps the locked vnode. In the common case,
|
|
|
|
* the locked vnode's v_usecount is decremented but remains greater
|
|
|
|
* than zero. Consequently, the vnode lock is not needed by vrele().
|
|
|
|
* However, in cases where the vnode lock is external, such as nullfs,
|
|
|
|
* v_usecount may become zero.
|
|
|
|
*/
|
2008-01-13 14:44:15 +00:00
|
|
|
VOP_UNLOCK(gz->ip->vp, 0);
|
2005-12-24 04:57:50 +00:00
|
|
|
|
1994-10-22 11:40:38 +00:00
|
|
|
/*
|
|
|
|
* Destroy old process VM and create a new one (with a new stack)
|
|
|
|
*/
|
2007-11-05 11:36:16 +00:00
|
|
|
error = exec_new_vmspace(gz->ip, &aout_sysvec);
|
1994-10-22 11:40:38 +00:00
|
|
|
|
2008-01-10 01:10:58 +00:00
|
|
|
vn_lock(gz->ip->vp, LK_EXCLUSIVE | LK_RETRY);
|
2007-11-05 11:36:16 +00:00
|
|
|
if (error) {
|
|
|
|
gz->where = __LINE__;
|
|
|
|
return (error);
|
|
|
|
}
|
2005-12-24 04:57:50 +00:00
|
|
|
|
1997-04-13 01:48:35 +00:00
|
|
|
vmspace = gz->ip->proc->p_vmspace;
|
|
|
|
|
1994-10-22 11:40:38 +00:00
|
|
|
vmaddr = gz->virtual_offset;
|
|
|
|
|
|
|
|
error = vm_mmap(&vmspace->vm_map,
|
|
|
|
&vmaddr,
|
1996-08-01 22:00:14 +00:00
|
|
|
gz->a_out.a_text + gz->a_out.a_data,
|
|
|
|
VM_PROT_ALL, VM_PROT_ALL, MAP_ANON | MAP_FIXED,
|
2005-04-01 20:00:11 +00:00
|
|
|
OBJT_DEFAULT,
|
|
|
|
NULL,
|
1994-10-22 11:40:38 +00:00
|
|
|
0);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
gz->where = __LINE__;
|
|
|
|
return (error);
|
|
|
|
}
|
1996-08-01 22:00:14 +00:00
|
|
|
|
1995-02-20 22:23:31 +00:00
|
|
|
if (gz->bss_size != 0) {
|
|
|
|
/*
|
1996-02-13 14:16:36 +00:00
|
|
|
* Allocate demand-zeroed area for uninitialized data.
|
|
|
|
* "bss" = 'block started by symbol' - named after the
|
|
|
|
* IBM 7090 instruction of the same name.
|
1995-02-20 22:23:31 +00:00
|
|
|
*/
|
1996-02-13 14:16:36 +00:00
|
|
|
vmaddr = gz->virtual_offset + gz->a_out.a_text +
|
|
|
|
gz->a_out.a_data;
|
2013-09-09 18:11:59 +00:00
|
|
|
error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr,
|
|
|
|
gz->bss_size, 0, VMFS_NO_SPACE, VM_PROT_ALL, VM_PROT_ALL,
|
|
|
|
0);
|
1995-02-20 22:23:31 +00:00
|
|
|
if (error) {
|
|
|
|
gz->where = __LINE__;
|
|
|
|
return (error);
|
|
|
|
}
|
1994-10-22 11:40:38 +00:00
|
|
|
}
|
|
|
|
/* Fill in process VM information */
|
|
|
|
vmspace->vm_tsize = gz->a_out.a_text >> PAGE_SHIFT;
|
|
|
|
vmspace->vm_dsize = (gz->a_out.a_data + gz->bss_size) >> PAGE_SHIFT;
|
1998-07-15 05:00:26 +00:00
|
|
|
vmspace->vm_taddr = (caddr_t) (uintptr_t) gz->virtual_offset;
|
|
|
|
vmspace->vm_daddr = (caddr_t) (uintptr_t)
|
|
|
|
(gz->virtual_offset + gz->a_out.a_text);
|
1994-10-22 11:40:38 +00:00
|
|
|
|
|
|
|
/* Fill in image_params */
|
|
|
|
gz->ip->interpreted = 0;
|
|
|
|
gz->ip->entry_addr = gz->a_out.a_entry;
|
|
|
|
|
|
|
|
gz->ip->proc->p_sysent = &aout_sysvec;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
NextByte(void *vp)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct imgact_gzip *igz = (struct imgact_gzip *) vp;
|
|
|
|
|
|
|
|
if (igz->idx >= igz->len) {
|
|
|
|
igz->where = __LINE__;
|
|
|
|
return GZ_EOF;
|
|
|
|
}
|
|
|
|
if (igz->inbuf && igz->idx < (igz->offset + PAGE_SIZE)) {
|
|
|
|
return igz->inbuf[(igz->idx++) - igz->offset];
|
|
|
|
}
|
2012-02-17 23:47:16 +00:00
|
|
|
if (igz->inbuf)
|
2013-08-07 06:21:20 +00:00
|
|
|
kmap_free_wakeup(exec_map, (vm_offset_t)igz->inbuf, PAGE_SIZE);
|
1995-02-13 07:40:33 +00:00
|
|
|
igz->offset = igz->idx & ~PAGE_MASK;
|
1994-10-22 11:40:38 +00:00
|
|
|
|
2012-02-17 23:47:16 +00:00
|
|
|
error = vm_mmap(exec_map, /* map */
|
1994-10-22 11:40:38 +00:00
|
|
|
(vm_offset_t *) & igz->inbuf, /* address */
|
|
|
|
PAGE_SIZE, /* size */
|
|
|
|
VM_PROT_READ, /* protection */
|
|
|
|
VM_PROT_READ, /* max protection */
|
|
|
|
0, /* flags */
|
2005-04-01 20:00:11 +00:00
|
|
|
OBJT_VNODE, /* handle type */
|
|
|
|
igz->ip->vp, /* vnode */
|
1994-10-22 11:40:38 +00:00
|
|
|
igz->offset); /* offset */
|
|
|
|
if (error) {
|
|
|
|
igz->where = __LINE__;
|
|
|
|
igz->error = error;
|
|
|
|
return GZ_EOF;
|
|
|
|
}
|
|
|
|
return igz->inbuf[(igz->idx++) - igz->offset];
|
1994-10-03 05:23:01 +00:00
|
|
|
}
|
|
|
|
|
1994-10-22 11:40:38 +00:00
|
|
|
static int
|
|
|
|
Flush(void *vp, u_char * ptr, u_long siz)
|
|
|
|
{
|
|
|
|
struct imgact_gzip *gz = (struct imgact_gzip *) vp;
|
|
|
|
u_char *p = ptr, *q;
|
|
|
|
int i;
|
|
|
|
|
2003-01-01 18:49:04 +00:00
|
|
|
/* First, find an a.out-header. */
|
1994-10-22 11:40:38 +00:00
|
|
|
if (gz->output < sizeof gz->a_out) {
|
|
|
|
q = (u_char *) & gz->a_out;
|
|
|
|
i = min(siz, sizeof gz->a_out - gz->output);
|
|
|
|
bcopy(p, q + gz->output, i);
|
|
|
|
gz->output += i;
|
|
|
|
p += i;
|
|
|
|
siz -= i;
|
|
|
|
if (gz->output == sizeof gz->a_out) {
|
1999-06-21 16:23:13 +00:00
|
|
|
gz->gotheader = 1;
|
1994-10-22 11:40:38 +00:00
|
|
|
i = do_aout_hdr(gz);
|
|
|
|
if (i == -1) {
|
1994-10-22 11:55:16 +00:00
|
|
|
if (!gz->where)
|
|
|
|
gz->where = __LINE__;
|
1994-10-22 11:40:38 +00:00
|
|
|
gz->error = ENOEXEC;
|
|
|
|
return ENOEXEC;
|
|
|
|
} else if (i) {
|
|
|
|
gz->where = __LINE__;
|
|
|
|
gz->error = i;
|
|
|
|
return ENOEXEC;
|
|
|
|
}
|
1997-12-14 19:36:24 +00:00
|
|
|
if (gz->file_offset == 0) {
|
1998-07-15 05:00:26 +00:00
|
|
|
q = (u_char *) (uintptr_t) gz->virtual_offset;
|
1998-06-16 14:36:40 +00:00
|
|
|
copyout(&gz->a_out, q, sizeof gz->a_out);
|
1994-10-22 11:40:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Skip over zero-padded first PAGE if needed */
|
1998-06-16 14:36:40 +00:00
|
|
|
if (gz->output < gz->file_offset &&
|
|
|
|
gz->output + siz > gz->file_offset) {
|
1994-10-22 11:40:38 +00:00
|
|
|
i = min(siz, gz->file_offset - gz->output);
|
|
|
|
gz->output += i;
|
|
|
|
p += i;
|
|
|
|
siz -= i;
|
|
|
|
}
|
|
|
|
if (gz->output >= gz->file_offset && gz->output < gz->file_end) {
|
|
|
|
i = min(siz, gz->file_end - gz->output);
|
1998-07-15 05:00:26 +00:00
|
|
|
q = (u_char *) (uintptr_t)
|
|
|
|
(gz->virtual_offset + gz->output - gz->file_offset);
|
1998-06-16 14:36:40 +00:00
|
|
|
copyout(p, q, i);
|
1994-10-22 11:40:38 +00:00
|
|
|
gz->output += i;
|
|
|
|
p += i;
|
|
|
|
siz -= i;
|
|
|
|
}
|
|
|
|
gz->output += siz;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1994-10-03 05:23:01 +00:00
|
|
|
/*
|
|
|
|
* Tell kern_execve.c about it, with a little help from the linker.
|
|
|
|
*/
|
2018-03-13 13:09:10 +00:00
|
|
|
static struct execsw gzip_execsw = {
|
|
|
|
.ex_imgact = exec_gzip_imgact,
|
|
|
|
.ex_name = "gzip"
|
|
|
|
};
|
1998-10-16 03:55:01 +00:00
|
|
|
EXEC_SET(execgzip, gzip_execsw);
|