17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 59acbbeafSnn * Common Development and Distribution License (the "License"). 69acbbeafSnn * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22a237e38eSth * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <stdio.h> 297c478bd9Sstevel@tonic-gate #define __EXTENSIONS__ 307c478bd9Sstevel@tonic-gate #include <string.h> 317c478bd9Sstevel@tonic-gate #undef __EXTENSIONS__ 327c478bd9Sstevel@tonic-gate #include <signal.h> 337c478bd9Sstevel@tonic-gate #include <alloca.h> 347c478bd9Sstevel@tonic-gate #include <errno.h> 357c478bd9Sstevel@tonic-gate #include "libproc.h" 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate static const char * 387c478bd9Sstevel@tonic-gate rawfltname(int flt) 397c478bd9Sstevel@tonic-gate { 407c478bd9Sstevel@tonic-gate const char *name; 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate switch (flt) { 437c478bd9Sstevel@tonic-gate case FLTILL: name = "FLTILL"; break; 447c478bd9Sstevel@tonic-gate case FLTPRIV: name = "FLTPRIV"; break; 457c478bd9Sstevel@tonic-gate case FLTBPT: name = "FLTBPT"; break; 467c478bd9Sstevel@tonic-gate case FLTTRACE: name = "FLTTRACE"; break; 477c478bd9Sstevel@tonic-gate case FLTACCESS: name = "FLTACCESS"; break; 487c478bd9Sstevel@tonic-gate case FLTBOUNDS: name = "FLTBOUNDS"; break; 497c478bd9Sstevel@tonic-gate case FLTIOVF: name = "FLTIOVF"; break; 507c478bd9Sstevel@tonic-gate case FLTIZDIV: name = "FLTIZDIV"; break; 517c478bd9Sstevel@tonic-gate case FLTFPE: name = "FLTFPE"; break; 527c478bd9Sstevel@tonic-gate case FLTSTACK: name = "FLTSTACK"; break; 537c478bd9Sstevel@tonic-gate case FLTPAGE: name = "FLTPAGE"; break; 547c478bd9Sstevel@tonic-gate case FLTWATCH: name = "FLTWATCH"; break; 557c478bd9Sstevel@tonic-gate case FLTCPCOVF: name = "FLTCPCOVF"; break; 567c478bd9Sstevel@tonic-gate default: name = NULL; break; 577c478bd9Sstevel@tonic-gate } 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate return (name); 607c478bd9Sstevel@tonic-gate } 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * Return the name of a fault. 647c478bd9Sstevel@tonic-gate * Manufacture a name for unknown fault. 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate char * 677c478bd9Sstevel@tonic-gate proc_fltname(int flt, char *buf, size_t bufsz) 687c478bd9Sstevel@tonic-gate { 697c478bd9Sstevel@tonic-gate const char *name = rawfltname(flt); 707c478bd9Sstevel@tonic-gate size_t len; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate if (bufsz == 0) /* force a program failure */ 737c478bd9Sstevel@tonic-gate return (NULL); 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate if (name != NULL) { 767c478bd9Sstevel@tonic-gate len = strlen(name); 777c478bd9Sstevel@tonic-gate (void) strncpy(buf, name, bufsz); 787c478bd9Sstevel@tonic-gate } else { 797c478bd9Sstevel@tonic-gate len = snprintf(buf, bufsz, "FLT#%d", flt); 807c478bd9Sstevel@tonic-gate } 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate if (len >= bufsz) /* ensure null-termination */ 837c478bd9Sstevel@tonic-gate buf[bufsz-1] = '\0'; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate return (buf); 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * Return the name of a signal. 907c478bd9Sstevel@tonic-gate * Manufacture a name for unknown signal. 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate char * 937c478bd9Sstevel@tonic-gate proc_signame(int sig, char *buf, size_t bufsz) 947c478bd9Sstevel@tonic-gate { 957c478bd9Sstevel@tonic-gate char name[SIG2STR_MAX+4]; 967c478bd9Sstevel@tonic-gate size_t len; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate if (bufsz == 0) /* force a program failure */ 997c478bd9Sstevel@tonic-gate return (NULL); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* sig2str() omits the leading "SIG" */ 1027c478bd9Sstevel@tonic-gate (void) strcpy(name, "SIG"); 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate if (sig2str(sig, name+3) == 0) { 1057c478bd9Sstevel@tonic-gate len = strlen(name); 1067c478bd9Sstevel@tonic-gate (void) strncpy(buf, name, bufsz); 1077c478bd9Sstevel@tonic-gate } else { 1087c478bd9Sstevel@tonic-gate len = snprintf(buf, bufsz, "SIG#%d", sig); 1097c478bd9Sstevel@tonic-gate } 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate if (len >= bufsz) /* ensure null-termination */ 1127c478bd9Sstevel@tonic-gate buf[bufsz-1] = '\0'; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate return (buf); 1157c478bd9Sstevel@tonic-gate } 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate static const char *const systable[] = { 1187c478bd9Sstevel@tonic-gate NULL, /* 0 */ 1197c478bd9Sstevel@tonic-gate "_exit", /* 1 */ 1207c478bd9Sstevel@tonic-gate "forkall", /* 2 */ 1217c478bd9Sstevel@tonic-gate "read", /* 3 */ 1227c478bd9Sstevel@tonic-gate "write", /* 4 */ 1237c478bd9Sstevel@tonic-gate "open", /* 5 */ 1247c478bd9Sstevel@tonic-gate "close", /* 6 */ 1257c478bd9Sstevel@tonic-gate "wait", /* 7 */ 1267c478bd9Sstevel@tonic-gate "creat", /* 8 */ 1277c478bd9Sstevel@tonic-gate "link", /* 9 */ 1287c478bd9Sstevel@tonic-gate "unlink", /* 10 */ 1297c478bd9Sstevel@tonic-gate "exec", /* 11 */ 1307c478bd9Sstevel@tonic-gate "chdir", /* 12 */ 1317c478bd9Sstevel@tonic-gate "time", /* 13 */ 1327c478bd9Sstevel@tonic-gate "mknod", /* 14 */ 1337c478bd9Sstevel@tonic-gate "chmod", /* 15 */ 1347c478bd9Sstevel@tonic-gate "chown", /* 16 */ 1357c478bd9Sstevel@tonic-gate "brk", /* 17 */ 1367c478bd9Sstevel@tonic-gate "stat", /* 18 */ 1377c478bd9Sstevel@tonic-gate "lseek", /* 19 */ 1387c478bd9Sstevel@tonic-gate "getpid", /* 20 */ 1397c478bd9Sstevel@tonic-gate "mount", /* 21 */ 1407c478bd9Sstevel@tonic-gate "umount", /* 22 */ 1417c478bd9Sstevel@tonic-gate "setuid", /* 23 */ 1427c478bd9Sstevel@tonic-gate "getuid", /* 24 */ 1437c478bd9Sstevel@tonic-gate "stime", /* 25 */ 1447c478bd9Sstevel@tonic-gate "ptrace", /* 26 */ 1457c478bd9Sstevel@tonic-gate "alarm", /* 27 */ 1467c478bd9Sstevel@tonic-gate "fstat", /* 28 */ 1477c478bd9Sstevel@tonic-gate "pause", /* 29 */ 1487c478bd9Sstevel@tonic-gate "utime", /* 30 */ 1497c478bd9Sstevel@tonic-gate "stty", /* 31 */ 1507c478bd9Sstevel@tonic-gate "gtty", /* 32 */ 1517c478bd9Sstevel@tonic-gate "access", /* 33 */ 1527c478bd9Sstevel@tonic-gate "nice", /* 34 */ 1537c478bd9Sstevel@tonic-gate "statfs", /* 35 */ 1547c478bd9Sstevel@tonic-gate "sync", /* 36 */ 1557c478bd9Sstevel@tonic-gate "kill", /* 37 */ 1567c478bd9Sstevel@tonic-gate "fstatfs", /* 38 */ 1577c478bd9Sstevel@tonic-gate "pgrpsys", /* 39 */ 1589acbbeafSnn "uucopystr", /* 40 */ 1597c478bd9Sstevel@tonic-gate "dup", /* 41 */ 1607c478bd9Sstevel@tonic-gate "pipe", /* 42 */ 1617c478bd9Sstevel@tonic-gate "times", /* 43 */ 1627c478bd9Sstevel@tonic-gate "profil", /* 44 */ 1637c478bd9Sstevel@tonic-gate "plock", /* 45 */ 1647c478bd9Sstevel@tonic-gate "setgid", /* 46 */ 1657c478bd9Sstevel@tonic-gate "getgid", /* 47 */ 1667c478bd9Sstevel@tonic-gate "signal", /* 48 */ 1677c478bd9Sstevel@tonic-gate "msgsys", /* 49 */ 1687c478bd9Sstevel@tonic-gate "sysi86", /* 50 */ 1697c478bd9Sstevel@tonic-gate "acct", /* 51 */ 1707c478bd9Sstevel@tonic-gate "shmsys", /* 52 */ 1717c478bd9Sstevel@tonic-gate "semsys", /* 53 */ 1727c478bd9Sstevel@tonic-gate "ioctl", /* 54 */ 1737c478bd9Sstevel@tonic-gate "uadmin", /* 55 */ 1747c478bd9Sstevel@tonic-gate NULL, /* 56 */ 1757c478bd9Sstevel@tonic-gate "utssys", /* 57 */ 1767c478bd9Sstevel@tonic-gate "fdsync", /* 58 */ 1777c478bd9Sstevel@tonic-gate "execve", /* 59 */ 1787c478bd9Sstevel@tonic-gate "umask", /* 60 */ 1797c478bd9Sstevel@tonic-gate "chroot", /* 61 */ 1807c478bd9Sstevel@tonic-gate "fcntl", /* 62 */ 1817c478bd9Sstevel@tonic-gate "ulimit", /* 63 */ 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /* The following 6 entries were reserved for the UNIX PC */ 1847c478bd9Sstevel@tonic-gate NULL, /* 64 */ 1857c478bd9Sstevel@tonic-gate NULL, /* 65 */ 1867c478bd9Sstevel@tonic-gate NULL, /* 66 */ 1877c478bd9Sstevel@tonic-gate NULL, /* 67 */ 1887c478bd9Sstevel@tonic-gate NULL, /* 68 */ 1897c478bd9Sstevel@tonic-gate NULL, /* 69 */ 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate "tasksys", /* 70 */ 1927c478bd9Sstevel@tonic-gate "acctctl", /* 71 */ 1937c478bd9Sstevel@tonic-gate "exacctsys", /* 72 */ 1947c478bd9Sstevel@tonic-gate "getpagesizes", /* 73 */ 1957c478bd9Sstevel@tonic-gate "rctlsys", /* 74 */ 1967c478bd9Sstevel@tonic-gate "issetugid", /* 75 */ 1977c478bd9Sstevel@tonic-gate "fsat", /* 76 */ 1987c478bd9Sstevel@tonic-gate "lwp_park", /* 77 */ 1997c478bd9Sstevel@tonic-gate "sendfilev", /* 78 */ 2007c478bd9Sstevel@tonic-gate "rmdir", /* 79 */ 2017c478bd9Sstevel@tonic-gate "mkdir", /* 80 */ 2027c478bd9Sstevel@tonic-gate "getdents", /* 81 */ 2037c478bd9Sstevel@tonic-gate "privsys", /* 82 */ 2047c478bd9Sstevel@tonic-gate "ucredsys", /* 83 */ 2057c478bd9Sstevel@tonic-gate "sysfs", /* 84 */ 2067c478bd9Sstevel@tonic-gate "getmsg", /* 85 */ 2077c478bd9Sstevel@tonic-gate "putmsg", /* 86 */ 2087c478bd9Sstevel@tonic-gate "poll", /* 87 */ 2097c478bd9Sstevel@tonic-gate "lstat", /* 88 */ 2107c478bd9Sstevel@tonic-gate "symlink", /* 89 */ 2117c478bd9Sstevel@tonic-gate "readlink", /* 90 */ 2127c478bd9Sstevel@tonic-gate "setgroups", /* 91 */ 2137c478bd9Sstevel@tonic-gate "getgroups", /* 92 */ 2147c478bd9Sstevel@tonic-gate "fchmod", /* 93 */ 2157c478bd9Sstevel@tonic-gate "fchown", /* 94 */ 2167c478bd9Sstevel@tonic-gate "sigprocmask", /* 95 */ 2177c478bd9Sstevel@tonic-gate "sigsuspend", /* 96 */ 2187c478bd9Sstevel@tonic-gate "sigaltstack", /* 97 */ 2197c478bd9Sstevel@tonic-gate "sigaction", /* 98 */ 2207c478bd9Sstevel@tonic-gate "sigpending", /* 99 */ 2217c478bd9Sstevel@tonic-gate "context", /* 100 */ 2227c478bd9Sstevel@tonic-gate "evsys", /* 101 */ 2237c478bd9Sstevel@tonic-gate "evtrapret", /* 102 */ 2247c478bd9Sstevel@tonic-gate "statvfs", /* 103 */ 2257c478bd9Sstevel@tonic-gate "fstatvfs", /* 104 */ 2267c478bd9Sstevel@tonic-gate "getloadavg", /* 105 */ 2277c478bd9Sstevel@tonic-gate "nfssys", /* 106 */ 2287c478bd9Sstevel@tonic-gate "waitid", /* 107 */ 2297c478bd9Sstevel@tonic-gate "sigsendsys", /* 108 */ 2307c478bd9Sstevel@tonic-gate "hrtsys", /* 109 */ 2317c478bd9Sstevel@tonic-gate "acancel", /* 110 */ 2327c478bd9Sstevel@tonic-gate "async", /* 111 */ 2337c478bd9Sstevel@tonic-gate "priocntlsys", /* 112 */ 2347c478bd9Sstevel@tonic-gate "pathconf", /* 113 */ 2357c478bd9Sstevel@tonic-gate "mincore", /* 114 */ 2367c478bd9Sstevel@tonic-gate "mmap", /* 115 */ 2377c478bd9Sstevel@tonic-gate "mprotect", /* 116 */ 2387c478bd9Sstevel@tonic-gate "munmap", /* 117 */ 2397c478bd9Sstevel@tonic-gate "fpathconf", /* 118 */ 2407c478bd9Sstevel@tonic-gate "vfork", /* 119 */ 2417c478bd9Sstevel@tonic-gate "fchdir", /* 120 */ 2427c478bd9Sstevel@tonic-gate "readv", /* 121 */ 2437c478bd9Sstevel@tonic-gate "writev", /* 122 */ 2447c478bd9Sstevel@tonic-gate "xstat", /* 123 */ 2457c478bd9Sstevel@tonic-gate "lxstat", /* 124 */ 2467c478bd9Sstevel@tonic-gate "fxstat", /* 125 */ 2477c478bd9Sstevel@tonic-gate "xmknod", /* 126 */ 2487c478bd9Sstevel@tonic-gate "NULL", /* 127 */ 2497c478bd9Sstevel@tonic-gate "setrlimit", /* 128 */ 2507c478bd9Sstevel@tonic-gate "getrlimit", /* 129 */ 2517c478bd9Sstevel@tonic-gate "lchown", /* 130 */ 2527c478bd9Sstevel@tonic-gate "memcntl", /* 131 */ 2537c478bd9Sstevel@tonic-gate "getpmsg", /* 132 */ 2547c478bd9Sstevel@tonic-gate "putpmsg", /* 133 */ 2557c478bd9Sstevel@tonic-gate "rename", /* 134 */ 2567c478bd9Sstevel@tonic-gate "uname", /* 135 */ 2577c478bd9Sstevel@tonic-gate "setegid", /* 136 */ 2587c478bd9Sstevel@tonic-gate "sysconfig", /* 137 */ 2597c478bd9Sstevel@tonic-gate "adjtime", /* 138 */ 2607c478bd9Sstevel@tonic-gate "systeminfo", /* 139 */ 261a237e38eSth "sharefs", /* 140 */ 2627c478bd9Sstevel@tonic-gate "seteuid", /* 141 */ 2637c478bd9Sstevel@tonic-gate NULL, /* 142 */ 2647c478bd9Sstevel@tonic-gate "fork1", /* 143 */ 2657c478bd9Sstevel@tonic-gate "sigtimedwait", /* 144 */ 2667c478bd9Sstevel@tonic-gate "lwp_info", /* 145 */ 2677c478bd9Sstevel@tonic-gate "yield", /* 146 */ 2687c478bd9Sstevel@tonic-gate "lwp_sema_wait", /* 147 */ 2697c478bd9Sstevel@tonic-gate "lwp_sema_post", /* 148 */ 2707c478bd9Sstevel@tonic-gate "lwp_sema_trywait", /* 149 */ 2717c478bd9Sstevel@tonic-gate "lwp_detatch", /* 150 */ 2727c478bd9Sstevel@tonic-gate "corectl", /* 151 */ 2737c478bd9Sstevel@tonic-gate "modctl", /* 152 */ 2747c478bd9Sstevel@tonic-gate "fchroot", /* 153 */ 2757c478bd9Sstevel@tonic-gate "utimes", /* 154 */ 2767c478bd9Sstevel@tonic-gate "vhangup", /* 155 */ 2777c478bd9Sstevel@tonic-gate "gettimeofday", /* 156 */ 2787c478bd9Sstevel@tonic-gate "getitimer", /* 157 */ 2797c478bd9Sstevel@tonic-gate "setitimer", /* 158 */ 2807c478bd9Sstevel@tonic-gate "lwp_create", /* 159 */ 2817c478bd9Sstevel@tonic-gate "lwp_exit", /* 160 */ 2827c478bd9Sstevel@tonic-gate "lwp_suspend", /* 161 */ 2837c478bd9Sstevel@tonic-gate "lwp_continue", /* 162 */ 2847c478bd9Sstevel@tonic-gate "lwp_kill", /* 163 */ 2857c478bd9Sstevel@tonic-gate "lwp_self", /* 164 */ 2867c478bd9Sstevel@tonic-gate "lwp_sigmask", /* 165 */ 2877c478bd9Sstevel@tonic-gate "lwp_private", /* 166 */ 2887c478bd9Sstevel@tonic-gate "lwp_wait", /* 167 */ 289*883492d5Sraf "lwp_mutex_wakeup", /* 168 */ 2907c478bd9Sstevel@tonic-gate "lwp_mutex_lock", /* 169 */ 2917c478bd9Sstevel@tonic-gate "lwp_cond_wait", /* 170 */ 2927c478bd9Sstevel@tonic-gate "lwp_cond_signal", /* 171 */ 2937c478bd9Sstevel@tonic-gate "lwp_cond_broadcast", /* 172 */ 2947c478bd9Sstevel@tonic-gate "pread", /* 173 */ 2957c478bd9Sstevel@tonic-gate "pwrite", /* 174 */ 2967c478bd9Sstevel@tonic-gate "llseek", /* 175 */ 2977c478bd9Sstevel@tonic-gate "inst_sync", /* 176 */ 2989acbbeafSnn "brand", /* 177 */ 2997c478bd9Sstevel@tonic-gate "kaio", /* 178 */ 3007c478bd9Sstevel@tonic-gate "cpc", /* 179 */ 3017c478bd9Sstevel@tonic-gate "lgrpsys", /* 180 */ 3027c478bd9Sstevel@tonic-gate "rusagesys", /* 181 */ 3037c478bd9Sstevel@tonic-gate "portfs", /* 182 */ 3047c478bd9Sstevel@tonic-gate "pollsys", /* 183 */ 3057c478bd9Sstevel@tonic-gate NULL, /* 184 */ 3067c478bd9Sstevel@tonic-gate "acl", /* 185 */ 3077c478bd9Sstevel@tonic-gate "auditsys", /* 186 */ 3087c478bd9Sstevel@tonic-gate "processor_bind", /* 187 */ 3097c478bd9Sstevel@tonic-gate "processor_info", /* 188 */ 3107c478bd9Sstevel@tonic-gate "p_online", /* 189 */ 3117c478bd9Sstevel@tonic-gate "sigqueue", /* 190 */ 3127c478bd9Sstevel@tonic-gate "clock_gettime", /* 191 */ 3137c478bd9Sstevel@tonic-gate "clock_settime", /* 192 */ 3147c478bd9Sstevel@tonic-gate "clock_getres", /* 193 */ 3157c478bd9Sstevel@tonic-gate "timer_create", /* 194 */ 3167c478bd9Sstevel@tonic-gate "timer_delete", /* 195 */ 3177c478bd9Sstevel@tonic-gate "timer_settime", /* 196 */ 3187c478bd9Sstevel@tonic-gate "timer_gettime", /* 197 */ 3197c478bd9Sstevel@tonic-gate "timer_getoverrun", /* 198 */ 3207c478bd9Sstevel@tonic-gate "nanosleep", /* 199 */ 3217c478bd9Sstevel@tonic-gate "facl", /* 200 */ 3227c478bd9Sstevel@tonic-gate "door", /* 201 */ 3237c478bd9Sstevel@tonic-gate "setreuid", /* 202 */ 3247c478bd9Sstevel@tonic-gate "setregid", /* 203 */ 3257c478bd9Sstevel@tonic-gate "install_utrap", /* 204 */ 3267c478bd9Sstevel@tonic-gate "signotify", /* 205 */ 3277c478bd9Sstevel@tonic-gate "schedctl", /* 206 */ 3287c478bd9Sstevel@tonic-gate "pset", /* 207 */ 3297c478bd9Sstevel@tonic-gate "sparc_utrap_install", /* 208 */ 3307c478bd9Sstevel@tonic-gate "resolvepath", /* 209 */ 3317c478bd9Sstevel@tonic-gate "lwp_mutex_timedlock", /* 210 */ 3327c478bd9Sstevel@tonic-gate "lwp_sema_timedwait", /* 211 */ 3337c478bd9Sstevel@tonic-gate "lwp_rwlock_sys", /* 212 */ 3347c478bd9Sstevel@tonic-gate "getdents64", /* 213 */ 3357c478bd9Sstevel@tonic-gate "mmap64", /* 214 */ 3367c478bd9Sstevel@tonic-gate "stat64", /* 215 */ 3377c478bd9Sstevel@tonic-gate "lstat64", /* 216 */ 3387c478bd9Sstevel@tonic-gate "fstat64", /* 217 */ 3397c478bd9Sstevel@tonic-gate "statvfs64", /* 218 */ 3407c478bd9Sstevel@tonic-gate "fstatvfs64", /* 219 */ 3417c478bd9Sstevel@tonic-gate "setrlimit64", /* 220 */ 3427c478bd9Sstevel@tonic-gate "getrlimit64", /* 221 */ 3437c478bd9Sstevel@tonic-gate "pread64", /* 222 */ 3447c478bd9Sstevel@tonic-gate "pwrite64", /* 223 */ 3457c478bd9Sstevel@tonic-gate "creat64", /* 224 */ 3467c478bd9Sstevel@tonic-gate "open64", /* 225 */ 3477c478bd9Sstevel@tonic-gate "rpcmod", /* 226 */ 3487c478bd9Sstevel@tonic-gate "zone", /* 227 */ 3497c478bd9Sstevel@tonic-gate "autofssys", /* 228 */ 3507c478bd9Sstevel@tonic-gate "getcwd", /* 229 */ 3517c478bd9Sstevel@tonic-gate "so_socket", /* 230 */ 3527c478bd9Sstevel@tonic-gate "so_socketpair", /* 231 */ 3537c478bd9Sstevel@tonic-gate "bind", /* 232 */ 3547c478bd9Sstevel@tonic-gate "listen", /* 233 */ 3557c478bd9Sstevel@tonic-gate "accept", /* 234 */ 3567c478bd9Sstevel@tonic-gate "connect", /* 235 */ 3577c478bd9Sstevel@tonic-gate "shutdown", /* 236 */ 3587c478bd9Sstevel@tonic-gate "recv", /* 237 */ 3597c478bd9Sstevel@tonic-gate "recvfrom", /* 238 */ 3607c478bd9Sstevel@tonic-gate "recvmsg", /* 239 */ 3617c478bd9Sstevel@tonic-gate "send", /* 240 */ 3627c478bd9Sstevel@tonic-gate "sendmsg", /* 241 */ 3637c478bd9Sstevel@tonic-gate "sendto", /* 242 */ 3647c478bd9Sstevel@tonic-gate "getpeername", /* 243 */ 3657c478bd9Sstevel@tonic-gate "getsockname", /* 244 */ 3667c478bd9Sstevel@tonic-gate "getsockopt", /* 245 */ 3677c478bd9Sstevel@tonic-gate "setsockopt", /* 246 */ 3687c478bd9Sstevel@tonic-gate "sockconfig", /* 247 */ 3697c478bd9Sstevel@tonic-gate "ntp_gettime", /* 248 */ 3707c478bd9Sstevel@tonic-gate "ntp_adjtime", /* 249 */ 3717c478bd9Sstevel@tonic-gate "lwp_mutex_unlock", /* 250 */ 3727c478bd9Sstevel@tonic-gate "lwp_mutex_trylock", /* 251 */ 373*883492d5Sraf "lwp_mutex_register", /* 252 */ 3747c478bd9Sstevel@tonic-gate "cladm", /* 253 */ 3759acbbeafSnn "uucopy", /* 254 */ 3767c478bd9Sstevel@tonic-gate "umount2" /* 255 */ 3777c478bd9Sstevel@tonic-gate }; 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate /* SYSEND == max syscall number + 1 */ 3807c478bd9Sstevel@tonic-gate #define SYSEND (sizeof (systable) / sizeof (systable[0])) 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gate /* 3837c478bd9Sstevel@tonic-gate * Return the name of a system call. 3847c478bd9Sstevel@tonic-gate * Manufacture a name for unknown system call. 3857c478bd9Sstevel@tonic-gate */ 3867c478bd9Sstevel@tonic-gate char * 3877c478bd9Sstevel@tonic-gate proc_sysname(int sys, char *buf, size_t bufsz) 3887c478bd9Sstevel@tonic-gate { 3897c478bd9Sstevel@tonic-gate const char *name; 3907c478bd9Sstevel@tonic-gate size_t len; 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate if (bufsz == 0) /* force a program failure */ 3937c478bd9Sstevel@tonic-gate return (NULL); 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate if (sys >= 0 && sys < SYSEND) 3967c478bd9Sstevel@tonic-gate name = systable[sys]; 3977c478bd9Sstevel@tonic-gate else 3987c478bd9Sstevel@tonic-gate name = NULL; 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate if (name != NULL) { 4017c478bd9Sstevel@tonic-gate len = strlen(name); 4027c478bd9Sstevel@tonic-gate (void) strncpy(buf, name, bufsz); 4037c478bd9Sstevel@tonic-gate } else { 4047c478bd9Sstevel@tonic-gate len = snprintf(buf, bufsz, "SYS#%d", sys); 4057c478bd9Sstevel@tonic-gate } 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate if (len >= bufsz) /* ensure null-termination */ 4087c478bd9Sstevel@tonic-gate buf[bufsz-1] = '\0'; 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate return (buf); 4117c478bd9Sstevel@tonic-gate } 4127c478bd9Sstevel@tonic-gate 4137c478bd9Sstevel@tonic-gate /* 4147c478bd9Sstevel@tonic-gate * Convert a string representation of a fault to the corresponding number. 4157c478bd9Sstevel@tonic-gate */ 4167c478bd9Sstevel@tonic-gate int 4177c478bd9Sstevel@tonic-gate proc_str2flt(const char *str, int *fltnum) 4187c478bd9Sstevel@tonic-gate { 4197c478bd9Sstevel@tonic-gate char *next; 4207c478bd9Sstevel@tonic-gate int i; 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate i = strtol(str, &next, 0); 4237c478bd9Sstevel@tonic-gate if (i > 0 && i <= PRMAXFAULT && *next == '\0') { 4247c478bd9Sstevel@tonic-gate *fltnum = i; 4257c478bd9Sstevel@tonic-gate return (0); 4267c478bd9Sstevel@tonic-gate } 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate for (i = 1; i <= PRMAXFAULT; i++) { 4297c478bd9Sstevel@tonic-gate const char *s = rawfltname(i); 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate if (s && (strcasecmp(s, str) == 0 || 4327c478bd9Sstevel@tonic-gate strcasecmp(s + 3, str) == 0)) { 4337c478bd9Sstevel@tonic-gate *fltnum = i; 4347c478bd9Sstevel@tonic-gate return (0); 4357c478bd9Sstevel@tonic-gate } 4367c478bd9Sstevel@tonic-gate } 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate return (-1); 4397c478bd9Sstevel@tonic-gate } 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate /* 4427c478bd9Sstevel@tonic-gate * Convert a string representation of a signal to the signal number. This 4437c478bd9Sstevel@tonic-gate * functionality is already available in libc, but the interface doesn't 4447c478bd9Sstevel@tonic-gate * optionally accept a "SIG" prefix. We strip that first, and then call libc. 4457c478bd9Sstevel@tonic-gate */ 4467c478bd9Sstevel@tonic-gate int 4477c478bd9Sstevel@tonic-gate proc_str2sig(const char *str, int *signum) 4487c478bd9Sstevel@tonic-gate { 4497c478bd9Sstevel@tonic-gate if (strncasecmp(str, "SIG", 3) == 0) 4507c478bd9Sstevel@tonic-gate str += 3; /* skip prefix */ 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate return (str2sig(str, signum)); 4537c478bd9Sstevel@tonic-gate } 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate /* 4567c478bd9Sstevel@tonic-gate * Convert a string representation of a system call to the corresponding number. 4577c478bd9Sstevel@tonic-gate * We do this by performing a simple linear search of the table above. 4587c478bd9Sstevel@tonic-gate */ 4597c478bd9Sstevel@tonic-gate int 4607c478bd9Sstevel@tonic-gate proc_str2sys(const char *str, int *sysnum) 4617c478bd9Sstevel@tonic-gate { 4627c478bd9Sstevel@tonic-gate char *next; 4637c478bd9Sstevel@tonic-gate int i; 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate i = strtol(str, &next, 0); 4667c478bd9Sstevel@tonic-gate if (i > 0 && i <= PRMAXSYS && *next == '\0') { 4677c478bd9Sstevel@tonic-gate *sysnum = i; 4687c478bd9Sstevel@tonic-gate return (0); 4697c478bd9Sstevel@tonic-gate } 4707c478bd9Sstevel@tonic-gate 4717c478bd9Sstevel@tonic-gate for (i = 1; i < SYSEND; i++) { 4727c478bd9Sstevel@tonic-gate if (systable[i] != NULL && strcmp(systable[i], str) == 0) { 4737c478bd9Sstevel@tonic-gate *sysnum = i; 4747c478bd9Sstevel@tonic-gate return (0); 4757c478bd9Sstevel@tonic-gate } 4767c478bd9Sstevel@tonic-gate } 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate return (-1); 4797c478bd9Sstevel@tonic-gate } 4807c478bd9Sstevel@tonic-gate 4817c478bd9Sstevel@tonic-gate /* 4827c478bd9Sstevel@tonic-gate * Convert a fltset_t to a string representation consisting of canonical 4837c478bd9Sstevel@tonic-gate * machine fault names separated by the given delimeter string. If 4847c478bd9Sstevel@tonic-gate * m is non-zero (TRUE), set members are printed. If m is zero (FALSE), set 4857c478bd9Sstevel@tonic-gate * non-members are printed. If the specified buf is too small to hold the 4867c478bd9Sstevel@tonic-gate * complete formatted set, NULL is returned; otherwise buf is returned. 4877c478bd9Sstevel@tonic-gate */ 4887c478bd9Sstevel@tonic-gate char * 4897c478bd9Sstevel@tonic-gate proc_fltset2str(const fltset_t *set, const char *delim, int m, 4907c478bd9Sstevel@tonic-gate char *buf, size_t len) 4917c478bd9Sstevel@tonic-gate { 4927c478bd9Sstevel@tonic-gate char name[FLT2STR_MAX], *p = buf; 4937c478bd9Sstevel@tonic-gate size_t n; 4947c478bd9Sstevel@tonic-gate int i; 4957c478bd9Sstevel@tonic-gate 4967c478bd9Sstevel@tonic-gate if (buf == NULL || len < 1) { 4977c478bd9Sstevel@tonic-gate errno = EINVAL; 4987c478bd9Sstevel@tonic-gate return (NULL); 4997c478bd9Sstevel@tonic-gate } 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate buf[0] = '\0'; /* Set first byte to \0 */ 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gate for (i = 1; i <= PRMAXFAULT; i++) { 5047c478bd9Sstevel@tonic-gate if ((prismember(set, i) != 0) ^ (m == 0)) { 5057c478bd9Sstevel@tonic-gate (void) proc_fltname(i, name, sizeof (name)); 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate if (buf[0] != '\0') 5087c478bd9Sstevel@tonic-gate n = snprintf(p, len, "%s%s", delim, name); 5097c478bd9Sstevel@tonic-gate else 5107c478bd9Sstevel@tonic-gate n = snprintf(p, len, "%s", name); 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate if (n != strlen(p)) { 5137c478bd9Sstevel@tonic-gate errno = ENAMETOOLONG; /* Output was truncated */ 5147c478bd9Sstevel@tonic-gate return (NULL); 5157c478bd9Sstevel@tonic-gate } 5167c478bd9Sstevel@tonic-gate len -= n; 5177c478bd9Sstevel@tonic-gate p += n; 5187c478bd9Sstevel@tonic-gate } 5197c478bd9Sstevel@tonic-gate } 5207c478bd9Sstevel@tonic-gate return (buf); 5217c478bd9Sstevel@tonic-gate } 5227c478bd9Sstevel@tonic-gate 5237c478bd9Sstevel@tonic-gate /* 5247c478bd9Sstevel@tonic-gate * Convert a sigset_t to a string representation consisting of canonical signal 5257c478bd9Sstevel@tonic-gate * names (without the SIG prefix). Parameters and return values analogous to 5267c478bd9Sstevel@tonic-gate * proc_fltset2str(). 5277c478bd9Sstevel@tonic-gate */ 5287c478bd9Sstevel@tonic-gate char * 5297c478bd9Sstevel@tonic-gate proc_sigset2str(const sigset_t *set, const char *delim, int m, 5307c478bd9Sstevel@tonic-gate char *buf, size_t len) 5317c478bd9Sstevel@tonic-gate { 5327c478bd9Sstevel@tonic-gate char name[SIG2STR_MAX], *p = buf; 5337c478bd9Sstevel@tonic-gate size_t n; 5347c478bd9Sstevel@tonic-gate int i; 5357c478bd9Sstevel@tonic-gate 5367c478bd9Sstevel@tonic-gate if (buf == NULL || len < 1) { 5377c478bd9Sstevel@tonic-gate errno = EINVAL; 5387c478bd9Sstevel@tonic-gate return (NULL); 5397c478bd9Sstevel@tonic-gate } 5407c478bd9Sstevel@tonic-gate 5417c478bd9Sstevel@tonic-gate m = (m != 0); /* Make sure m is 0 or 1 */ 5427c478bd9Sstevel@tonic-gate buf[0] = '\0'; /* Set first byte to \0 */ 5437c478bd9Sstevel@tonic-gate 5447c478bd9Sstevel@tonic-gate /* 5457c478bd9Sstevel@tonic-gate * Unlike proc_fltset2str() and proc_sysset2str(), we don't loop 5467c478bd9Sstevel@tonic-gate * until i <= NSIG here, because sigismember() rejects i == NSIG. 5477c478bd9Sstevel@tonic-gate */ 5487c478bd9Sstevel@tonic-gate for (i = 1; i < NSIG; i++) { 5497c478bd9Sstevel@tonic-gate if (sigismember(set, i) == m) { 5507c478bd9Sstevel@tonic-gate (void) sig2str(i, name); 5517c478bd9Sstevel@tonic-gate 5527c478bd9Sstevel@tonic-gate if (buf[0] != '\0') 5537c478bd9Sstevel@tonic-gate n = snprintf(p, len, "%s%s", delim, name); 5547c478bd9Sstevel@tonic-gate else 5557c478bd9Sstevel@tonic-gate n = snprintf(p, len, "%s", name); 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate if (n != strlen(p)) { 5587c478bd9Sstevel@tonic-gate errno = ENAMETOOLONG; /* Output was truncated */ 5597c478bd9Sstevel@tonic-gate return (NULL); 5607c478bd9Sstevel@tonic-gate } 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate len -= n; 5637c478bd9Sstevel@tonic-gate p += n; 5647c478bd9Sstevel@tonic-gate } 5657c478bd9Sstevel@tonic-gate } 5667c478bd9Sstevel@tonic-gate 5677c478bd9Sstevel@tonic-gate return (buf); 5687c478bd9Sstevel@tonic-gate } 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate /* 5717c478bd9Sstevel@tonic-gate * Convert a sysset_t to a string representation consisting of canonical system 5727c478bd9Sstevel@tonic-gate * call names. Parameters and return values analogous to proc_fltset2str(). 5737c478bd9Sstevel@tonic-gate */ 5747c478bd9Sstevel@tonic-gate char * 5757c478bd9Sstevel@tonic-gate proc_sysset2str(const sysset_t *set, const char *delim, int m, 5767c478bd9Sstevel@tonic-gate char *buf, size_t len) 5777c478bd9Sstevel@tonic-gate { 5787c478bd9Sstevel@tonic-gate char name[SYS2STR_MAX], *p = buf; 5797c478bd9Sstevel@tonic-gate size_t n; 5807c478bd9Sstevel@tonic-gate int i; 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate if (buf == NULL || len < 1) { 5837c478bd9Sstevel@tonic-gate errno = EINVAL; 5847c478bd9Sstevel@tonic-gate return (NULL); 5857c478bd9Sstevel@tonic-gate } 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate buf[0] = '\0'; /* Set first byte to \0 */ 5887c478bd9Sstevel@tonic-gate 5897c478bd9Sstevel@tonic-gate for (i = 1; i <= PRMAXSYS; i++) { 5907c478bd9Sstevel@tonic-gate if ((prismember(set, i) != 0) ^ (m == 0)) { 5917c478bd9Sstevel@tonic-gate (void) proc_sysname(i, name, sizeof (name)); 5927c478bd9Sstevel@tonic-gate 5937c478bd9Sstevel@tonic-gate if (buf[0] != '\0') 5947c478bd9Sstevel@tonic-gate n = snprintf(p, len, "%s%s", delim, name); 5957c478bd9Sstevel@tonic-gate else 5967c478bd9Sstevel@tonic-gate n = snprintf(p, len, "%s", name); 5977c478bd9Sstevel@tonic-gate 5987c478bd9Sstevel@tonic-gate if (n != strlen(p)) { 5997c478bd9Sstevel@tonic-gate errno = ENAMETOOLONG; /* Output was truncated */ 6007c478bd9Sstevel@tonic-gate return (NULL); 6017c478bd9Sstevel@tonic-gate } 6027c478bd9Sstevel@tonic-gate len -= n; 6037c478bd9Sstevel@tonic-gate p += n; 6047c478bd9Sstevel@tonic-gate } 6057c478bd9Sstevel@tonic-gate } 6067c478bd9Sstevel@tonic-gate return (buf); 6077c478bd9Sstevel@tonic-gate } 6087c478bd9Sstevel@tonic-gate 6097c478bd9Sstevel@tonic-gate /* 6107c478bd9Sstevel@tonic-gate * Convert a string representation of a fault set (names separated by 6117c478bd9Sstevel@tonic-gate * one or more of the given delimeters) to a fltset_t. 6127c478bd9Sstevel@tonic-gate * If m is non-zero (TRUE), members of the string representation are set. 6137c478bd9Sstevel@tonic-gate * If m is zero (FALSE), non-members of the string representation are set. 6147c478bd9Sstevel@tonic-gate * This function returns NULL for success. Otherwise it returns a pointer 6157c478bd9Sstevel@tonic-gate * to the token of the string that couldn't be identified as a string 6167c478bd9Sstevel@tonic-gate * representation of a fault. 6177c478bd9Sstevel@tonic-gate */ 6187c478bd9Sstevel@tonic-gate char * 6197c478bd9Sstevel@tonic-gate proc_str2fltset(const char *s, const char *delim, int m, fltset_t *set) 6207c478bd9Sstevel@tonic-gate { 6217c478bd9Sstevel@tonic-gate char *p, *q, *t = alloca(strlen(s) + 1); 6227c478bd9Sstevel@tonic-gate int flt; 6237c478bd9Sstevel@tonic-gate 6247c478bd9Sstevel@tonic-gate if (m) { 6257c478bd9Sstevel@tonic-gate premptyset(set); 6267c478bd9Sstevel@tonic-gate } else { 6277c478bd9Sstevel@tonic-gate prfillset(set); 6287c478bd9Sstevel@tonic-gate } 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gate (void) strcpy(t, s); 6317c478bd9Sstevel@tonic-gate 6327c478bd9Sstevel@tonic-gate for (p = strtok_r(t, delim, &q); p != NULL; 6337c478bd9Sstevel@tonic-gate p = strtok_r(NULL, delim, &q)) { 6347c478bd9Sstevel@tonic-gate if (proc_str2flt(p, &flt) == -1) { 6357c478bd9Sstevel@tonic-gate errno = EINVAL; 6367c478bd9Sstevel@tonic-gate return ((char *)s + (p - t)); 6377c478bd9Sstevel@tonic-gate } 6387c478bd9Sstevel@tonic-gate if (m) 6397c478bd9Sstevel@tonic-gate praddset(set, flt); 6407c478bd9Sstevel@tonic-gate else 6417c478bd9Sstevel@tonic-gate prdelset(set, flt); 6427c478bd9Sstevel@tonic-gate } 6437c478bd9Sstevel@tonic-gate return (NULL); 6447c478bd9Sstevel@tonic-gate } 6457c478bd9Sstevel@tonic-gate 6467c478bd9Sstevel@tonic-gate /* 6477c478bd9Sstevel@tonic-gate * Convert a string representation of a signal set (names with or without the 6487c478bd9Sstevel@tonic-gate * SIG prefix separated by one or more of the given delimeters) to a sigset_t. 6497c478bd9Sstevel@tonic-gate * Parameters and return values analogous to proc_str2fltset(). 6507c478bd9Sstevel@tonic-gate */ 6517c478bd9Sstevel@tonic-gate char * 6527c478bd9Sstevel@tonic-gate proc_str2sigset(const char *s, const char *delim, int m, sigset_t *set) 6537c478bd9Sstevel@tonic-gate { 6547c478bd9Sstevel@tonic-gate char *p, *q, *t = alloca(strlen(s) + 1); 6557c478bd9Sstevel@tonic-gate int sig; 6567c478bd9Sstevel@tonic-gate 6577c478bd9Sstevel@tonic-gate if (m) { 6587c478bd9Sstevel@tonic-gate premptyset(set); 6597c478bd9Sstevel@tonic-gate } else { 6607c478bd9Sstevel@tonic-gate prfillset(set); 6617c478bd9Sstevel@tonic-gate } 6627c478bd9Sstevel@tonic-gate 6637c478bd9Sstevel@tonic-gate (void) strcpy(t, s); 6647c478bd9Sstevel@tonic-gate 6657c478bd9Sstevel@tonic-gate for (p = strtok_r(t, delim, &q); p != NULL; 6667c478bd9Sstevel@tonic-gate p = strtok_r(NULL, delim, &q)) { 6677c478bd9Sstevel@tonic-gate if (proc_str2sig(p, &sig) == -1) { 6687c478bd9Sstevel@tonic-gate errno = EINVAL; 6697c478bd9Sstevel@tonic-gate return ((char *)s + (p - t)); 6707c478bd9Sstevel@tonic-gate } 6717c478bd9Sstevel@tonic-gate if (m) 6727c478bd9Sstevel@tonic-gate praddset(set, sig); 6737c478bd9Sstevel@tonic-gate else 6747c478bd9Sstevel@tonic-gate prdelset(set, sig); 6757c478bd9Sstevel@tonic-gate } 6767c478bd9Sstevel@tonic-gate return (NULL); 6777c478bd9Sstevel@tonic-gate } 6787c478bd9Sstevel@tonic-gate 6797c478bd9Sstevel@tonic-gate /* 6807c478bd9Sstevel@tonic-gate * Convert a string representation of a system call set (names separated by 6817c478bd9Sstevel@tonic-gate * one or more of the given delimeters) to a sysset_t. Parameters and return 6827c478bd9Sstevel@tonic-gate * values analogous to proc_str2fltset(). 6837c478bd9Sstevel@tonic-gate */ 6847c478bd9Sstevel@tonic-gate char * 6857c478bd9Sstevel@tonic-gate proc_str2sysset(const char *s, const char *delim, int m, sysset_t *set) 6867c478bd9Sstevel@tonic-gate { 6877c478bd9Sstevel@tonic-gate char *p, *q, *t = alloca(strlen(s) + 1); 6887c478bd9Sstevel@tonic-gate int sys; 6897c478bd9Sstevel@tonic-gate 6907c478bd9Sstevel@tonic-gate if (m) { 6917c478bd9Sstevel@tonic-gate premptyset(set); 6927c478bd9Sstevel@tonic-gate } else { 6937c478bd9Sstevel@tonic-gate prfillset(set); 6947c478bd9Sstevel@tonic-gate } 6957c478bd9Sstevel@tonic-gate 6967c478bd9Sstevel@tonic-gate (void) strcpy(t, s); 6977c478bd9Sstevel@tonic-gate 6987c478bd9Sstevel@tonic-gate for (p = strtok_r(t, delim, &q); p != NULL; 6997c478bd9Sstevel@tonic-gate p = strtok_r(NULL, delim, &q)) { 7007c478bd9Sstevel@tonic-gate if (proc_str2sys(p, &sys) == -1) { 7017c478bd9Sstevel@tonic-gate errno = EINVAL; 7027c478bd9Sstevel@tonic-gate return ((char *)s + (p - t)); 7037c478bd9Sstevel@tonic-gate } 7047c478bd9Sstevel@tonic-gate if (m) 7057c478bd9Sstevel@tonic-gate praddset(set, sys); 7067c478bd9Sstevel@tonic-gate else 7077c478bd9Sstevel@tonic-gate prdelset(set, sys); 7087c478bd9Sstevel@tonic-gate } 7097c478bd9Sstevel@tonic-gate return (NULL); 7107c478bd9Sstevel@tonic-gate } 711