24 #include <sys/cdefs.h>
27 #include <sys/param.h>
29 #include <sys/imgact.h>
30 #include <sys/imgact_aout.h>
31 #include <sys/kernel.h>
34 #include <sys/mutex.h>
36 #include <sys/racct.h>
37 #include <sys/resourcevar.h>
38 #include <sys/sysent.h>
39 #include <sys/systm.h>
40 #include <sys/vnode.h>
41 #include <sys/inflate.h>
44 #include <vm/vm_param.h>
46 #include <vm/vm_map.h>
47 #include <vm/vm_kern.h>
48 #include <vm/vm_extern.h>
51 struct image_params *
ip;
67 static int Flush(
void *vp, u_char *, u_long siz);
71 struct image_params *imgp;
74 const u_char *p = (
const u_char *) imgp->image_header;
77 struct vmspace *vmspace;
100 bzero(&igz,
sizeof igz);
101 bzero(&infl,
sizeof infl);
102 infl.gz_private = (
void *) &igz;
104 infl.gz_output =
Flush;
111 if (igz.idx >= PAGE_SIZE)
116 if (igz.idx >= PAGE_SIZE)
119 igz.len = imgp->attr->va_size;
127 if ( !igz.gotheader )
131 vmspace = imgp->proc->p_vmspace;
132 error = vm_map_protect(&vmspace->vm_map,
133 (vm_offset_t) vmspace->vm_taddr,
134 (vm_offset_t) (vmspace->vm_taddr +
135 (vmspace->vm_tsize << PAGE_SHIFT)) ,
136 VM_PROT_READ|VM_PROT_EXECUTE,0);
140 kmem_free_wakeup(exec_map, (vm_offset_t)igz.inbuf, PAGE_SIZE);
141 if (igz.error || error) {
142 printf(
"Output=%lu ", igz.output);
143 printf(
"Inflate_error=%d igz.error=%d where=%d\n",
144 error, igz.error, igz.where);
157 struct vmspace *vmspace;
164 switch ((
int) (gz->
a_out.a_magic & 0xffff)) {
167 if (gz->
a_out.a_text) {
180 switch ((
int) (ntohl(gz->
a_out.a_magic) & 0xffff)) {
187 gz->
where = __LINE__;
202 gz->
a_out.a_text & PAGE_MASK || gz->
a_out.a_data & PAGE_MASK) {
203 gz->
where = __LINE__;
209 PROC_LOCK(gz->
ip->proc);
218 PROC_UNLOCK(gz->
ip->proc);
219 gz->
where = __LINE__;
222 PROC_UNLOCK(gz->
ip->proc);
234 VOP_UNLOCK(gz->
ip->vp, 0);
241 vn_lock(gz->
ip->vp, LK_EXCLUSIVE | LK_RETRY);
243 gz->
where = __LINE__;
247 vmspace = gz->
ip->proc->p_vmspace;
251 error = vm_mmap(&vmspace->vm_map,
254 VM_PROT_ALL, VM_PROT_ALL, MAP_ANON | MAP_FIXED,
260 gz->
where = __LINE__;
272 error = vm_map_find(&vmspace->vm_map,
277 FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
279 gz->
where = __LINE__;
284 vmspace->vm_tsize = gz->
a_out.a_text >> PAGE_SHIFT;
285 vmspace->vm_dsize = (gz->
a_out.a_data + gz->
bss_size) >> PAGE_SHIFT;
287 vmspace->vm_daddr = (caddr_t) (uintptr_t)
291 gz->
ip->interpreted = 0;
292 gz->
ip->entry_addr = gz->
a_out.a_entry;
294 gz->
ip->proc->p_sysent = &aout_sysvec;
305 if (igz->
idx >= igz->
len) {
306 igz->
where = __LINE__;
313 kmem_free_wakeup(exec_map, (vm_offset_t)igz->
inbuf, PAGE_SIZE);
316 error = vm_mmap(exec_map,
317 (vm_offset_t *) & igz->
inbuf,
326 igz->
where = __LINE__;
334 Flush(
void *vp, u_char * ptr, u_long siz)
342 q = (u_char *) & gz->
a_out;
344 bcopy(p, q + gz->
output, i);
353 gz->
where = __LINE__;
357 gz->
where = __LINE__;
377 q = (u_char *) (uintptr_t)
rlim_t lim_cur(struct proc *p, int which)
int racct_set(struct proc *p, int resource, uint64_t amount)
int inflate(struct inflate *glbl)
EXEC_SET(execgzip, gzip_execsw)
static int NextByte(void *vp)
int exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv)
static const struct execsw ** execsw
int printf(const char *fmt,...)
static struct execsw gzip_execsw
static int exec_gzip_imgact(struct image_params *imgp)
static int Flush(void *vp, u_char *, u_long siz)
static int do_aout_hdr(struct imgact_gzip *)