Annotation of sys/compat/common/kern_info_09.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: kern_info_09.c,v 1.12 2004/06/22 23:52:17 jfb Exp $ */
! 2: /* $NetBSD: kern_info_09.c,v 1.5 1996/02/21 00:10:59 cgd Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1982, 1986, 1991, 1993
! 6: * The Regents of the University of California. All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. Neither the name of the University nor the names of its contributors
! 17: * may be used to endorse or promote products derived from this software
! 18: * without specific prior written permission.
! 19: *
! 20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 30: * SUCH DAMAGE.
! 31: *
! 32: * @(#)subr_xxx.c 8.1 (Berkeley) 6/10/93
! 33: */
! 34:
! 35: #include <sys/param.h>
! 36: #include <sys/systm.h>
! 37: #include <sys/filedesc.h>
! 38: #include <sys/kernel.h>
! 39: #include <sys/proc.h>
! 40: #include <sys/syslog.h>
! 41: #include <sys/unistd.h>
! 42: #include <uvm/uvm_extern.h>
! 43: #include <sys/sysctl.h>
! 44:
! 45: #include <sys/mount.h>
! 46: #include <sys/syscallargs.h>
! 47:
! 48: /*
! 49: * Note that while we no longer have a COMPAT_09 kernel option,
! 50: * there are other COMPAT_* options that need these old functions.
! 51: */
! 52:
! 53: /* ARGSUSED */
! 54: int
! 55: compat_09_sys_getdomainname(p, v, retval)
! 56: struct proc *p;
! 57: void *v;
! 58: register_t *retval;
! 59: {
! 60: struct compat_09_sys_getdomainname_args /* {
! 61: syscallarg(char *) domainname;
! 62: syscallarg(int) len;
! 63: } */ *uap = v;
! 64: int name;
! 65: size_t sz;
! 66:
! 67: name = KERN_DOMAINNAME;
! 68: sz = SCARG(uap,len);
! 69: return (kern_sysctl(&name, 1, SCARG(uap, domainname), &sz, 0, 0, p));
! 70: }
! 71:
! 72:
! 73: /* ARGSUSED */
! 74: int
! 75: compat_09_sys_setdomainname(p, v, retval)
! 76: struct proc *p;
! 77: void *v;
! 78: register_t *retval;
! 79: {
! 80: struct compat_09_sys_setdomainname_args /* {
! 81: syscallarg(char *) domainname;
! 82: syscallarg(int) len;
! 83: } */ *uap = v;
! 84: int name;
! 85: int error;
! 86:
! 87: if ((error = suser(p, 0)) != 0)
! 88: return (error);
! 89: name = KERN_DOMAINNAME;
! 90: return (kern_sysctl(&name, 1, 0, 0, SCARG(uap, domainname),
! 91: SCARG(uap, len), p));
! 92: }
! 93:
! 94: struct outsname {
! 95: char sysname[32];
! 96: char nodename[32];
! 97: char release[32];
! 98: char version[32];
! 99: char machine[32];
! 100: };
! 101:
! 102: /* ARGSUSED */
! 103: int
! 104: compat_09_sys_uname(p, v, retval)
! 105: struct proc *p;
! 106: void *v;
! 107: register_t *retval;
! 108: {
! 109: struct compat_09_sys_uname_args /* {
! 110: syscallarg(struct outsname *) name;
! 111: } */ *uap = v;
! 112: struct outsname outsname;
! 113: const char *cp;
! 114: char *dp, *ep;
! 115:
! 116: strlcpy(outsname.sysname, ostype, sizeof(outsname.sysname));
! 117: strlcpy(outsname.nodename, hostname, sizeof(outsname.nodename));
! 118: strlcpy(outsname.release, osrelease, sizeof(outsname.release));
! 119: dp = outsname.version;
! 120: ep = &outsname.version[sizeof(outsname.version) - 1];
! 121: for (cp = version; *cp && *cp != '('; cp++)
! 122: ;
! 123: for (cp++; *cp && *cp != ')' && dp < ep; cp++)
! 124: *dp++ = *cp;
! 125: for (; *cp && *cp != '#'; cp++)
! 126: ;
! 127: for (; *cp && *cp != ':' && dp < ep; cp++)
! 128: *dp++ = *cp;
! 129: *dp = '\0';
! 130: strlcpy(outsname.machine, MACHINE, sizeof(outsname.machine));
! 131:
! 132: return (copyout((caddr_t)&outsname, (caddr_t)SCARG(uap, name),
! 133: sizeof(struct outsname)));
! 134: }
CVSweb