xref: /original-bsd/sys/kern/kern_xxx.c (revision 048a349a)
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.3 (Berkeley) 08/27/88
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 	register u_int len;
40 
41 	len = uap->len;
42 	if (len > hostnamelen + 1)
43 		len = hostnamelen + 1;
44 	u.u_error = copyout((caddr_t)hostname, (caddr_t)uap->hostname, len);
45 }
46 
47 sethostname()
48 {
49 	register struct a {
50 		char	*hostname;
51 		u_int	len;
52 	} *uap = (struct a *)u.u_ap;
53 
54 	if (!suser())
55 		return;
56 	if (uap->len > sizeof (hostname) - 1) {
57 		u.u_error = EINVAL;
58 		return;
59 	}
60 	hostnamelen = uap->len;
61 	u.u_error = copyin((caddr_t)uap->hostname, hostname, uap->len);
62 	hostname[hostnamelen] = 0;
63 }
64 
65 reboot()
66 {
67 	register struct a {
68 		int	opt;
69 	};
70 
71 	if (suser())
72 		boot(((struct a *)u.u_ap)->opt);
73 }
74