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/kernel/system/do_exec.c

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 /* The kernel call implemented in this file:
    2  *   m_type:    SYS_EXEC
    3  *
    4  * The parameters for this kernel call are:
    5  *    m1_i1:    PR_PROC_NR              (process that did exec call)
    6  *    m1_p1:    PR_STACK_PTR            (new stack pointer)
    7  *    m1_p2:    PR_NAME_PTR             (pointer to program name)
    8  *    m1_p3:    PR_IP_PTR               (new instruction pointer)
    9  */
   10 #include "../system.h"
   11 #include <string.h>
   12 #include <signal.h>
   13 
   14 #if USE_EXEC
   15 
   16 /*===========================================================================*
   17  *                              do_exec                                      *
   18  *===========================================================================*/
   19 PUBLIC int do_exec(m_ptr)
   20 register message *m_ptr;        /* pointer to request message */
   21 {
   22 /* Handle sys_exec().  A process has done a successful EXEC. Patch it up. */
   23   register struct proc *rp;
   24   reg_t sp;                     /* new sp */
   25   phys_bytes phys_name;
   26   char *np;
   27 
   28   rp = proc_addr(m_ptr->PR_PROC_NR);
   29   sp = (reg_t) m_ptr->PR_STACK_PTR;
   30   rp->p_reg.sp = sp;            /* set the stack pointer */
   31 #if (CHIP == M68000)
   32   rp->p_splow = sp;             /* set the stack pointer low water */
   33 #ifdef FPP
   34   /* Initialize fpp for this process */
   35   fpp_new_state(rp);
   36 #endif
   37 #endif
   38 #if (CHIP == INTEL)             /* wipe extra LDT entries */
   39   phys_memset(vir2phys(&rp->p_ldt[EXTRA_LDT_INDEX]), 0,
   40         (LDT_SIZE - EXTRA_LDT_INDEX) * sizeof(rp->p_ldt[0]));
   41 #endif
   42   rp->p_reg.pc = (reg_t) m_ptr->PR_IP_PTR;      /* set pc */
   43   rp->p_rts_flags &= ~RECEIVING;        /* PM does not reply to EXEC call */
   44   if (rp->p_rts_flags == 0) lock_enqueue(rp);
   45 
   46   /* Save command name for debugging, ps(1) output, etc. */
   47   phys_name = numap_local(m_ptr->m_source, (vir_bytes) m_ptr->PR_NAME_PTR,
   48                                         (vir_bytes) P_NAME_LEN - 1);
   49   if (phys_name != 0) {
   50         phys_copy(phys_name, vir2phys(rp->p_name), (phys_bytes) P_NAME_LEN - 1);
   51         for (np = rp->p_name; (*np & BYTE) >= ' '; np++) {}
   52         *np = 0;                                        /* mark end */
   53   } else {
   54         strncpy(rp->p_name, "<unset>", P_NAME_LEN);
   55   }
   56   return(OK);
   57 }
   58 #endif /* USE_EXEC */
   59 

Cache object: a2ec88b9b3fe9baf4202d46540e36a70


[ 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.