1: /* 2: * Copyright (c) 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: * @(#)init_sysent.c 1.16 (2.11BSD) 2000/2/20 7: */ 8: 9: /* 10: * System call switch table. 11: */ 12: 13: #include "param.h" 14: #include "systm.h" 15: 16: int nosys(); 17: 18: /* 1.1 processes and protection */ 19: int getpid(); 20: int getppid(), fork(),rexit(),execv(),execve(); 21: int wait4(), getuid(),getgid(),getgroups(),setgroups(); 22: int geteuid(), getegid(), getlogin(); 23: int getpgrp(),setpgrp(), setlogin(); 24: int setgid(), setegid(), setuid(), seteuid(); 25: int ucall(); /* 2BSD calls */ 26: 27: /* 1.2 memory management */ 28: int sbrk(); 29: int lock(),phys(),fetchi(),nostk(),fperr(); /* 2BSD calls */ 30: 31: /* 1.3 signals */ 32: int sigstack(),sigreturn(); 33: int sigaction(), sigprocmask(), sigpending(), sigaltstack(), sigsuspend(); 34: int sigwait(), kill(), killpg(); 35: 36: /* 1.4 timing and statistics */ 37: int gettimeofday(),settimeofday(); 38: int getitimer(),setitimer(); 39: int adjtime(); 40: 41: /* 1.5 descriptors */ 42: int getdtablesize(),dup(),dup2(),close(); 43: int pselect(),select(),fcntl(),flock(); 44: 45: /* 1.6 resource controls */ 46: int getpriority(),setpriority(),getrusage(),getrlimit(),setrlimit(); 47: int setquota(),qquota(); 48: 49: /* 1.7 system operation support */ 50: int umount(),smount(); 51: int sync(),reboot(),__sysctl(); 52: 53: /* 2.1 generic operations */ 54: int read(),write(),readv(),writev(),ioctl(); 55: 56: /* 2.2 file system */ 57: int chdir(), fchdir(), chroot(); 58: int mkdir(),rmdir(), chflags(), fchflags(); 59: int open(),mknod(),unlink(),stat(),fstat(),lstat(); 60: int chown(),fchown(),chmod(),fchmod(),utimes(); 61: int link(),symlink(),readlink(),rename(); 62: int lseek(),truncate(),ftruncate(),saccess(),fsync(); 63: int statfs(), fstatfs(), getfsstat(); 64: 65: /* 2.3 communications */ 66: int socket(),bind(),listen(),accept(),connect(); 67: int socketpair(),sendto(),send(),recvfrom(),recv(); 68: int sendmsg(),recvmsg(),shutdown(),setsockopt(),getsockopt(); 69: int getsockname(),getpeername(),pipe(); 70: 71: int umask(); /* XXX */ 72: 73: /* 2.4 processes */ 74: int ptrace(); 75: 76: /* 2.5 terminals */ 77: 78: #ifdef INET 79: #define ifnet(narg, name) narg, name 80: #define errnet(narg, name) narg, name 81: #else 82: int nonet(); 83: #define ifnet(narg, name) 0, nosys 84: #define errnet(narg, name) 0, nonet 85: #endif 86: 87: /* BEGIN JUNK */ 88: int profil(); /* 'cuz sys calls are interruptible */ 89: int vhangup(); /* should just do in exit() */ 90: int vfork(); /* awaiting fork w/ copy on write */ 91: /* END JUNK */ 92: 93: /* 94: * Reserved/unimplemented system calls in the range 0-150 inclusive 95: * are reserved for use in future Berkeley releases. 96: * Additional system calls implemented in vendor and other 97: * redistributions should be placed in the reserved range at the end 98: * of the current calls. 99: */ 100: /* 101: * This table is the switch used to transfer to the appropriate routine for 102: * processing a system call. Each row contains the number of words of 103: * arguments expected in registers, how many on the stack, and a pointer to 104: * the routine. 105: * 106: * The maximum number of direct system calls is 255 since system call numbers 107: * are encoded in the lower byte of the trap instruction -- see trap.c. 108: */ 109: struct sysent sysent[] = { 110: 1, nosys, /* 0 = indir or out-of-range */ 111: 1, rexit, /* 1 = exit */ 112: 0, fork, /* 2 = fork */ 113: 3, read, /* 3 = read */ 114: 3, write, /* 4 = write */ 115: 3, open, /* 5 = open */ 116: 1, close, /* 6 = close */ 117: 4, wait4, /* 7 = wait4 */ 118: 0, nosys, /* 8 = (old creat) */ 119: 2, link, /* 9 = link */ 120: 1, unlink, /* 10 = unlink */ 121: 2, execv, /* 11 = execv */ 122: 1, chdir, /* 12 = chdir */ 123: 1, fchdir, /* 13 = fchdir */ 124: 3, mknod, /* 14 = mknod */ 125: 2, chmod, /* 15 = chmod */ 126: 3, chown, /* 16 = chown; now 3 args */ 127: 2, chflags, /* 17 = chflags */ 128: 2, fchflags, /* 18 = fchflags */ 129: 4, lseek, /* 19 = lseek */ 130: 0, getpid, /* 20 = getpid */ 131: 3, smount, /* 21 = mount */ 132: 1, umount, /* 22 = umount */ 133: 6, __sysctl, /* 23 = __sysctl */ 134: 0, getuid, /* 24 = getuid */ 135: 0, geteuid, /* 25 = geteuid */ 136: 4, ptrace, /* 26 = ptrace */ 137: 0, getppid, /* 27 = getppid */ 138: 2, statfs, /* 28 = statfs */ 139: 2, fstatfs, /* 29 = fstatfs */ 140: 3, getfsstat, /* 30 = getfsstat */ 141: 4, sigaction, /* 31 = sigaction */ 142: 3, sigprocmask, /* 32 = sigprocmask */ 143: 2, saccess, /* 33 = access */ 144: 1, sigpending, /* 34 = sigpending */ 145: 2, sigaltstack, /* 35 = sigaltstack */ 146: 0, sync, /* 36 = sync */ 147: 2, kill, /* 37 = kill */ 148: 2, stat, /* 38 = stat */ 149: 2, getlogin, /* 39 = getlogin */ 150: 2, lstat, /* 40 = lstat */ 151: 1, dup, /* 41 = dup */ 152: 0, pipe, /* 42 = pipe */ 153: 1, setlogin, /* 43 = setlogin */ 154: 4, profil, /* 44 = profil */ 155: 1, setuid, /* 45 = setuid */ 156: 1, seteuid, /* 46 = seteuid */ 157: 0, getgid, /* 47 = getgid */ 158: 0, getegid, /* 48 = getegid */ 159: 1, setgid, /* 49 = setgid */ 160: 1, setegid, /* 50 = setegid */ 161: 0, nosys, /* 51 = unused */ 162: 3, phys, /* 52 = (2.9) set phys addr */ 163: 1, lock, /* 53 = (2.9) lock in core */ 164: 4, ioctl, /* 54 = ioctl */ 165: 1, reboot, /* 55 = reboot */ 166: 2, sigwait, /* 56 = sigwait */ 167: 2, symlink, /* 57 = symlink */ 168: 3, readlink, /* 58 = readlink */ 169: 3, execve, /* 59 = execve */ 170: 1, umask, /* 60 = umask */ 171: 1, chroot, /* 61 = chroot */ 172: 2, fstat, /* 62 = fstat */ 173: 0, nosys, /* 63 = reserved */ 174: 0, nosys, /* 64 = (old getpagesize) */ 175: 6, pselect, /* 65 = pselect */ 176: 0, vfork, /* 66 = vfork */ 177: 0, nosys, /* 67 = unused */ 178: 0, nosys, /* 68 = unused */ 179: 1, sbrk, /* 69 = sbrk */ 180: 0, nosys, /* 70 = unused */ 181: 0, nosys, /* 71 = unused */ 182: 0, nosys, /* 72 = unused */ 183: 0, nosys, /* 73 = unused */ 184: 0, nosys, /* 74 = unused */ 185: 0, nosys, /* 75 = unused */ 186: 0, vhangup, /* 76 = vhangup */ 187: 0, nosys, /* 77 = unused */ 188: 0, nosys, /* 78 = unused */ 189: 2, getgroups, /* 79 = getgroups */ 190: 2, setgroups, /* 80 = setgroups */ 191: 1, getpgrp, /* 81 = getpgrp */ 192: 2, setpgrp, /* 82 = setpgrp */ 193: 3, setitimer, /* 83 = setitimer */ 194: 0, nosys, /* 84 = (old wait,wait3) */ 195: 0, nosys, /* 85 = unused */ 196: 2, getitimer, /* 86 = getitimer */ 197: 0, nosys, /* 87 = (old gethostname) */ 198: 0, nosys, /* 88 = (old sethostname) */ 199: 0, getdtablesize, /* 89 = getdtablesize */ 200: 2, dup2, /* 90 = dup2 */ 201: 0, nosys, /* 91 = unused */ 202: 3, fcntl, /* 92 = fcntl */ 203: 5, select, /* 93 = select */ 204: 0, nosys, /* 94 = unused */ 205: 1, fsync, /* 95 = fsync */ 206: 3, setpriority, /* 96 = setpriority */ 207: errnet(3, socket), /* 97 = socket */ 208: ifnet(3, connect), /* 98 = connect */ 209: ifnet(3, accept), /* 99 = accept */ 210: 2, getpriority, /* 100 = getpriority */ 211: ifnet(4, send), /* 101 = send */ 212: ifnet(4, recv), /* 102 = recv */ 213: 1, sigreturn, /* 103 = sigreturn */ 214: ifnet(3, bind), /* 104 = bind */ 215: ifnet(5, setsockopt), /* 105 = setsockopt */ 216: ifnet(2, listen), /* 106 = listen */ 217: 1, sigsuspend, /* 107 = sigsuspend */ 218: 0, nosys, /* 108 = (old sigvec) */ 219: 0, nosys, /* 109 = (old sigblock) */ 220: 0, nosys, /* 110 = (old sigsetmask) */ 221: 0, nosys, /* 111 = (old sigpause) */ 222: 2, sigstack, /* 112 = sigstack COMPAT-43 */ 223: ifnet(3, recvmsg), /* 113 = recvmsg */ 224: ifnet(3, sendmsg), /* 114 = sendmsg */ 225: 0, nosys, /* 115 = unused */ 226: 2, gettimeofday, /* 116 = gettimeofday */ 227: 2, getrusage, /* 117 = getrusage */ 228: ifnet(5, getsockopt), /* 118 = getsockopt */ 229: 0, nosys, /* 119 = unused */ 230: 3, readv, /* 120 = readv */ 231: 3, writev, /* 121 = writev */ 232: 2, settimeofday, /* 122 = settimeofday */ 233: 3, fchown, /* 123 = fchown */ 234: 2, fchmod, /* 124 = fchmod */ 235: ifnet(6, recvfrom), /* 125 = recvfrom */ 236: 0, nosys, /* 126 = (old setreuid) */ 237: 0, nosys, /* 127 = (old setregid) */ 238: 2, rename, /* 128 = rename */ 239: 3, truncate, /* 129 = truncate */ 240: 3, ftruncate, /* 130 = ftruncate */ 241: 2, flock, /* 131 = flock */ 242: 0, nosys, /* 132 = nosys */ 243: ifnet(6, sendto), /* 133 = sendto */ 244: ifnet(2, shutdown), /* 134 = shutdown */ 245: errnet(4, socketpair), /* 135 = socketpair */ 246: 2, mkdir, /* 136 = mkdir */ 247: 1, rmdir, /* 137 = rmdir */ 248: 2, utimes, /* 138 = utimes */ 249: 0, nosys, /* 139 = unused */ 250: 2, adjtime, /* 140 = adjtime */ 251: ifnet(3, getpeername), /* 141 = getpeername */ 252: 0, nosys, /* 142 = (old gethostid) */ 253: 0, nosys, /* 143 = (old sethostid) */ 254: 2, getrlimit, /* 144 = getrlimit */ 255: 2, setrlimit, /* 145 = setrlimit */ 256: 2, killpg, /* 146 = killpg */ 257: 0, nosys, /* 147 = nosys */ 258: 2, setquota, /* 148 = quota */ 259: 4, qquota, /* 149 = qquota */ 260: ifnet(3, getsockname), /* 150 = getsockname */ 261: /* 262: * Syscalls 151-180 inclusive are reserved for vendor-specific 263: * system calls. (This includes various calls added for compatibity 264: * with other Unix variants.) 265: */ 266: 267: /* 268: * 2BSD special calls 269: */ 270: 0, nosys, /* 151 = unused */ 271: 0, nostk, /* 152 = nostk */ 272: 1, fetchi, /* 153 = fetchi */ 273: 4, ucall, /* 154 = ucall */ 274: 0, fperr, /* 155 = fperr */ 275: }; 276: 277: int nsysent = sizeof (sysent) / sizeof (sysent[0]);