xref: /original-bsd/sys/kern/kern_xxx.c (revision 77040245)
1 /*
2  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)kern_xxx.c	7.19 (Berkeley) 07/10/92
8  */
9 
10 #include "param.h"
11 #include "systm.h"
12 #include "kernel.h"
13 #include "proc.h"
14 #include "reboot.h"
15 
16 char	hostname[MAXHOSTNAMELEN];
17 int	hostnamelen;
18 long	hostid;
19 
20 struct gethostid_args {
21 	int	dummy;
22 };
23 /* ARGSUSED */
24 gethostid(p, uap, retval)
25 	struct proc *p;
26 	struct gethostid_args *uap;
27 	int *retval;
28 {
29 
30 	*(long *)retval = hostid;
31 	return (0);
32 }
33 
34 struct sethostid_args {
35 	long	hostid;
36 };
37 /* ARGSUSED */
38 sethostid(p, uap, retval)
39 	struct proc *p;
40 	struct sethostid_args *uap;
41 	int *retval;
42 {
43 	int error;
44 
45 	if (error = suser(p->p_ucred, &p->p_acflag))
46 		return (error);
47 	hostid = uap->hostid;
48 	return (0);
49 }
50 
51 struct gethostname_args {
52 	char	*hostname;
53 	u_int	len;
54 };
55 /* ARGSUSED */
56 gethostname(p, uap, retval)
57 	struct proc *p;
58 	struct gethostname_args *uap;
59 	int *retval;
60 {
61 
62 	if (uap->len > hostnamelen + 1)
63 		uap->len = hostnamelen + 1;
64 	return (copyout((caddr_t)hostname, (caddr_t)uap->hostname, uap->len));
65 }
66 
67 struct sethostname_args {
68 	char	*hostname;
69 	u_int	len;
70 };
71 /* ARGSUSED */
72 sethostname(p, uap, retval)
73 	struct proc *p;
74 	register struct sethostname_args *uap;
75 	int *retval;
76 {
77 	int error;
78 
79 	if (error = suser(p->p_ucred, &p->p_acflag))
80 		return (error);
81 	if (uap->len > sizeof (hostname) - 1)
82 		return (EINVAL);
83 	hostnamelen = uap->len;
84 	error = copyin((caddr_t)uap->hostname, hostname, uap->len);
85 	hostname[hostnamelen] = 0;
86 	return (error);
87 }
88 
89 struct reboot_args {
90 	int	opt;
91 };
92 /* ARGSUSED */
93 reboot(p, uap, retval)
94 	struct proc *p;
95 	struct reboot_args *uap;
96 	int *retval;
97 {
98 	int error;
99 
100 	if (error = suser(p->p_ucred, &p->p_acflag))
101 		return (error);
102 	boot(uap->opt);
103 	return (0);
104 }
105 
106 #ifdef COMPAT_43
107 oquota()
108 {
109 
110 	return (ENOSYS);
111 }
112 #endif
113