1*6bbef11eSad /* $NetBSD: kern_xxx_12.c,v 1.18 2020/02/23 15:57:09 ad Exp $ */
25abbf990Smrg
35abbf990Smrg /*
45abbf990Smrg * Copyright (c) 1982, 1986, 1989, 1993
55abbf990Smrg * The Regents of the University of California. All rights reserved.
65abbf990Smrg *
75abbf990Smrg * Redistribution and use in source and binary forms, with or without
85abbf990Smrg * modification, are permitted provided that the following conditions
95abbf990Smrg * are met:
105abbf990Smrg * 1. Redistributions of source code must retain the above copyright
115abbf990Smrg * notice, this list of conditions and the following disclaimer.
125abbf990Smrg * 2. Redistributions in binary form must reproduce the above copyright
135abbf990Smrg * notice, this list of conditions and the following disclaimer in the
145abbf990Smrg * documentation and/or other materials provided with the distribution.
15aad01611Sagc * 3. Neither the name of the University nor the names of its contributors
165abbf990Smrg * may be used to endorse or promote products derived from this software
175abbf990Smrg * without specific prior written permission.
185abbf990Smrg *
195abbf990Smrg * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
205abbf990Smrg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
215abbf990Smrg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
225abbf990Smrg * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
235abbf990Smrg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
245abbf990Smrg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
255abbf990Smrg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
265abbf990Smrg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
275abbf990Smrg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
285abbf990Smrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
295abbf990Smrg * SUCH DAMAGE.
305abbf990Smrg *
315abbf990Smrg * @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
325abbf990Smrg * from NetBSD: kern_xxx.c,v 1.32 1996/04/22 01:38:41 christos Exp
335abbf990Smrg */
345abbf990Smrg
35dab6ef8bSlukem #include <sys/cdefs.h>
36*6bbef11eSad __KERNEL_RCSID(0, "$NetBSD: kern_xxx_12.c,v 1.18 2020/02/23 15:57:09 ad Exp $");
37dab6ef8bSlukem
38d91f98a8Spgoyette #if defined(_KERNEL_OPT)
39d91f98a8Spgoyette #include "opt_compat_netbsd.h"
40d91f98a8Spgoyette #endif
415abbf990Smrg
425abbf990Smrg #include <sys/param.h>
435abbf990Smrg #include <sys/systm.h>
445abbf990Smrg #include <sys/proc.h>
455abbf990Smrg #include <sys/reboot.h>
46d91f98a8Spgoyette #include <sys/syscall.h>
47d91f98a8Spgoyette #include <sys/syscallvar.h>
485abbf990Smrg #include <sys/syscallargs.h>
49874fef37Selad #include <sys/kauth.h>
505abbf990Smrg
51d91f98a8Spgoyette #include <compat/common/compat_mod.h>
52d91f98a8Spgoyette
53d91f98a8Spgoyette static const struct syscall_package kern_xxx_12_syscalls[] = {
54d91f98a8Spgoyette { SYS_compat_12_oreboot, 0, (sy_call_t *)compat_12_sys_reboot },
55d91f98a8Spgoyette { 0, 0, NULL }
56d91f98a8Spgoyette };
57d91f98a8Spgoyette
585abbf990Smrg /* ARGSUSED */
595abbf990Smrg int
compat_12_sys_reboot(struct lwp * l,const struct compat_12_sys_reboot_args * uap,register_t * retval)60d91f98a8Spgoyette compat_12_sys_reboot(struct lwp *l,
61d91f98a8Spgoyette const struct compat_12_sys_reboot_args *uap, register_t *retval)
625abbf990Smrg {
637e2790cfSdsl /* {
645abbf990Smrg syscallarg(int) opt;
657e2790cfSdsl } */
665abbf990Smrg int error;
675abbf990Smrg
6868f43d80Selad if ((error = kauth_authorize_system(l->l_cred,
6968f43d80Selad KAUTH_SYSTEM_REBOOT, 0, NULL, NULL, NULL)) != 0)
705abbf990Smrg return (error);
71599c2405Sthorpej kern_reboot(SCARG(uap, opt), NULL);
725abbf990Smrg return (0);
735abbf990Smrg }
74d91f98a8Spgoyette
75d91f98a8Spgoyette int
kern_xxx_12_init(void)76d91f98a8Spgoyette kern_xxx_12_init(void)
77d91f98a8Spgoyette {
78d91f98a8Spgoyette
79d91f98a8Spgoyette return syscall_establish(NULL, kern_xxx_12_syscalls);
80d91f98a8Spgoyette }
81d91f98a8Spgoyette
82d91f98a8Spgoyette int
kern_xxx_12_fini(void)83d91f98a8Spgoyette kern_xxx_12_fini(void)
84d91f98a8Spgoyette {
85d91f98a8Spgoyette
86d91f98a8Spgoyette return syscall_disestablish(NULL, kern_xxx_12_syscalls);
87d91f98a8Spgoyette }
88