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-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 /*      $OpenBSD: kern_xxx.c,v 1.41 2022/12/05 23:18:37 deraadt Exp $   */
    2 /*      $NetBSD: kern_xxx.c,v 1.32 1996/04/22 01:38:41 christos Exp $   */
    3 
    4 /*
    5  * Copyright (c) 1982, 1986, 1989, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  *      @(#)kern_xxx.c  8.2 (Berkeley) 11/14/93
   33  */
   34 
   35 #include <sys/param.h>
   36 #include <sys/systm.h>
   37 #include <sys/reboot.h>
   38 #include <sys/mount.h>
   39 #include <sys/syscallargs.h>
   40 
   41 int rebooting = 0;
   42 
   43 int
   44 sys_reboot(struct proc *p, void *v, register_t *retval)
   45 {
   46         struct sys_reboot_args /* {
   47                 syscallarg(int) opt;
   48         } */ *uap = v;
   49         int error;
   50 
   51         if ((error = suser(p)) != 0)
   52                 return (error);
   53 
   54 #ifdef MULTIPROCESSOR
   55         sched_stop_secondary_cpus();
   56         KASSERT(CPU_IS_PRIMARY(curcpu()));
   57 #endif
   58         reboot(SCARG(uap, opt));
   59         /* NOTREACHED */
   60         return (0);
   61 }
   62 
   63 __dead void
   64 reboot(int howto)
   65 {
   66         KASSERT((howto & RB_NOSYNC) || curproc != NULL);
   67 
   68         stop_periodic_resettodr();
   69 
   70         rebooting = 1;
   71 
   72         boot(howto);
   73         /* NOTREACHED */
   74 }
   75 
   76 #if !defined(NO_PROPOLICE) && !defined(_RET_PROTECTOR)
   77 void __stack_smash_handler(char [], int __attribute__((unused)));
   78 
   79 void
   80 __stack_smash_handler(char func[], int damaged)
   81 {
   82         panic("smashed stack in %s", func);
   83 }
   84 #endif
   85 
   86 #ifdef SYSCALL_DEBUG
   87 #include <sys/proc.h>
   88 #include <sys/syscall.h>
   89 
   90 #define SCDEBUG_CALLS           0x0001  /* show calls */
   91 #define SCDEBUG_RETURNS         0x0002  /* show returns */
   92 #define SCDEBUG_ALL             0x0004  /* even syscalls that are implemented */
   93 #define SCDEBUG_SHOWARGS        0x0008  /* show arguments to calls */
   94 
   95 int     scdebug = SCDEBUG_CALLS|SCDEBUG_RETURNS|SCDEBUG_SHOWARGS;
   96 
   97 extern const char *const syscallnames[];
   98 
   99 void
  100 scdebug_call(struct proc *p, register_t code, const register_t args[])
  101 {
  102         struct process *pr;
  103         int i;
  104 
  105         if (!(scdebug & SCDEBUG_CALLS))
  106                 return;
  107 
  108         if (!(scdebug & SCDEBUG_ALL || code < 0 || code >= SYS_MAXSYSCALL ||
  109              sysent[code].sy_call == sys_nosys))
  110                 return;
  111 
  112         pr = p->p_p;
  113         printf("proc %d (%s): num ", pr->ps_pid, pr->ps_comm);
  114         if (code < 0 || code >= SYS_MAXSYSCALL)
  115                 printf("OUT OF RANGE (%ld)", code);
  116         else {
  117                 printf("%ld call: %s", code, syscallnames[code]);
  118                 if (scdebug & SCDEBUG_SHOWARGS) {
  119                         printf("(");
  120                         for (i = 0; i < sysent[code].sy_argsize / sizeof(register_t);
  121                             i++)
  122                                 printf("%s0x%lx", i == 0 ? "" : ", ", args[i]);
  123                         printf(")");
  124                 }
  125         }
  126         printf("\n");
  127 }
  128 
  129 void
  130 scdebug_ret(struct proc *p, register_t code, int error,
  131     const register_t retval[])
  132 {
  133         struct process *pr;
  134 
  135         if (!(scdebug & SCDEBUG_RETURNS))
  136                 return;
  137 
  138         if (!(scdebug & SCDEBUG_ALL || code < 0 || code >= SYS_MAXSYSCALL ||
  139             sysent[code].sy_call == sys_nosys))
  140                 return;
  141 
  142         pr = p->p_p;
  143         printf("proc %d (%s): num ", pr->ps_pid, pr->ps_comm);
  144         if (code < 0 || code >= SYS_MAXSYSCALL)
  145                 printf("OUT OF RANGE (%ld)", code);
  146         else if (code == SYS_lseek)
  147                 printf("%ld ret: err = %d, rv = 0x%llx", code,
  148                     error, *(off_t *)retval);
  149         else
  150                 printf("%ld ret: err = %d, rv = 0x%lx", code,
  151                     error, *retval);
  152         printf("\n");
  153 }
  154 #endif /* SYSCALL_DEBUG */

Cache object: b77142404295d11a9d7d467dba7d27a6


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