2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
35 #include "opt_compat.h"
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/sysproto.h>
40 #include <sys/kernel.h>
43 #include <sys/mutex.h>
44 #include <sys/sysctl.h>
45 #include <sys/utsname.h>
48 #if defined(COMPAT_43)
50 #ifndef _SYS_SYSPROTO_H_
51 struct gethostname_args {
63 struct gethostname_args *uap;
67 size_t len = uap->len;
70 name[1] = KERN_HOSTNAME;
72 error = userland_sysctl(td, name, 2, uap->hostname, &len, 1, 0, 0, 0);
77 #ifndef _SYS_SYSPROTO_H_
78 struct sethostname_args {
90 register struct sethostname_args *uap;
96 name[1] = KERN_HOSTNAME;
98 if ((error = suser_cred(td->td_ucred, SUSER_ALLOWJAIL)) == 0) {
99 error = userland_sysctl(td, name, 2, 0, 0, 0,
100 uap->hostname, uap->len, 0);
106 #ifndef _SYS_SYSPROTO_H_
107 struct ogethostid_args {
118 struct ogethostid_args *uap;
121 *(long *)(td->td_retval) = hostid;
124 #endif /* COMPAT_43 */
127 #ifndef _SYS_SYSPROTO_H_
128 struct osethostid_args {
139 struct osethostid_args *uap;
143 if ((error = suser(td)))
146 hostid = uap->hostid;
157 struct oquota_args *uap;
161 #endif /* COMPAT_43 */
164 * This is the FreeBSD-1.1 compatable uname(2) interface. These
165 * days it is done in libc as a wrapper around a bunch of sysctl's.
166 * This must maintain the old 1.1 binary ABI.
169 #error "FreeBSD-1.1 uname syscall has been broken"
171 #ifndef _SYS_SYSPROTO_H_
173 struct utsname *name;
184 struct uname_args *uap;
191 name[1] = KERN_OSTYPE;
192 len = sizeof (uap->name->sysname);
194 error = userland_sysctl(td, name, 2, uap->name->sysname, &len,
198 subyte( uap->name->sysname + sizeof(uap->name->sysname) - 1, 0);
200 name[1] = KERN_HOSTNAME;
201 len = sizeof uap->name->nodename;
202 error = userland_sysctl(td, name, 2, uap->name->nodename, &len,
206 subyte( uap->name->nodename + sizeof(uap->name->nodename) - 1, 0);
208 name[1] = KERN_OSRELEASE;
209 len = sizeof uap->name->release;
210 error = userland_sysctl(td, name, 2, uap->name->release, &len,
214 subyte( uap->name->release + sizeof(uap->name->release) - 1, 0);
218 len = sizeof uap->name->version;
219 error = userland_sysctl(td, name, 2, uap->name->version, &len,
223 subyte( uap->name->version + sizeof(uap->name->version) - 1, 0);
227 * this stupid hackery to make the version field look like FreeBSD 1.1
229 for(s = version; *s && *s != '#'; s++);
231 for(us = uap->name->version; *s && *s != ':'; s++) {
232 error = subyte( us++, *s);
236 error = subyte( us++, 0);
241 name[1] = HW_MACHINE;
242 len = sizeof uap->name->machine;
243 error = userland_sysctl(td, name, 2, uap->name->machine, &len,
247 subyte( uap->name->machine + sizeof(uap->name->machine) - 1, 0);
253 #ifndef _SYS_SYSPROTO_H_
254 struct getdomainname_args {
265 getdomainname(td, uap)
267 struct getdomainname_args *uap;
273 domainnamelen = strlen(domainname) + 1;
274 if ((u_int)uap->len > domainnamelen)
275 uap->len = domainnamelen;
276 error = copyout(domainname, uap->domainname, uap->len);
281 #ifndef _SYS_SYSPROTO_H_
282 struct setdomainname_args {
293 setdomainname(td, uap)
295 struct setdomainname_args *uap;
297 int error, domainnamelen;
300 if ((error = suser(td)))
302 if ((u_int)uap->len > sizeof (domainname) - 1) {
306 domainnamelen = uap->len;
307 error = copyin(uap->domainname, domainname, uap->len);
308 domainname[domainnamelen] = 0;