The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/exec.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: exec.h,v 1.124 2008/07/02 17:28:57 ad Exp $    */
    2 
    3 /*-
    4  * Copyright (c) 1992, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  * (c) UNIX System Laboratories, Inc.
    7  * All or some portions of this file are derived from material licensed
    8  * to the University of California by American Telephone and Telegraph
    9  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   10  * the permission of UNIX System Laboratories, Inc.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  *      @(#)exec.h      8.4 (Berkeley) 2/19/95
   37  */
   38 
   39 /*-
   40  * Copyright (c) 1993 Theo de Raadt.  All rights reserved.
   41  *
   42  * Redistribution and use in source and binary forms, with or without
   43  * modification, are permitted provided that the following conditions
   44  * are met:
   45  * 1. Redistributions of source code must retain the above copyright
   46  *    notice, this list of conditions and the following disclaimer.
   47  * 2. Redistributions in binary form must reproduce the above copyright
   48  *    notice, this list of conditions and the following disclaimer in the
   49  *    documentation and/or other materials provided with the distribution.
   50  *
   51  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   52  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   53  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   54  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   55  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   56  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   57  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   58  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   59  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   60  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   61  */
   62 
   63 /*-
   64  * Copyright (c) 1994 Christopher G. Demetriou
   65  *
   66  * Redistribution and use in source and binary forms, with or without
   67  * modification, are permitted provided that the following conditions
   68  * are met:
   69  * 1. Redistributions of source code must retain the above copyright
   70  *    notice, this list of conditions and the following disclaimer.
   71  * 2. Redistributions in binary form must reproduce the above copyright
   72  *    notice, this list of conditions and the following disclaimer in the
   73  *    documentation and/or other materials provided with the distribution.
   74  * 3. All advertising materials mentioning features or use of this software
   75  *    must display the following acknowledgement:
   76  *      This product includes software developed by the University of
   77  *      California, Berkeley and its contributors.
   78  * 4. Neither the name of the University nor the names of its contributors
   79  *    may be used to endorse or promote products derived from this software
   80  *    without specific prior written permission.
   81  *
   82  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   83  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   84  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   85  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   86  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   87  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   88  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   89  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   90  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   91  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   92  * SUCH DAMAGE.
   93  *
   94  *      @(#)exec.h      8.4 (Berkeley) 2/19/95
   95  */
   96 
   97 #ifndef _SYS_EXEC_H_
   98 #define _SYS_EXEC_H_
   99 
  100 /*
  101  * The following structure is found at the top of the user stack of each
  102  * user process. The ps program uses it to locate argv and environment
  103  * strings. Programs that wish ps to display other information may modify
  104  * it; normally ps_argvstr points to argv[0], and ps_nargvstr is the same
  105  * as the program's argc. The fields ps_envstr and ps_nenvstr are the
  106  * equivalent for the environment.
  107  */
  108 struct ps_strings {
  109         char    **ps_argvstr;   /* first of 0 or more argument strings */
  110         int     ps_nargvstr;    /* the number of argument strings */
  111         char    **ps_envstr;    /* first of 0 or more environment strings */
  112         int     ps_nenvstr;     /* the number of environment strings */
  113 };
  114 
  115 /*
  116  * the following structures allow execve() to put together processes
  117  * in a more extensible and cleaner way.
  118  *
  119  * the exec_package struct defines an executable being execve()'d.
  120  * it contains the header, the vmspace-building commands, the vnode
  121  * information, and the arguments associated with the newly-execve'd
  122  * process.
  123  *
  124  * the exec_vmcmd struct defines a command description to be used
  125  * in creating the new process's vmspace.
  126  */
  127 
  128 #include <sys/uio.h>
  129 
  130 struct lwp;
  131 struct proc;
  132 struct exec_package;
  133 struct vnode;
  134 
  135 typedef int (*exec_makecmds_fcn)(struct lwp *, struct exec_package *);
  136 
  137 struct execsw {
  138         u_int   es_hdrsz;               /* size of header for this format */
  139         exec_makecmds_fcn es_makecmds;  /* function to setup vmcmds */
  140         union {                         /* probe function */
  141                 int (*elf_probe_func)(struct lwp *,
  142                         struct exec_package *, void *, char *, vaddr_t *);
  143                 int (*ecoff_probe_func)(struct lwp *, struct exec_package *);
  144                 int (*mach_probe_func)(const char **);
  145         } u;
  146         const struct  emul *es_emul;    /* os emulation */
  147         int     es_prio;                /* entry priority */
  148         int     es_arglen;              /* Extra argument size in words */
  149                                         /* Copy arguments on the new stack */
  150         int     (*es_copyargs)(struct lwp *, struct exec_package *,
  151                         struct ps_strings *, char **, void *);
  152                                         /* Set registers before execution */
  153         void    (*es_setregs)(struct lwp *, struct exec_package *, u_long);
  154                                         /* Dump core */
  155         int     (*es_coredump)(struct lwp *, void *);
  156         int     (*es_setup_stack)(struct lwp *, struct exec_package *);
  157 };
  158 
  159 #define EXECSW_PRIO_ANY         0x000   /* default, no preference */
  160 #define EXECSW_PRIO_FIRST       0x001   /* this should be among first */
  161 #define EXECSW_PRIO_LAST        0x002   /* this should be among last */
  162 
  163 /* exec vmspace-creation command set; see below */
  164 struct exec_vmcmd_set {
  165         u_int   evs_cnt;
  166         u_int   evs_used;
  167         struct  exec_vmcmd *evs_cmds;
  168 };
  169 
  170 #define EXEC_DEFAULT_VMCMD_SETSIZE      9       /* # of cmds in set to start */
  171 
  172 struct exec_package {
  173         const char *ep_name;            /* file's name */
  174         void    *ep_hdr;                /* file's exec header */
  175         u_int   ep_hdrlen;              /* length of ep_hdr */
  176         u_int   ep_hdrvalid;            /* bytes of ep_hdr that are valid */
  177         struct nameidata *ep_ndp;       /* namei data pointer for lookups */
  178         struct  exec_vmcmd_set ep_vmcmds;  /* vmcmds used to build vmspace */
  179         struct  vnode *ep_vp;           /* executable's vnode */
  180         struct  vattr *ep_vap;          /* executable's attributes */
  181         u_long  ep_taddr;               /* process's text address */
  182         u_long  ep_tsize;               /* size of process's text */
  183         u_long  ep_daddr;               /* process's data(+bss) address */
  184         u_long  ep_dsize;               /* size of process's data(+bss) */
  185         u_long  ep_maxsaddr;            /* proc's max stack addr ("top") */
  186         u_long  ep_minsaddr;            /* proc's min stack addr ("bottom") */
  187         u_long  ep_ssize;               /* size of process's stack */
  188         u_long  ep_entry;               /* process's entry point */
  189         vaddr_t ep_vm_minaddr;          /* bottom of process address space */
  190         vaddr_t ep_vm_maxaddr;          /* top of process address space */
  191         u_int   ep_flags;               /* flags; see below. */
  192         size_t  ep_fa_len;              /* byte size of ep_fa */
  193         struct exec_fakearg {
  194                 char *fa_arg;
  195                 size_t fa_len;
  196         } *ep_fa;                       /* a fake args vector for scripts */
  197         int     ep_fd;                  /* a file descriptor we're holding */
  198         void    *ep_emul_arg;           /* emulation argument */
  199         const struct    execsw *ep_esch;/* execsw entry */
  200         struct vnode *ep_emul_root;     /* base of emulation filesystem */
  201         struct vnode *ep_interp;        /* vnode of (elf) interpeter */
  202         uint32_t ep_pax_flags;          /* pax flags */
  203         char    *ep_path;               /* absolute path of executable */
  204 };
  205 #define EXEC_INDIR      0x0001          /* script handling already done */
  206 #define EXEC_HASFD      0x0002          /* holding a shell script */
  207 #define EXEC_HASARGL    0x0004          /* has fake args vector */
  208 #define EXEC_SKIPARG    0x0008          /* don't copy user-supplied argv[0] */
  209 #define EXEC_DESTR      0x0010          /* destructive ops performed */
  210 #define EXEC_32         0x0020          /* 32-bit binary emulation */
  211 
  212 struct exec_vmcmd {
  213         int     (*ev_proc)(struct lwp *, struct exec_vmcmd *);
  214                                 /* procedure to run for region of vmspace */
  215         u_long  ev_len;         /* length of the segment to map */
  216         u_long  ev_addr;        /* address in the vmspace to place it at */
  217         struct  vnode *ev_vp;   /* vnode pointer for the file w/the data */
  218         u_long  ev_offset;      /* offset in the file for the data */
  219         u_int   ev_prot;        /* protections for segment */
  220         int     ev_flags;
  221 #define VMCMD_RELATIVE  0x0001  /* ev_addr is relative to base entry */
  222 #define VMCMD_BASE      0x0002  /* marks a base entry */
  223 #define VMCMD_FIXED     0x0004  /* entry must be mapped at ev_addr */
  224 #define VMCMD_STACK     0x0008  /* entry is for a stack */
  225 };
  226 
  227 #ifdef _KERNEL
  228 /*
  229  * funtions used either by execve() or the various CPU-dependent execve()
  230  * hooks.
  231  */
  232 void    kill_vmcmd              (struct exec_vmcmd **);
  233 int     exec_makecmds           (struct lwp *, struct exec_package *);
  234 int     exec_runcmds            (struct lwp *, struct exec_package *);
  235 void    vmcmdset_extend         (struct exec_vmcmd_set *);
  236 void    kill_vmcmds             (struct exec_vmcmd_set *);
  237 int     vmcmd_map_pagedvn       (struct lwp *, struct exec_vmcmd *);
  238 int     vmcmd_map_readvn        (struct lwp *, struct exec_vmcmd *);
  239 int     vmcmd_readvn            (struct lwp *, struct exec_vmcmd *);
  240 int     vmcmd_map_zero          (struct lwp *, struct exec_vmcmd *);
  241 int     copyargs                (struct lwp *, struct exec_package *,
  242                                     struct ps_strings *, char **, void *);
  243 void    setregs                 (struct lwp *, struct exec_package *, u_long);
  244 int     check_veriexec          (struct lwp *, struct vnode *,
  245                                      struct exec_package *, int);
  246 int     check_exec              (struct lwp *, struct exec_package *);
  247 int     exec_init               (int);
  248 int     exec_read_from          (struct lwp *, struct vnode *, u_long off,
  249                                     void *, size_t);
  250 int     exec_setup_stack        (struct lwp *, struct exec_package *);
  251 
  252 int     coredump_write          (void *, enum uio_seg, const void *, size_t);
  253 /*
  254  * Machine dependent functions
  255  */
  256 struct core;
  257 struct core32;
  258 int     cpu_coredump(struct lwp *, void *, struct core *);
  259 int     cpu_coredump32(struct lwp *, void *, struct core32 *);
  260 
  261 
  262 #ifdef LKM
  263 int     emul_register           (const struct emul *, int);
  264 int     emul_unregister         (const char *);
  265 const struct emul *emul_search(const char *);
  266 
  267 int     exec_add                (struct execsw *, const char *);
  268 int     exec_remove             (const struct execsw *);
  269 #endif /* LKM */
  270 
  271 void    new_vmcmd(struct exec_vmcmd_set *,
  272                     int (*)(struct lwp *, struct exec_vmcmd *),
  273                     u_long, u_long, struct vnode *, u_long, u_int, int);
  274 #define NEW_VMCMD(evsp,lwp,len,addr,vp,offset,prot) \
  275         new_vmcmd(evsp,lwp,len,addr,vp,offset,prot,0)
  276 #define NEW_VMCMD2(evsp,lwp,len,addr,vp,offset,prot,flags) \
  277         new_vmcmd(evsp,lwp,len,addr,vp,offset,prot,flags)
  278 
  279 typedef int (*execve_fetch_element_t)(char * const *, size_t, char **);
  280 int     execve1(struct lwp *, const char *, char * const *, char * const *,
  281     execve_fetch_element_t);
  282 
  283 extern int      maxexec;
  284 
  285 #endif /* _KERNEL */
  286 
  287 #include <sys/exec_aout.h>
  288 
  289 #endif /* !_SYS_EXEC_H_ */

Cache object: 4bc9ba79e159806adb1aeb5e0feaca59


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.