xref: /csrg-svn/sys/kern/kern_xxx.c (revision 37553)
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.5 (Berkeley) 04/26/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 (u.u_error = suser(u.u_cred, &u.u_acflag))
30 		return;
31 	hostid = uap->hostid;
32 }
33 
34 gethostname()
35 {
36 	register struct a {
37 		char	*hostname;
38 		u_int	len;
39 	} *uap = (struct a *)u.u_ap;
40 
41 	if (uap->len > hostnamelen + 1)
42 		uap->len = hostnamelen + 1;
43 	u.u_error = copyout((caddr_t)hostname, (caddr_t)uap->hostname,
44 		uap->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 (u.u_error = suser(u.u_cred, &u.u_acflag))
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 (u.u_error = suser(u.u_cred, &u.u_acflag))
72 		return;
73 	boot(((struct a *)u.u_ap)->opt);
74 }
75