Annotation of sys/compat/osf1/osf1_resource.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: osf1_resource.c,v 1.1 2000/08/04 15:47:55 ericj Exp $ */
! 2: /* $NetBSD: osf1_resource.c,v 1.1 1999/05/01 05:41:56 cgd Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
! 6: *
! 7: * Redistribution and use in source and binary forms, with or without
! 8: * modification, are permitted provided that the following conditions
! 9: * are met:
! 10: * 1. Redistributions of source code must retain the above copyright
! 11: * notice, this list of conditions and the following disclaimer.
! 12: * 2. Redistributions in binary form must reproduce the above copyright
! 13: * notice, this list of conditions and the following disclaimer in the
! 14: * documentation and/or other materials provided with the distribution.
! 15: * 3. All advertising materials mentioning features or use of this software
! 16: * must display the following acknowledgement:
! 17: * This product includes software developed by Christopher G. Demetriou
! 18: * for the NetBSD Project.
! 19: * 4. The name of the author may not be used to endorse or promote products
! 20: * derived from this software without specific prior written permission
! 21: *
! 22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 25: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 26: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 27: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 28: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 29: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 30: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 31: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 32: */
! 33:
! 34: #include <sys/param.h>
! 35: #include <sys/systm.h>
! 36: #include <sys/proc.h>
! 37: #include <sys/mount.h>
! 38: #include <sys/syscallargs.h>
! 39: #include <sys/resource.h>
! 40: #include <sys/resourcevar.h>
! 41:
! 42: #include <compat/osf1/osf1.h>
! 43: #include <compat/osf1/osf1_syscallargs.h>
! 44: #include <compat/osf1/osf1_cvt.h>
! 45:
! 46: int
! 47: osf1_sys_getrlimit(p, v, retval)
! 48: struct proc *p;
! 49: void *v;
! 50: register_t *retval;
! 51: {
! 52: struct osf1_sys_getrlimit_args *uap = v;
! 53: struct sys_getrlimit_args a;
! 54:
! 55: switch (SCARG(uap, which)) {
! 56: case OSF1_RLIMIT_CPU:
! 57: SCARG(&a, which) = RLIMIT_CPU;
! 58: break;
! 59: case OSF1_RLIMIT_FSIZE:
! 60: SCARG(&a, which) = RLIMIT_FSIZE;
! 61: break;
! 62: case OSF1_RLIMIT_DATA:
! 63: SCARG(&a, which) = RLIMIT_DATA;
! 64: break;
! 65: case OSF1_RLIMIT_STACK:
! 66: SCARG(&a, which) = RLIMIT_STACK;
! 67: break;
! 68: case OSF1_RLIMIT_CORE:
! 69: SCARG(&a, which) = RLIMIT_CORE;
! 70: break;
! 71: case OSF1_RLIMIT_RSS:
! 72: SCARG(&a, which) = RLIMIT_RSS;
! 73: break;
! 74: case OSF1_RLIMIT_NOFILE:
! 75: SCARG(&a, which) = RLIMIT_NOFILE;
! 76: break;
! 77: case OSF1_RLIMIT_AS: /* unhandled */
! 78: default:
! 79: return (EINVAL);
! 80: }
! 81:
! 82: /* XXX should translate */
! 83: SCARG(&a, rlp) = SCARG(uap, rlp);
! 84:
! 85: return sys_getrlimit(p, &a, retval);
! 86: }
! 87:
! 88: int
! 89: osf1_sys_getrusage(p, v, retval)
! 90: struct proc *p;
! 91: void *v;
! 92: register_t *retval;
! 93: {
! 94: struct osf1_sys_getrusage_args *uap = v;
! 95: struct sys_getrusage_args a;
! 96: struct osf1_rusage osf1_rusage;
! 97: struct rusage netbsd_rusage;
! 98: caddr_t sg;
! 99: int error;
! 100:
! 101: switch (SCARG(uap, who)) {
! 102: case OSF1_RUSAGE_SELF:
! 103: SCARG(&a, who) = RUSAGE_SELF;
! 104: break;
! 105:
! 106: case OSF1_RUSAGE_CHILDREN:
! 107: SCARG(&a, who) = RUSAGE_CHILDREN;
! 108: break;
! 109:
! 110: case OSF1_RUSAGE_THREAD: /* XXX not supported */
! 111: default:
! 112: return (EINVAL);
! 113: }
! 114:
! 115: sg = stackgap_init(p->p_emul);
! 116: SCARG(&a, rusage) = stackgap_alloc(&sg, sizeof netbsd_rusage);
! 117:
! 118: error = sys_getrusage(p, &a, retval);
! 119: if (error == 0)
! 120: error = copyin((caddr_t)SCARG(&a, rusage),
! 121: (caddr_t)&netbsd_rusage, sizeof netbsd_rusage);
! 122: if (error == 0) {
! 123: osf1_cvt_rusage_from_native(&netbsd_rusage, &osf1_rusage);
! 124: error = copyout((caddr_t)&osf1_rusage,
! 125: (caddr_t)SCARG(uap, rusage), sizeof osf1_rusage);
! 126: }
! 127:
! 128: return (error);
! 129: }
! 130:
! 131: int
! 132: osf1_sys_setrlimit(p, v, retval)
! 133: struct proc *p;
! 134: void *v;
! 135: register_t *retval;
! 136: {
! 137: struct osf1_sys_setrlimit_args *uap = v;
! 138: struct sys_setrlimit_args a;
! 139:
! 140: switch (SCARG(uap, which)) {
! 141: case OSF1_RLIMIT_CPU:
! 142: SCARG(&a, which) = RLIMIT_CPU;
! 143: break;
! 144: case OSF1_RLIMIT_FSIZE:
! 145: SCARG(&a, which) = RLIMIT_FSIZE;
! 146: break;
! 147: case OSF1_RLIMIT_DATA:
! 148: SCARG(&a, which) = RLIMIT_DATA;
! 149: break;
! 150: case OSF1_RLIMIT_STACK:
! 151: SCARG(&a, which) = RLIMIT_STACK;
! 152: break;
! 153: case OSF1_RLIMIT_CORE:
! 154: SCARG(&a, which) = RLIMIT_CORE;
! 155: break;
! 156: case OSF1_RLIMIT_RSS:
! 157: SCARG(&a, which) = RLIMIT_RSS;
! 158: break;
! 159: case OSF1_RLIMIT_NOFILE:
! 160: SCARG(&a, which) = RLIMIT_NOFILE;
! 161: break;
! 162: case OSF1_RLIMIT_AS: /* unhandled */
! 163: default:
! 164: return (EINVAL);
! 165: }
! 166:
! 167: /* XXX should translate */
! 168: SCARG(&a, rlp) = SCARG(uap, rlp);
! 169:
! 170: return sys_setrlimit(p, &a, retval);
! 171: }
CVSweb