1850Sdg/*-
2850Sdg * Copyright (c) 1993, David Greenman
3850Sdg * All rights reserved.
4850Sdg *
5850Sdg * Redistribution and use in source and binary forms, with or without
6850Sdg * modification, are permitted provided that the following conditions
7850Sdg * are met:
8850Sdg * 1. Redistributions of source code must retain the above copyright
9850Sdg *    notice, this list of conditions and the following disclaimer.
10850Sdg * 2. Redistributions in binary form must reproduce the above copyright
11850Sdg *    notice, this list of conditions and the following disclaimer in the
12850Sdg *    documentation and/or other materials provided with the distribution.
13850Sdg * 4. Neither the name of the University nor the names of its contributors
14850Sdg *    may be used to endorse or promote products derived from this software
15850Sdg *    without specific prior written permission.
16850Sdg *
17850Sdg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18850Sdg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19850Sdg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20850Sdg * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21850Sdg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22850Sdg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23850Sdg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24850Sdg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25850Sdg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26850Sdg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27850Sdg * SUCH DAMAGE.
28850Sdg *
2950477Speter * $FreeBSD$
30850Sdg */
31850Sdg
322165Spaul#ifndef _SYS_IMGACT_H_
3315494Sbde#define	_SYS_IMGACT_H_
34886Swollman
35210498Skib#include <sys/uio.h>
36210498Skib
37217151Skib#include <vm/vm.h>
38217151Skib
39142453Ssobomax#define MAXSHELLCMDLEN	PAGE_SIZE
4059663Sdillon
41140992Ssobomaxstruct image_args {
42140992Ssobomax	char *buf;		/* pointer to string buffer */
43140992Ssobomax	char *begin_argv;	/* beginning of argv in buf */
44140992Ssobomax	char *begin_envv;	/* beginning of envv in buf */
45140992Ssobomax	char *endp;		/* current `end' pointer of arg & env strings */
46140992Ssobomax	char *fname;            /* pointer to filename of executable (system space) */
47210555Salc	char *fname_buf;	/* pointer to optional malloc(M_TEMP) buffer */
48140992Ssobomax	int stringspace;	/* space left in arg & env buffer */
49140992Ssobomax	int argc;		/* count of argument strings */
50140992Ssobomax	int envc;		/* count of environment strings */
51177787Skib	int fd;			/* file descriptor of the executable */
52140992Ssobomax};
53140992Ssobomax
54850Sdgstruct image_params {
55850Sdg	struct proc *proc;	/* our process struct */
56106468Srwatson	struct label *execlabel;	/* optional exec label */
5712130Sdg	struct vnode *vp;	/* pointer to vnode of file to exec */
5899487Sjeff	struct vm_object *object;	/* The vm object for this vp */
59850Sdg	struct vattr *attr;	/* attributes of file */
60850Sdg	const char *image_header; /* head of file to exec */
61850Sdg	unsigned long entry_addr; /* entry address of target executable */
62205643Snwhitehorn	unsigned long reloc_base; /* load address of image */
63850Sdg	char vmspace_destroyed;	/* flag - we've blown away original vm space */
64850Sdg	char interpreted;	/* flag - this executable is interpreted */
65180570Skib	char opened;		/* flag - we have opened executable vnode */
66142453Ssobomax	char *interpreter_name;	/* name of the interpreter */
6714456Ssos	void *auxargs;		/* ELF Auxinfo structure pointer */
68128568Salc	struct sf_buf *firstpage;	/* first page that we mapped */
6945270Sjdp	unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */
7066379Stakawata	size_t auxarg_size;
71140992Ssobomax	struct image_args *args;	/* system call arguments */
72161302Snetchild	struct sysentvec *sysent;	/* system entry vector */
73189927Skib	char *execpath;
74189927Skib	unsigned long execpathp;
75189927Skib	char *freepath;
76211412Skib	unsigned long canary;
77211412Skib	int canarylen;
78211412Skib	unsigned long pagesizes;
79211412Skib	int pagesizeslen;
80217151Skib	vm_prot_t stack_prot;
81850Sdg};
82886Swollman
8355205Speter#ifdef _KERNEL
84128599Sbdestruct sysentvec;
85128599Sbdestruct thread;
86128599Sbde
87204552Salfred#define IMGACT_CORE_COMPRESS	0x01
88204552Salfred
89210545Salcint	exec_alloc_args(struct image_args *);
9092719Salfredint	exec_check_permissions(struct image_params *);
91102808Sjakeregister_t *exec_copyout_strings(struct image_params *);
92210429Salcvoid	exec_free_args(struct image_args *);
93103767Sjakeint	exec_new_vmspace(struct image_params *, struct sysentvec *);
94205642Snwhitehornvoid	exec_setregs(struct thread *, struct image_params *, u_long);
9592719Salfredint	exec_shell_imgact(struct image_params *);
96140992Ssobomaxint	exec_copyin_args(struct image_args *, char *, enum uio_seg,
97140992Ssobomax	char **, char **);
983304Sphk#endif
9915494Sbde
10015494Sbde#endif /* !_SYS_IMGACT_H_ */
101