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 */
64272450Ssbruno#define IMGACT_SHELL	0x1
65272450Ssbruno#define IMGACT_BINMISC	0x2
66272450Ssbruno	unsigned char interpreted;	/* mask of interpreters that have run */
67180570Skib	char opened;		/* flag - we have opened executable vnode */
68142453Ssobomax	char *interpreter_name;	/* name of the interpreter */
6914456Ssos	void *auxargs;		/* ELF Auxinfo structure pointer */
70128568Salc	struct sf_buf *firstpage;	/* first page that we mapped */
7145270Sjdp	unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */
7266379Stakawata	size_t auxarg_size;
73140992Ssobomax	struct image_args *args;	/* system call arguments */
74161302Snetchild	struct sysentvec *sysent;	/* system entry vector */
75189927Skib	char *execpath;
76189927Skib	unsigned long execpathp;
77189927Skib	char *freepath;
78211412Skib	unsigned long canary;
79211412Skib	int canarylen;
80211412Skib	unsigned long pagesizes;
81211412Skib	int pagesizeslen;
82217151Skib	vm_prot_t stack_prot;
83850Sdg};
84886Swollman
8555205Speter#ifdef _KERNEL
86128599Sbdestruct sysentvec;
87128599Sbdestruct thread;
88128599Sbde
89204552Salfred#define IMGACT_CORE_COMPRESS	0x01
90204552Salfred
91210545Salcint	exec_alloc_args(struct image_args *);
9292719Salfredint	exec_check_permissions(struct image_params *);
93102808Sjakeregister_t *exec_copyout_strings(struct image_params *);
94210429Salcvoid	exec_free_args(struct image_args *);
95103767Sjakeint	exec_new_vmspace(struct image_params *, struct sysentvec *);
96205642Snwhitehornvoid	exec_setregs(struct thread *, struct image_params *, u_long);
9792719Salfredint	exec_shell_imgact(struct image_params *);
98140992Ssobomaxint	exec_copyin_args(struct image_args *, char *, enum uio_seg,
99140992Ssobomax	char **, char **);
1003304Sphk#endif
10115494Sbde
10215494Sbde#endif /* !_SYS_IMGACT_H_ */
103