xref: /original-bsd/sys/kern/kern_xxx.c (revision 3d751ffd)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)kern_xxx.c	7.4 (Berkeley) 02/23/89
7  */
8 
9 #include "param.h"
10 #include "systm.h"
11 #include "dir.h"
12 #include "user.h"
13 #include "kernel.h"
14 #include "proc.h"
15 #include "reboot.h"
16 
17 gethostid()
18 {
19 
20 	u.u_r.r_val1 = hostid;
21 }
22 
23 sethostid()
24 {
25 	struct a {
26 		long	hostid;
27 	} *uap = (struct a *)u.u_ap;
28 
29 	if (suser())
30 		hostid = uap->hostid;
31 }
32 
33 gethostname()
34 {
35 	register struct a {
36 		char	*hostname;
37 		u_int	len;
38 	} *uap = (struct a *)u.u_ap;
39 
40 	if (uap->len > hostnamelen + 1)
41 		uap->len = hostnamelen + 1;
42 	u.u_error = copyout((caddr_t)hostname, (caddr_t)uap->hostname,
43 		uap->len);
44 }
45 
46 sethostname()
47 {
48 	register struct a {
49 		char	*hostname;
50 		u_int	len;
51 	} *uap = (struct a *)u.u_ap;
52 
53 	if (!suser())
54 		return;
55 	if (uap->len > sizeof (hostname) - 1) {
56 		u.u_error = EINVAL;
57 		return;
58 	}
59 	hostnamelen = uap->len;
60 	u.u_error = copyin((caddr_t)uap->hostname, hostname, uap->len);
61 	hostname[hostnamelen] = 0;
62 }
63 
64 reboot()
65 {
66 	register struct a {
67 		int	opt;
68 	};
69 
70 	if (suser())
71 		boot(((struct a *)u.u_ap)->opt);
72 }
73