1/* 2 * Copyright (c) 1993, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/kern/imgact_aout.c 50717 1999-09-01 00:29:56Z julian $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/acct.h> 31#include <sys/resourcevar.h> 32#include <sys/exec.h> 33#include <sys/fcntl.h> 34#include <sys/imgact.h> --- 35 unchanged lines hidden (view full) --- 70 sendsig, 71 sigcode, 72 &szsigcode, 73 0, 74 "FreeBSD a.out", 75 aout_coredump 76}; 77 |
78int |
79exec_aout_imgact(imgp) 80 struct image_params *imgp; 81{ 82 const struct exec *a_out = (const struct exec *) imgp->image_header; 83 struct vmspace *vmspace; 84 struct vnode *vp; 85 vm_map_t map; 86 vm_object_t object; --- 152 unchanged lines hidden (view full) --- 239 return (0); 240} 241 242/* 243 * Dump core, into a file named as described in the comments for 244 * expand_name(), unless the process was setuid/setgid. 245 */ 246int |
247aout_coredump(p, vp, limit) |
248 register struct proc *p; |
249 register struct vnode *vp; |
250 off_t limit; 251{ |
252 register struct ucred *cred = p->p_cred->pc_ucred; 253 register struct vmspace *vm = p->p_vmspace; |
254 int error = 0; |
255 |
256 if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >= |
257 limit) |
258 return (EFAULT); |
259 |
260 bcopy(p, &p->p_addr->u_kproc.kp_proc, sizeof(struct proc)); 261 fill_eproc(p, &p->p_addr->u_kproc.kp_eproc); 262 error = cpu_coredump(p, vp, cred); 263 if (error == 0) 264 error = vn_rdwr(UIO_WRITE, vp, vm->vm_daddr, 265 (int)ctob(vm->vm_dsize), (off_t)ctob(UPAGES), UIO_USERSPACE, 266 IO_NODELOCKED|IO_UNIT, cred, (int *) NULL, p); 267 if (error == 0) 268 error = vn_rdwr(UIO_WRITE, vp, 269 (caddr_t) trunc_page(USRSTACK - ctob(vm->vm_ssize)), 270 round_page(ctob(vm->vm_ssize)), 271 (off_t)ctob(UPAGES) + ctob(vm->vm_dsize), UIO_USERSPACE, 272 IO_NODELOCKED|IO_UNIT, cred, (int *) NULL, p); |
273 return error; |
274} 275 276/* 277 * Tell kern_execve.c about it, with a little help from the linker. 278 */ 279static struct execsw aout_execsw = { exec_aout_imgact, "a.out" }; 280EXEC_SET(aout, aout_execsw); |