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>
44 #include <sys/mutex.h>
45 #include <sys/sysctl.h>
46 #include <sys/utsname.h>
49 #if defined(COMPAT_43)
51 #ifndef _SYS_SYSPROTO_H_
52 struct gethostname_args {
64 struct gethostname_args *uap;
68 size_t len = uap->len;
71 name[1] = KERN_HOSTNAME;
73 error = userland_sysctl(td, name, 2, uap->hostname, &len,
79 #ifndef _SYS_SYSPROTO_H_
80 struct sethostname_args {
92 register struct sethostname_args *uap;
98 name[1] = KERN_HOSTNAME;
100 error = userland_sysctl(td, name, 2, 0, 0, 0, uap->hostname,
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 error = priv_check(td, PRIV_SETHOSTID);
147 hostid = uap->hostid;
158 struct oquota_args *uap;
162 #endif /* COMPAT_43 */
165 * This is the FreeBSD-1.1 compatable uname(2) interface. These
166 * days it is done in libc as a wrapper around a bunch of sysctl's.
167 * This must maintain the old 1.1 binary ABI.
170 #error "FreeBSD-1.1 uname syscall has been broken"
172 #ifndef _SYS_SYSPROTO_H_
174 struct utsname *name;
185 struct uname_args *uap;
192 name[1] = KERN_OSTYPE;
193 len = sizeof (uap->name->sysname);
195 error = userland_sysctl(td, name, 2, uap->name->sysname, &len,
199 subyte( uap->name->sysname + sizeof(uap->name->sysname) - 1, 0);
201 name[1] = KERN_HOSTNAME;
202 len = sizeof uap->name->nodename;
203 error = userland_sysctl(td, name, 2, uap->name->nodename, &len,
207 subyte( uap->name->nodename + sizeof(uap->name->nodename) - 1, 0);
209 name[1] = KERN_OSRELEASE;
210 len = sizeof uap->name->release;
211 error = userland_sysctl(td, name, 2, uap->name->release, &len,
215 subyte( uap->name->release + sizeof(uap->name->release) - 1, 0);
219 len = sizeof uap->name->version;
220 error = userland_sysctl(td, name, 2, uap->name->version, &len,
224 subyte( uap->name->version + sizeof(uap->name->version) - 1, 0);
228 * this stupid hackery to make the version field look like FreeBSD 1.1
230 for(s = version; *s && *s != '#'; s++);
232 for(us = uap->name->version; *s && *s != ':'; s++) {
233 error = subyte( us++, *s);
237 error = subyte( us++, 0);
242 name[1] = HW_MACHINE;
243 len = sizeof uap->name->machine;
244 error = userland_sysctl(td, name, 2, uap->name->machine, &len,
248 subyte( uap->name->machine + sizeof(uap->name->machine) - 1, 0);
254 #ifndef _SYS_SYSPROTO_H_
255 struct getdomainname_args {
266 getdomainname(td, uap)
268 struct getdomainname_args *uap;
274 domainnamelen = strlen(domainname) + 1;
275 if ((u_int)uap->len > domainnamelen)
276 uap->len = domainnamelen;
277 error = copyout(domainname, uap->domainname, uap->len);
282 #ifndef _SYS_SYSPROTO_H_
283 struct setdomainname_args {
294 setdomainname(td, uap)
296 struct setdomainname_args *uap;
298 int error, domainnamelen;
300 error = priv_check(td, PRIV_SETDOMAINNAME);
304 if ((u_int)uap->len > sizeof (domainname) - 1) {
308 domainnamelen = uap->len;
309 error = copyin(uap->domainname, domainname, uap->len);
310 domainname[domainnamelen] = 0;