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/kern/kern_xxx.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: kern_xxx.c,v 1.62 2006/11/01 10:17:58 yamt Exp $       */
    2 
    3 /*
    4  * Copyright (c) 1982, 1986, 1989, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the University nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  *      @(#)kern_xxx.c  8.3 (Berkeley) 2/14/95
   32  */
   33 
   34 #include <sys/cdefs.h>
   35 __KERNEL_RCSID(0, "$NetBSD: kern_xxx.c,v 1.62 2006/11/01 10:17:58 yamt Exp $");
   36 
   37 #include "opt_syscall_debug.h"
   38 
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <sys/kernel.h>
   42 #include <sys/proc.h>
   43 #include <sys/reboot.h>
   44 #include <sys/syscall.h>
   45 #include <sys/sysctl.h>
   46 #include <sys/mount.h>
   47 #include <sys/sa.h>
   48 #include <sys/syscallargs.h>
   49 #include <sys/kauth.h>
   50 
   51 /* ARGSUSED */
   52 int
   53 sys_reboot(struct lwp *l, void *v, register_t *retval)
   54 {
   55         struct sys_reboot_args /* {
   56                 syscallarg(int) opt;
   57                 syscallarg(char *) bootstr;
   58         } */ *uap = v;
   59         int error;
   60         char *bootstr, bs[128];
   61 
   62         if ((error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_REBOOT,
   63             0, NULL, NULL, NULL)) != 0)
   64                 return (error);
   65 
   66         /*
   67          * Only use the boot string if RB_STRING is set.
   68          */
   69         if ((SCARG(uap, opt) & RB_STRING) &&
   70             (error = copyinstr(SCARG(uap, bootstr), bs, sizeof(bs), 0)) == 0)
   71                 bootstr = bs;
   72         else
   73                 bootstr = NULL;
   74         /*
   75          * Not all ports use the bootstr currently.
   76          */
   77         cpu_reboot(SCARG(uap, opt), bootstr);
   78         return (0);
   79 }
   80 
   81 #ifdef SYSCALL_DEBUG
   82 #define SCDEBUG_CALLS           0x0001  /* show calls */
   83 #define SCDEBUG_RETURNS         0x0002  /* show returns */
   84 #define SCDEBUG_ALL             0x0004  /* even syscalls that are implemented */
   85 #define SCDEBUG_SHOWARGS        0x0008  /* show arguments to calls */
   86 
   87 #if 0
   88 int     scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS;
   89 #else
   90 int     scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS|SCDEBUG_ALL;
   91 #endif
   92 
   93 void
   94 scdebug_call(struct lwp *l, register_t code, register_t args[])
   95 {
   96         struct proc *p = l->l_proc;
   97         const struct sysent *sy;
   98         const struct emul *em;
   99         int i;
  100 
  101         if (!(scdebug & SCDEBUG_CALLS))
  102                 return;
  103 
  104         em = p->p_emul;
  105         sy = &em->e_sysent[code];
  106         if (!(scdebug & SCDEBUG_ALL || code < 0
  107 #ifndef __HAVE_MINIMAL_EMUL
  108             || code >= em->e_nsysent
  109 #endif
  110             || sy->sy_call == sys_nosys))
  111                 return;
  112 
  113         KERNEL_PROC_LOCK(l);
  114         printf("proc %d (%s): %s num ", p->p_pid, p->p_comm, em->e_name);
  115         if (code < 0
  116 #ifndef __HAVE_MINIMAL_EMUL
  117             || code >= em->e_nsysent
  118 #endif
  119             )
  120                 printf("OUT OF RANGE (%ld)", (long)code);
  121         else {
  122                 printf("%ld call: %s", (long)code, em->e_syscallnames[code]);
  123                 if (scdebug & SCDEBUG_SHOWARGS) {
  124                         printf("(");
  125                         for (i = 0; i < sy->sy_argsize/sizeof(register_t); i++)
  126                                 printf("%s0x%lx", i == 0 ? "" : ", ",
  127                                     (long)args[i]);
  128                         printf(")");
  129                 }
  130         }
  131         printf("\n");
  132         KERNEL_PROC_UNLOCK(l);
  133 }
  134 
  135 void
  136 scdebug_ret(struct lwp *l, register_t code, int error, register_t retval[])
  137 {
  138         struct proc *p = l->l_proc;
  139         const struct sysent *sy;
  140         const struct emul *em;
  141 
  142         if (!(scdebug & SCDEBUG_RETURNS))
  143                 return;
  144 
  145         em = p->p_emul;
  146         sy = &em->e_sysent[code];
  147         if (!(scdebug & SCDEBUG_ALL || code < 0
  148 #ifndef __HAVE_MINIMAL_EMUL
  149             || code >= em->e_nsysent
  150 #endif
  151             || sy->sy_call == sys_nosys))
  152                 return;
  153 
  154         KERNEL_PROC_LOCK(l);
  155         printf("proc %d (%s): %s num ", p->p_pid, p->p_comm, em->e_name);
  156         if (code < 0
  157 #ifndef __HAVE_MINIMAL_EMUL
  158             || code >= em->e_nsysent
  159 #endif
  160             )
  161                 printf("OUT OF RANGE (%ld)", (long)code);
  162         else
  163                 printf("%ld ret: err = %d, rv = 0x%lx,0x%lx", (long)code,
  164                     error, (long)retval[0], (long)retval[1]);
  165         printf("\n");
  166         KERNEL_PROC_UNLOCK(l);
  167 }
  168 #endif /* SYSCALL_DEBUG */

Cache object: cb73e606339309400a29d0d33140de7e


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