xref: /original-bsd/sys/kern/kern_xxx.c (revision b8338845)
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.7 (Berkeley) 05/05/89
18  */
19 
20 #include "param.h"
21 #include "systm.h"
22 #include "user.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 }
32 
33 sethostid()
34 {
35 	struct a {
36 		long	hostid;
37 	} *uap = (struct a *)u.u_ap;
38 
39 	if (u.u_error = suser(u.u_cred, &u.u_acflag))
40 		return;
41 	hostid = uap->hostid;
42 }
43 
44 gethostname()
45 {
46 	register struct a {
47 		char	*hostname;
48 		u_int	len;
49 	} *uap = (struct a *)u.u_ap;
50 
51 	if (uap->len > hostnamelen + 1)
52 		uap->len = hostnamelen + 1;
53 	u.u_error = copyout((caddr_t)hostname, (caddr_t)uap->hostname,
54 		uap->len);
55 }
56 
57 sethostname()
58 {
59 	register struct a {
60 		char	*hostname;
61 		u_int	len;
62 	} *uap = (struct a *)u.u_ap;
63 
64 	if (u.u_error = suser(u.u_cred, &u.u_acflag))
65 		return;
66 	if (uap->len > sizeof (hostname) - 1) {
67 		u.u_error = EINVAL;
68 		return;
69 	}
70 	hostnamelen = uap->len;
71 	u.u_error = copyin((caddr_t)uap->hostname, hostname, uap->len);
72 	hostname[hostnamelen] = 0;
73 }
74 
75 reboot()
76 {
77 	register struct a {
78 		int	opt;
79 	};
80 
81 	if (u.u_error = suser(u.u_cred, &u.u_acflag))
82 		return;
83 	boot(((struct a *)u.u_ap)->opt);
84 }
85