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 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD: src/sys/sys/imgact.h,v 1.22.2.2 2001/12/22 01:21:44 jwd Exp $ 30 * $DragonFly: src/sys/sys/imgact.h,v 1.6 2004/04/11 00:10:34 dillon Exp $ 31 */ 32 33 #ifndef _SYS_IMGACT_H_ 34 #define _SYS_IMGACT_H_ 35 36 #include <sys/mount.h> 37 #include <cpu/lwbuf.h> 38 39 #define MAXSHELLCMDLEN 128 40 41 struct image_args { 42 char *buf; /* pointer to string buffer */ 43 char *begin_argv; /* beginning of argv in buf */ 44 char *begin_envv; /* beginning of envv in buf */ 45 char *endp; /* current `end' pointer of arg & env strings */ 46 char *fname; /* beginning of file name */ 47 int space; /* space left in arg & env buffer */ 48 int argc; /* count of argument strings */ 49 int envc; /* count of environment strings */ 50 }; 51 52 struct image_params { 53 struct proc *proc; /* our process struct */ 54 struct image_args *args; /* syscall arguments */ 55 struct vnode *vp; /* pointer to vnode of file to exec */ 56 struct vattr *attr; /* attributes of file */ 57 const char *image_header; /* head of file to exec */ 58 unsigned long entry_addr; /* entry address of target executable */ 59 char resident; /* flag - resident image */ 60 char vmspace_destroyed; /* flag - we've blown away original vm space */ 61 char interpreted; /* flag - this executable is interpreted */ 62 char interpreter_name[MAXSHELLCMDLEN]; /* name of the interpreter */ 63 void *auxargs; /* ELF Auxinfo structure pointer */ 64 struct lwbuf *firstpage; /* first page that we mapped */ 65 struct lwbuf firstpage_cache; 66 unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */ 67 char *execpath; 68 unsigned long execpathp; 69 char *freepath; 70 }; 71 72 #ifdef _KERNEL 73 enum exec_path_segflg {PATH_SYSSPACE, PATH_USERSPACE}; 74 75 struct vmspace; 76 int exec_resident_imgact (struct image_params *); 77 int exec_check_permissions (struct image_params *, struct mount *); 78 int exec_new_vmspace (struct image_params *, struct vmspace *vmres); 79 int exec_shell_imgact (struct image_params *); 80 int exec_copyin_args(struct image_args *, char *, enum exec_path_segflg, 81 char **, char **); 82 void exec_free_args(struct image_args *); 83 #endif 84 85 #endif /* !_SYS_IMGACT_H_ */ 86