|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)sys_machdep.c 7.5 (Berkeley) 6/28/90 ! 7: */ ! 8: ! 9: #include "param.h" ! 10: #include "systm.h" ! 11: #include "user.h" ! 12: #include "ioctl.h" ! 13: #include "file.h" ! 14: #include "proc.h" ! 15: #include "kernel.h" ! 16: #include "mtio.h" ! 17: #include "buf.h" ! 18: #include "trace.h" ! 19: ! 20: #include "dkio.h" ! 21: #include "pte.h" ! 22: #include "../vaxuba/ubareg.h" ! 23: #include "../vaxuba/ubavar.h" ! 24: ! 25: /* ARGSUSED */ ! 26: resuba(p, uap, retval) ! 27: struct proc *p; ! 28: struct args { ! 29: int value; ! 30: } *uap; ! 31: int *retval; ! 32: { ! 33: int error; ! 34: ! 35: if (error = suser(u.u_cred, &u.u_acflag)) ! 36: return (error); ! 37: if (uap->value < numuba) ! 38: ubareset(uap->value); ! 39: return (0); ! 40: } ! 41: ! 42: #ifdef TRACE ! 43: int nvualarm; ! 44: ! 45: vtrace(p, uap, retval) ! 46: struct proc *p; ! 47: register struct args { ! 48: int request; ! 49: int value; ! 50: } *uap; ! 51: int *retval; ! 52: { ! 53: int vdoualarm(); ! 54: ! 55: switch (uap->request) { ! 56: ! 57: case VTR_DISABLE: /* disable a trace point */ ! 58: case VTR_ENABLE: /* enable a trace point */ ! 59: if (uap->value < 0 || uap->value >= TR_NFLAGS) ! 60: return (EINVAL); ! 61: *retval = traceflags[uap->value]; ! 62: traceflags[uap->value] = uap->request; ! 63: break; ! 64: ! 65: case VTR_VALUE: /* return a trace point setting */ ! 66: if (uap->value < 0 || uap->value >= TR_NFLAGS) ! 67: return (EINVAL); ! 68: *retval = traceflags[uap->value]; ! 69: break; ! 70: ! 71: case VTR_UALARM: /* set a real-time ualarm, less than 1 min */ ! 72: if (uap->value <= 0 || uap->value > 60 * hz || nvualarm > 5) ! 73: return (EINVAL); ! 74: nvualarm++; ! 75: timeout(vdoualarm, (caddr_t)p->p_pid, uap->value); ! 76: break; ! 77: ! 78: case VTR_STAMP: ! 79: trace(TR_STAMP, uap->value, p->p_pid); ! 80: break; ! 81: } ! 82: return (0); ! 83: } ! 84: ! 85: vdoualarm(arg) ! 86: int arg; ! 87: { ! 88: register struct proc *p; ! 89: ! 90: p = pfind(arg); ! 91: if (p) ! 92: psignal(p, 16); ! 93: nvualarm--; ! 94: } ! 95: #endif ! 96: ! 97: #ifdef COMPAT ! 98: /* ! 99: * Note: these tables are sorted by ! 100: * ioctl "code" (in ascending order). ! 101: */ ! 102: int dctls[] = { DKIOCHDR, 0 }; ! 103: int fctls[] = { FIOCLEX, FIONCLEX, FIOASYNC, FIONBIO, FIONREAD, 0 }; ! 104: int mctls[] = { MTIOCTOP, MTIOCGET, 0 }; ! 105: int tctls[] = { ! 106: TIOCGETD, TIOCSETD, TIOCHPCL, TIOCMODG, TIOCMODS, ! 107: TIOCGETP, TIOCSETP, TIOCSETN, TIOCEXCL, TIOCNXCL, ! 108: TIOCFLUSH,TIOCSETC, TIOCGETC, TIOCREMOTE,TIOCMGET, ! 109: TIOCMBIC, TIOCMBIS, TIOCMSET, TIOCSTART,TIOCSTOP, ! 110: TIOCPKT, TIOCNOTTY,TIOCSTI, TIOCOUTQ, TIOCGLTC, ! 111: TIOCSLTC, TIOCSPGRP,TIOCGPGRP,TIOCCDTR, TIOCSDTR, ! 112: TIOCCBRK, TIOCSBRK, TIOCLGET, TIOCLSET, TIOCLBIC, ! 113: TIOCLBIS, 0 ! 114: }; ! 115: ! 116: /* ! 117: * Map an old style ioctl command to new. ! 118: */ ! 119: mapioctl(cmd) ! 120: int cmd; ! 121: { ! 122: register int *map, c; ! 123: ! 124: switch ((cmd >> 8) & 0xff) { ! 125: ! 126: case 'd': ! 127: map = dctls; ! 128: break; ! 129: ! 130: case 'f': ! 131: map = fctls; ! 132: break; ! 133: ! 134: case 'm': ! 135: map = mctls; ! 136: break; ! 137: ! 138: case 't': ! 139: map = tctls; ! 140: break; ! 141: ! 142: default: ! 143: return (0); ! 144: } ! 145: while ((c = *map) && (c&0xff) < (cmd&0xff)) ! 146: map++; ! 147: if (c && (c&0xff) == (cmd&0xff)) ! 148: return (c); ! 149: return (0); ! 150: } ! 151: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.