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