kern_xxx.c revision 1541
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1982, 1986, 1989, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
331541Srgrimes *	@(#)kern_xxx.c	8.2 (Berkeley) 11/14/93
341541Srgrimes */
351541Srgrimes
361541Srgrimes#include <sys/param.h>
371541Srgrimes#include <sys/systm.h>
381541Srgrimes#include <sys/kernel.h>
391541Srgrimes#include <sys/proc.h>
401541Srgrimes#include <sys/reboot.h>
411541Srgrimes#include <vm/vm.h>
421541Srgrimes#include <sys/sysctl.h>
431541Srgrimes
441541Srgrimesstruct reboot_args {
451541Srgrimes	int	opt;
461541Srgrimes};
471541Srgrimes/* ARGSUSED */
481541Srgrimesreboot(p, uap, retval)
491541Srgrimes	struct proc *p;
501541Srgrimes	struct reboot_args *uap;
511541Srgrimes	int *retval;
521541Srgrimes{
531541Srgrimes	int error;
541541Srgrimes
551541Srgrimes	if (error = suser(p->p_ucred, &p->p_acflag))
561541Srgrimes		return (error);
571541Srgrimes	boot(uap->opt);
581541Srgrimes	return (0);
591541Srgrimes}
601541Srgrimes
611541Srgrimes#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
621541Srgrimes
631541Srgrimesstruct gethostname_args {
641541Srgrimes	char	*hostname;
651541Srgrimes	u_int	len;
661541Srgrimes};
671541Srgrimes/* ARGSUSED */
681541Srgrimesogethostname(p, uap, retval)
691541Srgrimes	struct proc *p;
701541Srgrimes	struct gethostname_args *uap;
711541Srgrimes	int *retval;
721541Srgrimes{
731541Srgrimes	int name;
741541Srgrimes
751541Srgrimes	name = KERN_HOSTNAME;
761541Srgrimes	return (kern_sysctl(&name, 1, uap->hostname, &uap->len, 0, 0));
771541Srgrimes}
781541Srgrimes
791541Srgrimesstruct sethostname_args {
801541Srgrimes	char	*hostname;
811541Srgrimes	u_int	len;
821541Srgrimes};
831541Srgrimes/* ARGSUSED */
841541Srgrimesosethostname(p, uap, retval)
851541Srgrimes	struct proc *p;
861541Srgrimes	register struct sethostname_args *uap;
871541Srgrimes	int *retval;
881541Srgrimes{
891541Srgrimes	int name;
901541Srgrimes	int error;
911541Srgrimes
921541Srgrimes	if (error = suser(p->p_ucred, &p->p_acflag))
931541Srgrimes		return (error);
941541Srgrimes	name = KERN_HOSTNAME;
951541Srgrimes	return (kern_sysctl(&name, 1, 0, 0, uap->hostname, uap->len));
961541Srgrimes}
971541Srgrimes
981541Srgrimesextern long hostid;
991541Srgrimes
1001541Srgrimesstruct gethostid_args {
1011541Srgrimes	int	dummy;
1021541Srgrimes};
1031541Srgrimes/* ARGSUSED */
1041541Srgrimesogethostid(p, uap, retval)
1051541Srgrimes	struct proc *p;
1061541Srgrimes	struct gethostid_args *uap;
1071541Srgrimes	int *retval;
1081541Srgrimes{
1091541Srgrimes
1101541Srgrimes	*(long *)retval = hostid;
1111541Srgrimes	return (0);
1121541Srgrimes}
1131541Srgrimes#endif /* COMPAT_43 || COMPAT_SUNOS */
1141541Srgrimes
1151541Srgrimes#ifdef COMPAT_43
1161541Srgrimesstruct sethostid_args {
1171541Srgrimes	long	hostid;
1181541Srgrimes};
1191541Srgrimes/* ARGSUSED */
1201541Srgrimesosethostid(p, uap, retval)
1211541Srgrimes	struct proc *p;
1221541Srgrimes	struct sethostid_args *uap;
1231541Srgrimes	int *retval;
1241541Srgrimes{
1251541Srgrimes	int error;
1261541Srgrimes
1271541Srgrimes	if (error = suser(p->p_ucred, &p->p_acflag))
1281541Srgrimes		return (error);
1291541Srgrimes	hostid = uap->hostid;
1301541Srgrimes	return (0);
1311541Srgrimes}
1321541Srgrimes
1331541Srgrimesoquota()
1341541Srgrimes{
1351541Srgrimes
1361541Srgrimes	return (ENOSYS);
1371541Srgrimes}
1381541Srgrimes#endif /* COMPAT_43 */
139