xref: /original-bsd/sys/kern/kern_xxx.c (revision 82d4dc09)
1 /*
2  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)kern_xxx.c	7.11 (Berkeley) 05/15/90
18  */
19 
20 #include "param.h"
21 #include "systm.h"
22 #include "syscontext.h"
23 #include "kernel.h"
24 #include "proc.h"
25 #include "reboot.h"
26 
27 gethostid()
28 {
29 
30 	u.u_r.r_val1 = hostid;
31 	RETURN (0);
32 }
33 
34 sethostid()
35 {
36 	struct a {
37 		long	hostid;
38 	} *uap = (struct a *)u.u_ap;
39 	int error;
40 
41 	if (error = suser(u.u_cred, &u.u_acflag))
42 		RETURN (error);
43 	hostid = uap->hostid;
44 	RETURN (0);
45 }
46 
47 gethostname()
48 {
49 	register struct a {
50 		char	*hostname;
51 		u_int	len;
52 	} *uap = (struct a *)u.u_ap;
53 
54 	if (uap->len > hostnamelen + 1)
55 		uap->len = hostnamelen + 1;
56 	RETURN (copyout((caddr_t)hostname, (caddr_t)uap->hostname, uap->len));
57 }
58 
59 sethostname()
60 {
61 	register struct a {
62 		char	*hostname;
63 		u_int	len;
64 	} *uap = (struct a *)u.u_ap;
65 	int error;
66 
67 	if (error = suser(u.u_cred, &u.u_acflag))
68 		RETURN (error);
69 	if (uap->len > sizeof (hostname) - 1)
70 		RETURN (EINVAL);
71 	hostnamelen = uap->len;
72 	error = copyin((caddr_t)uap->hostname, hostname, uap->len);
73 	hostname[hostnamelen] = 0;
74 	RETURN (error);
75 }
76 
77 reboot()
78 {
79 	struct a {
80 		int	opt;
81 	};
82 	int error;
83 
84 	if (error = suser(u.u_cred, &u.u_acflag))
85 		RETURN (error);
86 	boot(((struct a *)u.u_ap)->opt);
87 	RETURN (0);
88 }
89 
90 ovhangup()
91 {
92 
93 	RETURN (EINVAL);
94 }
95 
96 oldquota()
97 {
98 
99 	RETURN (EINVAL);
100 }
101