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.71 2010/11/21 17:57:24 pooka 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.71 2010/11/21 17:57:24 pooka Exp $");
   36 
   37 #ifdef _KERNEL_OPT
   38 #include "opt_syscall_debug.h"
   39 #endif
   40 
   41 #include <sys/param.h>
   42 #include <sys/systm.h>
   43 #include <sys/kernel.h>
   44 #include <sys/proc.h>
   45 #include <sys/reboot.h>
   46 #include <sys/syscall.h>
   47 #include <sys/sysctl.h>
   48 #include <sys/mount.h>
   49 #include <sys/syscall.h>
   50 #include <sys/syscallargs.h>
   51 #include <sys/kauth.h>
   52 
   53 /* ARGSUSED */
   54 int
   55 sys_reboot(struct lwp *l, const struct sys_reboot_args *uap, register_t *retval)
   56 {
   57         /* {
   58                 syscallarg(int) opt;
   59                 syscallarg(char *) bootstr;
   60         } */
   61         int error;
   62         char *bootstr, bs[128];
   63 
   64         if ((error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_REBOOT,
   65             0, NULL, NULL, NULL)) != 0)
   66                 return (error);
   67 
   68         /*
   69          * Only use the boot string if RB_STRING is set.
   70          */
   71         if ((SCARG(uap, opt) & RB_STRING) &&
   72             (error = copyinstr(SCARG(uap, bootstr), bs, sizeof(bs), 0)) == 0)
   73                 bootstr = bs;
   74         else
   75                 bootstr = NULL;
   76         /*
   77          * Not all ports use the bootstr currently.
   78          */
   79         KERNEL_LOCK(1, NULL);
   80         cpu_reboot(SCARG(uap, opt), bootstr);
   81         KERNEL_UNLOCK_ONE(NULL);
   82         return (0);
   83 }
   84 
   85 /*
   86  * Pull in the indirect syscall functions here.
   87  * They are only actually used if the ports syscall entry code
   88  * doesn't special-case SYS_SYSCALL and SYS___SYSCALL
   89  *
   90  * In some cases the generated code for the two functions is identical,
   91  * but there isn't a MI way of determining that - so we don't try.
   92  */
   93 
   94 #define SYS_SYSCALL sys_syscall
   95 #include "sys_syscall.c"
   96 #undef SYS_SYSCALL
   97 
   98 #define SYS_SYSCALL sys___syscall
   99 #include "sys_syscall.c"
  100 #undef SYS_SYSCALL
  101 
  102 #ifdef SYSCALL_DEBUG
  103 #define SCDEBUG_CALLS           0x0001  /* show calls */
  104 #define SCDEBUG_RETURNS         0x0002  /* show returns */
  105 #define SCDEBUG_ALL             0x0004  /* even syscalls that are implemented */
  106 #define SCDEBUG_SHOWARGS        0x0008  /* show arguments to calls */
  107 
  108 #if 0
  109 int     scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS;
  110 #else
  111 int     scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS|SCDEBUG_ALL;
  112 #endif
  113 
  114 void
  115 scdebug_call(register_t code, const register_t args[])
  116 {
  117         struct lwp *l = curlwp;
  118         struct proc *p = l->l_proc;
  119         const struct sysent *sy;
  120         const struct emul *em;
  121         int i;
  122 
  123         if (!(scdebug & SCDEBUG_CALLS))
  124                 return;
  125 
  126         em = p->p_emul;
  127         sy = &em->e_sysent[code];
  128         if (!(scdebug & SCDEBUG_ALL || (int)code < 0
  129 #ifndef __HAVE_MINIMAL_EMUL
  130             || code >= em->e_nsysent
  131 #endif
  132             || sy->sy_call == sys_nosys))
  133                 return;
  134 
  135         printf("proc %d (%s): %s num ", p->p_pid, p->p_comm, em->e_name);
  136         if ((int)code < 0
  137 #ifndef __HAVE_MINIMAL_EMUL
  138             || code >= em->e_nsysent
  139 #endif
  140             )
  141                 printf("OUT OF RANGE (%ld)", (long)code);
  142         else {
  143                 printf("%ld call: %s", (long)code, em->e_syscallnames[code]);
  144                 if (scdebug & SCDEBUG_SHOWARGS) {
  145                         printf("(");
  146                         for (i = 0; i < sy->sy_argsize/sizeof(register_t); i++)
  147                                 printf("%s0x%lx", i == 0 ? "" : ", ",
  148                                     (long)args[i]);
  149                         printf(")");
  150                 }
  151         }
  152         printf("\n");
  153 }
  154 
  155 void
  156 scdebug_ret(register_t code, int error, const register_t retval[])
  157 {
  158         struct lwp *l = curlwp;
  159         struct proc *p = l->l_proc;
  160         const struct sysent *sy;
  161         const struct emul *em;
  162 
  163         if (!(scdebug & SCDEBUG_RETURNS))
  164                 return;
  165 
  166         em = p->p_emul;
  167         sy = &em->e_sysent[code];
  168         if (!(scdebug & SCDEBUG_ALL || (int)code < 0
  169 #ifndef __HAVE_MINIMAL_EMUL
  170             || (int)code >= em->e_nsysent
  171 #endif
  172             || sy->sy_call == sys_nosys))
  173                 return;
  174 
  175         printf("proc %d (%s): %s num ", p->p_pid, p->p_comm, em->e_name);
  176         if ((int)code < 0
  177 #ifndef __HAVE_MINIMAL_EMUL
  178             || code >= em->e_nsysent
  179 #endif
  180             )
  181                 printf("OUT OF RANGE (%ld)", (long)code);
  182         else
  183                 printf("%ld ret: err = %d, rv = 0x%lx,0x%lx", (long)code,
  184                     error, (long)retval[0], (long)retval[1]);
  185         printf("\n");
  186 }
  187 #endif /* SYSCALL_DEBUG */

Cache object: 09715921c599f77f7e6f9e71e902610d


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