kern_xxx.c (184789) | kern_xxx.c (186564) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. 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 --- 16 unchanged lines hidden (view full) --- 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 27 * SUCH DAMAGE. 28 * 29 * @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. 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 --- 16 unchanged lines hidden (view full) --- 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 27 * SUCH DAMAGE. 28 * 29 * @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/kern/kern_xxx.c 184789 2008-11-09 10:45:13Z ed $"); | 33__FBSDID("$FreeBSD: head/sys/kern/kern_xxx.c 186564 2008-12-29 12:58:45Z ed $"); |
34 35#include "opt_compat.h" 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/sysproto.h> 40#include <sys/kernel.h> 41#include <sys/priv.h> --- 15 unchanged lines hidden (view full) --- 57#endif 58/* ARGSUSED */ 59int 60ogethostname(td, uap) 61 struct thread *td; 62 struct gethostname_args *uap; 63{ 64 int name[2]; | 34 35#include "opt_compat.h" 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/sysproto.h> 40#include <sys/kernel.h> 41#include <sys/priv.h> --- 15 unchanged lines hidden (view full) --- 57#endif 58/* ARGSUSED */ 59int 60ogethostname(td, uap) 61 struct thread *td; 62 struct gethostname_args *uap; 63{ 64 int name[2]; |
65 int error; | |
66 size_t len = uap->len; 67 68 name[0] = CTL_KERN; 69 name[1] = KERN_HOSTNAME; | 65 size_t len = uap->len; 66 67 name[0] = CTL_KERN; 68 name[1] = KERN_HOSTNAME; |
70 mtx_lock(&Giant); 71 error = userland_sysctl(td, name, 2, uap->hostname, &len, 72 1, 0, 0, 0, 0); 73 mtx_unlock(&Giant); 74 return(error); | 69 return (userland_sysctl(td, name, 2, uap->hostname, &len, 70 1, 0, 0, 0, 0)); |
75} 76 77#ifndef _SYS_SYSPROTO_H_ 78struct sethostname_args { 79 char *hostname; 80 u_int len; 81}; 82#endif 83/* ARGSUSED */ 84int 85osethostname(td, uap) 86 struct thread *td; 87 register struct sethostname_args *uap; 88{ 89 int name[2]; 90 int error; 91 92 name[0] = CTL_KERN; 93 name[1] = KERN_HOSTNAME; | 71} 72 73#ifndef _SYS_SYSPROTO_H_ 74struct sethostname_args { 75 char *hostname; 76 u_int len; 77}; 78#endif 79/* ARGSUSED */ 80int 81osethostname(td, uap) 82 struct thread *td; 83 register struct sethostname_args *uap; 84{ 85 int name[2]; 86 int error; 87 88 name[0] = CTL_KERN; 89 name[1] = KERN_HOSTNAME; |
94 mtx_lock(&Giant); 95 error = userland_sysctl(td, name, 2, 0, 0, 0, uap->hostname, 96 uap->len, 0, 0); 97 mtx_unlock(&Giant); 98 return (error); | 90 return (userland_sysctl(td, name, 2, 0, 0, 0, uap->hostname, 91 uap->len, 0, 0)); |
99} 100 101#ifndef _SYS_SYSPROTO_H_ 102struct ogethostid_args { 103 int dummy; 104}; 105#endif 106/* ARGSUSED */ --- 61 unchanged lines hidden (view full) --- 168{ 169 int name[2], error; 170 size_t len; 171 char *s, *us; 172 173 name[0] = CTL_KERN; 174 name[1] = KERN_OSTYPE; 175 len = sizeof (uap->name->sysname); | 92} 93 94#ifndef _SYS_SYSPROTO_H_ 95struct ogethostid_args { 96 int dummy; 97}; 98#endif 99/* ARGSUSED */ --- 61 unchanged lines hidden (view full) --- 161{ 162 int name[2], error; 163 size_t len; 164 char *s, *us; 165 166 name[0] = CTL_KERN; 167 name[1] = KERN_OSTYPE; 168 len = sizeof (uap->name->sysname); |
176 mtx_lock(&Giant); | |
177 error = userland_sysctl(td, name, 2, uap->name->sysname, &len, 178 1, 0, 0, 0, 0); 179 if (error) | 169 error = userland_sysctl(td, name, 2, uap->name->sysname, &len, 170 1, 0, 0, 0, 0); 171 if (error) |
180 goto done2; | 172 return (error); |
181 subyte( uap->name->sysname + sizeof(uap->name->sysname) - 1, 0); 182 183 name[1] = KERN_HOSTNAME; 184 len = sizeof uap->name->nodename; 185 error = userland_sysctl(td, name, 2, uap->name->nodename, &len, 186 1, 0, 0, 0, 0); 187 if (error) | 173 subyte( uap->name->sysname + sizeof(uap->name->sysname) - 1, 0); 174 175 name[1] = KERN_HOSTNAME; 176 len = sizeof uap->name->nodename; 177 error = userland_sysctl(td, name, 2, uap->name->nodename, &len, 178 1, 0, 0, 0, 0); 179 if (error) |
188 goto done2; | 180 return (error); |
189 subyte( uap->name->nodename + sizeof(uap->name->nodename) - 1, 0); 190 191 name[1] = KERN_OSRELEASE; 192 len = sizeof uap->name->release; 193 error = userland_sysctl(td, name, 2, uap->name->release, &len, 194 1, 0, 0, 0, 0); 195 if (error) | 181 subyte( uap->name->nodename + sizeof(uap->name->nodename) - 1, 0); 182 183 name[1] = KERN_OSRELEASE; 184 len = sizeof uap->name->release; 185 error = userland_sysctl(td, name, 2, uap->name->release, &len, 186 1, 0, 0, 0, 0); 187 if (error) |
196 goto done2; | 188 return (error); |
197 subyte( uap->name->release + sizeof(uap->name->release) - 1, 0); 198 199/* 200 name = KERN_VERSION; 201 len = sizeof uap->name->version; 202 error = userland_sysctl(td, name, 2, uap->name->version, &len, 203 1, 0, 0, 0, 0); 204 if (error) | 189 subyte( uap->name->release + sizeof(uap->name->release) - 1, 0); 190 191/* 192 name = KERN_VERSION; 193 len = sizeof uap->name->version; 194 error = userland_sysctl(td, name, 2, uap->name->version, &len, 195 1, 0, 0, 0, 0); 196 if (error) |
205 goto done2; | 197 return (error); |
206 subyte( uap->name->version + sizeof(uap->name->version) - 1, 0); 207*/ 208 209/* 210 * this stupid hackery to make the version field look like FreeBSD 1.1 211 */ 212 for(s = version; *s && *s != '#'; s++); 213 214 for(us = uap->name->version; *s && *s != ':'; s++) { 215 error = subyte( us++, *s); 216 if (error) | 198 subyte( uap->name->version + sizeof(uap->name->version) - 1, 0); 199*/ 200 201/* 202 * this stupid hackery to make the version field look like FreeBSD 1.1 203 */ 204 for(s = version; *s && *s != '#'; s++); 205 206 for(us = uap->name->version; *s && *s != ':'; s++) { 207 error = subyte( us++, *s); 208 if (error) |
217 goto done2; | 209 return (error); |
218 } 219 error = subyte( us++, 0); 220 if (error) | 210 } 211 error = subyte( us++, 0); 212 if (error) |
221 goto done2; | 213 return (error); |
222 223 name[0] = CTL_HW; 224 name[1] = HW_MACHINE; 225 len = sizeof uap->name->machine; 226 error = userland_sysctl(td, name, 2, uap->name->machine, &len, 227 1, 0, 0, 0, 0); 228 if (error) | 214 215 name[0] = CTL_HW; 216 name[1] = HW_MACHINE; 217 len = sizeof uap->name->machine; 218 error = userland_sysctl(td, name, 2, uap->name->machine, &len, 219 1, 0, 0, 0, 0); 220 if (error) |
229 goto done2; | 221 return (error); |
230 subyte( uap->name->machine + sizeof(uap->name->machine) - 1, 0); | 222 subyte( uap->name->machine + sizeof(uap->name->machine) - 1, 0); |
231done2: 232 mtx_unlock(&Giant); 233 return (error); | 223 return (0); |
234} 235 236#ifndef _SYS_SYSPROTO_H_ 237struct getdomainname_args { 238 char *domainname; 239 int len; 240}; 241#endif 242/* ARGSUSED */ 243int 244freebsd4_getdomainname(struct thread *td, 245 struct freebsd4_getdomainname_args *uap) 246{ 247 int name[2]; | 224} 225 226#ifndef _SYS_SYSPROTO_H_ 227struct getdomainname_args { 228 char *domainname; 229 int len; 230}; 231#endif 232/* ARGSUSED */ 233int 234freebsd4_getdomainname(struct thread *td, 235 struct freebsd4_getdomainname_args *uap) 236{ 237 int name[2]; |
248 int error; | |
249 size_t len = uap->len; 250 251 name[0] = CTL_KERN; 252 name[1] = KERN_NISDOMAINNAME; | 238 size_t len = uap->len; 239 240 name[0] = CTL_KERN; 241 name[1] = KERN_NISDOMAINNAME; |
253 mtx_lock(&Giant); 254 error = userland_sysctl(td, name, 2, uap->domainname, &len, 255 1, 0, 0, 0, 0); 256 mtx_unlock(&Giant); 257 return(error); | 242 return (userland_sysctl(td, name, 2, uap->domainname, &len, 243 1, 0, 0, 0, 0)); |
258} 259 260#ifndef _SYS_SYSPROTO_H_ 261struct setdomainname_args { 262 char *domainname; 263 int len; 264}; 265#endif 266/* ARGSUSED */ 267int 268freebsd4_setdomainname(struct thread *td, 269 struct freebsd4_setdomainname_args *uap) 270{ 271 int name[2]; | 244} 245 246#ifndef _SYS_SYSPROTO_H_ 247struct setdomainname_args { 248 char *domainname; 249 int len; 250}; 251#endif 252/* ARGSUSED */ 253int 254freebsd4_setdomainname(struct thread *td, 255 struct freebsd4_setdomainname_args *uap) 256{ 257 int name[2]; |
272 int error; | |
273 274 name[0] = CTL_KERN; 275 name[1] = KERN_NISDOMAINNAME; | 258 259 name[0] = CTL_KERN; 260 name[1] = KERN_NISDOMAINNAME; |
276 mtx_lock(&Giant); 277 error = userland_sysctl(td, name, 2, 0, 0, 0, uap->domainname, 278 uap->len, 0, 0); 279 mtx_unlock(&Giant); 280 return (error); | 261 return (userland_sysctl(td, name, 2, 0, 0, 0, uap->domainname, 262 uap->len, 0, 0)); |
281} 282#endif /* COMPAT_FREEBSD4 */ | 263} 264#endif /* COMPAT_FREEBSD4 */ |