This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / sys / kern / kern_xxx.c
CommitLineData
15637ed4
RG
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, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
78ed81a3 33 * from: @(#)kern_xxx.c 7.17 (Berkeley) 4/20/91
34 * $Id: kern_xxx.c,v 1.4 1993/10/16 15:24:35 rgrimes Exp $
15637ed4
RG
35 */
36
37#include "param.h"
38#include "systm.h"
39#include "kernel.h"
40#include "proc.h"
41#include "reboot.h"
78ed81a3 42#include "utsname.h"
15637ed4
RG
43
44/* ARGSUSED */
45gethostid(p, uap, retval)
46 struct proc *p;
47 void *uap;
48 long *retval;
49{
50
51 *retval = hostid;
52 return (0);
53}
54
78ed81a3 55struct sethostid_args {
56 long hostid;
57};
58
15637ed4
RG
59/* ARGSUSED */
60sethostid(p, uap, retval)
61 struct proc *p;
78ed81a3 62 struct sethostid_args *uap;
15637ed4
RG
63 int *retval;
64{
65 int error;
66
67 if (error = suser(p->p_ucred, &p->p_acflag))
68 return (error);
69 hostid = uap->hostid;
70 return (0);
71}
72
78ed81a3 73struct gethostname_args {
74 char *hostname;
75 u_int len;
76};
77
15637ed4
RG
78/* ARGSUSED */
79gethostname(p, uap, retval)
80 struct proc *p;
78ed81a3 81 struct gethostname_args *uap;
15637ed4
RG
82 int *retval;
83{
84
85 if (uap->len > hostnamelen + 1)
86 uap->len = hostnamelen + 1;
87 return (copyout((caddr_t)hostname, (caddr_t)uap->hostname, uap->len));
88}
89
78ed81a3 90struct sethostname_args {
91 char *hostname;
92 u_int len;
93};
94
15637ed4
RG
95/* ARGSUSED */
96sethostname(p, uap, retval)
97 struct proc *p;
78ed81a3 98 register struct sethostname_args *uap;
15637ed4
RG
99 int *retval;
100{
101 int error;
102
103 if (error = suser(p->p_ucred, &p->p_acflag))
104 return (error);
105 if (uap->len > sizeof (hostname) - 1)
106 return (EINVAL);
107 hostnamelen = uap->len;
108 error = copyin((caddr_t)uap->hostname, hostname, uap->len);
109 hostname[hostnamelen] = 0;
110 return (error);
111}
112
78ed81a3 113struct getdomainname_args {
114 char *domainname;
115 u_int len;
116};
117
118/* ARGSUSED */
119int
120getdomainname(p, uap, retval)
121 struct proc *p;
122 struct getdomainname_args *uap;
123 int *retval;
124{
125 if (uap->len > domainnamelen + 1)
126 uap->len = domainnamelen + 1;
127 return (copyout((caddr_t)domainname, (caddr_t)uap->domainname, uap->len));
128}
129
130struct setdomainname_args {
131 char *domainname;
132 u_int len;
133};
134
135/* ARGSUSED */
136int
137setdomainname(p, uap, retval)
138 struct proc *p;
139 struct setdomainname_args *uap;
140 int *retval;
141{
142 int error;
143
144 if (error = suser(p->p_ucred, &p->p_acflag))
145 return (error);
146 if (uap->len > sizeof (domainname) - 1)
147 return EINVAL;
148 domainnamelen = uap->len;
149 error = copyin((caddr_t)uap->domainname, domainname, uap->len);
150 domainname[domainnamelen] = 0;
151 return (error);
152}
153
154struct uname_args {
155 struct utsname *name;
156};
157
158/* ARGSUSED */
159int
160uname(p, uap, retval)
161 struct proc *p;
162 struct uname_args *uap;
163 int *retval;
164{
165 bcopy(hostname, utsname.nodename, sizeof(utsname.nodename));
166 utsname.nodename[sizeof(utsname.nodename)-1] = '\0';
167 return (copyout((caddr_t)&utsname, (caddr_t)uap->name,
168 sizeof(struct utsname)));
169}
170
171struct reboot_args {
172 int opt;
173};
174
15637ed4
RG
175/* ARGSUSED */
176reboot(p, uap, retval)
177 struct proc *p;
78ed81a3 178 struct reboot_args *uap;
15637ed4
RG
179 int *retval;
180{
181 int error;
182
183 if (error = suser(p->p_ucred, &p->p_acflag))
184 return (error);
185 boot(uap->opt);
186 return (0);
187}
188
189#ifdef COMPAT_43
190oquota()
191{
192
193 return (ENOSYS);
194}
195#endif