1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26 /*
27 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
28 * Copyright (c) 2018 Joyent, Inc.
29 * Copyright 2022 Oxide Computer Company
30 */
31
32 /*
33 * String conversion routines the system structs found in
34 * Solaris core file note sections. These items are not
35 * ELF constructs. However, elfdump contains code for decoding
36 * them, and therefore requires formatting support.
37 */
38 #include <stdio.h>
39 #include <procfs.h>
40 #include <sys/corectl.h>
41 #include <sys/secflags.h>
42 #include <string.h>
43 #include <_conv.h>
44 #include <corenote_msg.h>
45
46 const char *
conv_cnote_type(Word type,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)47 conv_cnote_type(Word type, Conv_fmt_flags_t fmt_flags,
48 Conv_inv_buf_t *inv_buf)
49 {
50 static const Msg types[] = {
51 MSG_NT_PRSTATUS, MSG_NT_PRFPREG,
52 MSG_NT_PRPSINFO, MSG_NT_PRXREG,
53 MSG_NT_PLATFORM, MSG_NT_AUXV,
54 MSG_NT_GWINDOWS, MSG_NT_ASRS,
55 MSG_NT_LDT, MSG_NT_PSTATUS,
56 0, 0,
57 MSG_NT_PSINFO, MSG_NT_PRCRED,
58 MSG_NT_UTSNAME, MSG_NT_LWPSTATUS,
59 MSG_NT_LWPSINFO, MSG_NT_PRPRIV,
60 MSG_NT_PRPRIVINFO, MSG_NT_CONTENT,
61 MSG_NT_ZONENAME, MSG_NT_FDINFO,
62 MSG_NT_SPYMASTER, MSG_NT_SECFLAGS,
63 MSG_NT_LWPNAME, MSG_NT_UPANIC
64 };
65 #if NT_NUM != NT_UPANIC
66 #error "NT_NUM has grown. Update core note types[]"
67 #endif
68 static const conv_ds_msg_t ds_types = {
69 CONV_DS_MSG_INIT(NT_PRSTATUS, types) };
70 static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_types), NULL };
71
72
73 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, type, ds, fmt_flags,
74 inv_buf));
75 }
76
77
78 const char *
conv_cnote_auxv_type(Word type,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)79 conv_cnote_auxv_type(Word type, Conv_fmt_flags_t fmt_flags,
80 Conv_inv_buf_t *inv_buf)
81 {
82 static const Msg types_0_22[] = {
83 MSG_AUXV_AT_NULL, MSG_AUXV_AT_IGNORE,
84 MSG_AUXV_AT_EXECFD, MSG_AUXV_AT_PHDR,
85 MSG_AUXV_AT_PHENT, MSG_AUXV_AT_PHNUM,
86 MSG_AUXV_AT_PAGESZ, MSG_AUXV_AT_BASE,
87 MSG_AUXV_AT_FLAGS, MSG_AUXV_AT_ENTRY,
88 MSG_AUXV_AT_NOTELF, MSG_AUXV_AT_UID,
89 MSG_AUXV_AT_EUID, MSG_AUXV_AT_GID,
90 MSG_AUXV_AT_EGID, MSG_AUXV_AT_PLATFORM,
91 MSG_AUXV_AT_HWCAP, MSG_AUXV_AT_CLKTCK,
92 MSG_AUXV_AT_FPUCW, MSG_AUXV_AT_DCACHEBSIZE,
93 MSG_AUXV_AT_ICACHEBSIZE, MSG_AUXV_AT_UCACHEBSIZE,
94 MSG_AUXV_AT_IGNOREPPC
95 };
96 static const conv_ds_msg_t ds_types_0_22 = {
97 CONV_DS_MSG_INIT(0, types_0_22) };
98
99 static const Msg types_2000_2011[] = {
100 MSG_AUXV_AT_SUN_UID, MSG_AUXV_AT_SUN_RUID,
101 MSG_AUXV_AT_SUN_GID, MSG_AUXV_AT_SUN_RGID,
102 MSG_AUXV_AT_SUN_LDELF, MSG_AUXV_AT_SUN_LDSHDR,
103 MSG_AUXV_AT_SUN_LDNAME, MSG_AUXV_AT_SUN_LPAGESZ,
104 MSG_AUXV_AT_SUN_PLATFORM, MSG_AUXV_AT_SUN_HWCAP,
105 MSG_AUXV_AT_SUN_IFLUSH, MSG_AUXV_AT_SUN_CPU
106 };
107 static const conv_ds_msg_t ds_types_2000_2011 = {
108 CONV_DS_MSG_INIT(2000, types_2000_2011) };
109
110 static const Msg types_2014_2029[] = {
111 MSG_AUXV_AT_SUN_EXECNAME, MSG_AUXV_AT_SUN_MMU,
112 MSG_AUXV_AT_SUN_LDDATA, MSG_AUXV_AT_SUN_AUXFLAGS,
113 MSG_AUXV_AT_SUN_EMULATOR, MSG_AUXV_AT_SUN_BRANDNAME,
114 MSG_AUXV_AT_SUN_BRAND_AUX1, MSG_AUXV_AT_SUN_BRAND_AUX2,
115 MSG_AUXV_AT_SUN_BRAND_AUX3, MSG_AUXV_AT_SUN_HWCAP2,
116 0, 0,
117 MSG_AUXV_AT_SUN_COMMPAGE, MSG_AUXV_AT_SUN_FPTYPE,
118 MSG_AUXV_AT_SUN_FPSIZE, MSG_AUXV_AT_SUN_HWCAP3
119 };
120 static const conv_ds_msg_t ds_types_2014_2029 = {
121 CONV_DS_MSG_INIT(2014, types_2014_2029) };
122
123 static const conv_ds_t *ds[] = {
124 CONV_DS_ADDR(ds_types_0_22), CONV_DS_ADDR(ds_types_2000_2011),
125 CONV_DS_ADDR(ds_types_2014_2029), NULL };
126
127 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, type, ds, fmt_flags,
128 inv_buf));
129 }
130
131
132 const char *
conv_cnote_signal(Word sig,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)133 conv_cnote_signal(Word sig, Conv_fmt_flags_t fmt_flags,
134 Conv_inv_buf_t *inv_buf)
135 {
136 static const Msg sigarr[] = {
137 MSG_SIGHUP, MSG_SIGINT,
138 MSG_SIGQUIT, MSG_SIGILL,
139 MSG_SIGTRAP, MSG_SIGABRT,
140 MSG_SIGEMT, MSG_SIGFPE,
141 MSG_SIGKILL, MSG_SIGBUS,
142 MSG_SIGSEGV, MSG_SIGSYS,
143 MSG_SIGPIPE, MSG_SIGALRM,
144 MSG_SIGTERM, MSG_SIGUSR1,
145 MSG_SIGUSR2, MSG_SIGCHLD,
146 MSG_SIGPWR, MSG_SIGWINCH,
147 MSG_SIGURG, MSG_SIGPOLL,
148 MSG_SIGSTOP, MSG_SIGTSTP,
149 MSG_SIGCONT, MSG_SIGTTIN,
150 MSG_SIGTTOU, MSG_SIGVTALRM,
151 MSG_SIGPROF, MSG_SIGXCPU,
152 MSG_SIGXFSZ, MSG_SIGWAITING,
153 MSG_SIGLWP, MSG_SIGFREEZE,
154 MSG_SIGTHAW, MSG_SIGCANCEL,
155 MSG_SIGLOST, MSG_SIGXRES,
156 MSG_SIGJVM1, MSG_SIGJVM2,
157 };
158 static const conv_ds_msg_t ds_sigarr = {
159 CONV_DS_MSG_INIT(SIGHUP, sigarr) };
160
161 static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_sigarr), NULL };
162
163 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, sig, ds, fmt_flags,
164 inv_buf));
165 }
166
167
168 const char *
conv_cnote_fault(Word flt,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)169 conv_cnote_fault(Word flt, Conv_fmt_flags_t fmt_flags,
170 Conv_inv_buf_t *inv_buf)
171 {
172 static const Msg fltarr[] = {
173 MSG_FLTILL, MSG_FLTPRIV,
174 MSG_FLTBPT, MSG_FLTTRACE,
175 MSG_FLTACCESS, MSG_FLTBOUNDS,
176 MSG_FLTIOVF, MSG_FLTIZDIV,
177 MSG_FLTFPE, MSG_FLTSTACK,
178 MSG_FLTPAGE, MSG_FLTWATCH,
179 MSG_FLTCPCOVF
180
181 };
182 static const conv_ds_msg_t ds_fltarr = {
183 CONV_DS_MSG_INIT(FLTILL, fltarr) };
184
185 static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_fltarr), NULL };
186
187 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, flt, ds, fmt_flags,
188 inv_buf));
189 }
190
191
192 const char *
conv_cnote_syscall(Word sysnum,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)193 conv_cnote_syscall(Word sysnum, Conv_fmt_flags_t fmt_flags,
194 Conv_inv_buf_t *inv_buf)
195 {
196 static const Msg sysnumarr[] = {
197 MSG_SYS_EXIT, MSG_SYS_2,
198 MSG_SYS_READ, MSG_SYS_WRITE,
199 MSG_SYS_OPEN, MSG_SYS_CLOSE,
200 MSG_SYS_7, MSG_SYS_8,
201 MSG_SYS_LINK, MSG_SYS_UNLINK,
202 MSG_SYS_11, MSG_SYS_CHDIR,
203 MSG_SYS_TIME, MSG_SYS_MKNOD,
204 MSG_SYS_CHMOD, MSG_SYS_CHOWN,
205 MSG_SYS_BRK, MSG_SYS_STAT,
206 MSG_SYS_LSEEK, MSG_SYS_GETPID,
207 MSG_SYS_MOUNT, MSG_SYS_22,
208 MSG_SYS_SETUID, MSG_SYS_GETUID,
209 MSG_SYS_STIME, MSG_SYS_PCSAMPLE,
210 MSG_SYS_ALARM, MSG_SYS_FSTAT,
211 MSG_SYS_PAUSE, MSG_SYS_30,
212 MSG_SYS_STTY, MSG_SYS_GTTY,
213 MSG_SYS_ACCESS, MSG_SYS_NICE,
214 MSG_SYS_STATFS, MSG_SYS_SYNC,
215 MSG_SYS_KILL, MSG_SYS_FSTATFS,
216 MSG_SYS_PGRPSYS, MSG_SYS_UUCOPYSTR,
217 MSG_SYS_41, MSG_SYS_PIPE,
218 MSG_SYS_TIMES, MSG_SYS_PROFIL,
219 MSG_SYS_FACCESSAT, MSG_SYS_SETGID,
220 MSG_SYS_GETGID, MSG_SYS_48,
221 MSG_SYS_MSGSYS, MSG_SYS_SYSI86,
222 MSG_SYS_ACCT, MSG_SYS_SHMSYS,
223 MSG_SYS_SEMSYS, MSG_SYS_IOCTL,
224 MSG_SYS_UADMIN, MSG_SYS_FCHOWNAT,
225 MSG_SYS_UTSSYS, MSG_SYS_FDSYNC,
226 MSG_SYS_EXECVE, MSG_SYS_UMASK,
227 MSG_SYS_CHROOT, MSG_SYS_FCNTL,
228 MSG_SYS_ULIMIT, MSG_SYS_RENAMEAT,
229 MSG_SYS_UNLINKAT, MSG_SYS_FSTATAT,
230 MSG_SYS_FSTATAT64, MSG_SYS_OPENAT,
231 MSG_SYS_OPENAT64, MSG_SYS_TASKSYS,
232 MSG_SYS_ACCTCTL, MSG_SYS_EXACCTSYS,
233 MSG_SYS_GETPAGESIZES, MSG_SYS_RCTLSYS,
234 MSG_SYS_SIDSYS, MSG_SYS_76,
235 MSG_SYS_LWP_PARK, MSG_SYS_SENDFILEV,
236 MSG_SYS_RMDIR, MSG_SYS_MKDIR,
237 MSG_SYS_GETDENTS, MSG_SYS_PRIVSYS,
238 MSG_SYS_UCREDSYS, MSG_SYS_SYSFS,
239 MSG_SYS_GETMSG, MSG_SYS_PUTMSG,
240 MSG_SYS_87, MSG_SYS_LSTAT,
241 MSG_SYS_SYMLINK, MSG_SYS_READLINK,
242 MSG_SYS_SETGROUPS, MSG_SYS_GETGROUPS,
243 MSG_SYS_FCHMOD, MSG_SYS_FCHOWN,
244 MSG_SYS_SIGPROCMASK, MSG_SYS_SIGSUSPEND,
245 MSG_SYS_SIGALTSTACK, MSG_SYS_SIGACTION,
246 MSG_SYS_SIGPENDING, MSG_SYS_CONTEXT,
247 MSG_SYS_101, MSG_SYS_102,
248 MSG_SYS_STATVFS, MSG_SYS_FSTATVFS,
249 MSG_SYS_GETLOADAVG, MSG_SYS_NFSSYS,
250 MSG_SYS_WAITID, MSG_SYS_SIGSENDSYS,
251 MSG_SYS_HRTSYS, MSG_SYS_UTIMESYS,
252 MSG_SYS_SIGRESEND, MSG_SYS_PRIOCNTLSYS,
253 MSG_SYS_PATHCONF, MSG_SYS_MINCORE,
254 MSG_SYS_MMAP, MSG_SYS_MPROTECT,
255 MSG_SYS_MUNMAP, MSG_SYS_FPATHCONF,
256 MSG_SYS_VFORK, MSG_SYS_FCHDIR,
257 MSG_SYS_READV, MSG_SYS_WRITEV,
258 MSG_SYS_PREADV, MSG_SYS_PWRITEV,
259 MSG_SYS_UPANIC, MSG_SYS_GETRANDOM,
260 MSG_SYS_MMAPOBJ, MSG_SYS_SETRLIMIT,
261 MSG_SYS_GETRLIMIT, MSG_SYS_LCHOWN,
262 MSG_SYS_MEMCNTL, MSG_SYS_GETPMSG,
263 MSG_SYS_PUTPMSG, MSG_SYS_RENAME,
264 MSG_SYS_UNAME, MSG_SYS_SETEGID,
265 MSG_SYS_SYSCONFIG, MSG_SYS_ADJTIME,
266 MSG_SYS_SYSTEMINFO, MSG_SYS_SHAREFS,
267 MSG_SYS_SETEUID, MSG_SYS_FORKSYS,
268 MSG_SYS_143, MSG_SYS_SIGTIMEDWAIT,
269 MSG_SYS_LWP_INFO, MSG_SYS_YIELD,
270 MSG_SYS_147, MSG_SYS_LWP_SEMA_POST,
271 MSG_SYS_LWP_SEMA_TRYWAIT, MSG_SYS_LWP_DETACH,
272 MSG_SYS_CORECTL, MSG_SYS_MODCTL,
273 MSG_SYS_FCHROOT, MSG_SYS_154,
274 MSG_SYS_VHANGUP, MSG_SYS_GETTIMEOFDAY,
275 MSG_SYS_GETITIMER, MSG_SYS_SETITIMER,
276 MSG_SYS_LWP_CREATE, MSG_SYS_LWP_EXIT,
277 MSG_SYS_LWP_SUSPEND, MSG_SYS_LWP_CONTINUE,
278 MSG_SYS_LWP_KILL, MSG_SYS_LWP_SELF,
279 MSG_SYS_LWP_SIGMASK, MSG_SYS_LWP_PRIVATE,
280 MSG_SYS_LWP_WAIT, MSG_SYS_LWP_MUTEX_WAKEUP,
281 MSG_SYS_169, MSG_SYS_LWP_COND_WAIT,
282 MSG_SYS_LWP_COND_SIGNAL, MSG_SYS_LWP_COND_BROADCAST,
283 MSG_SYS_PREAD, MSG_SYS_PWRITE,
284 MSG_SYS_LLSEEK, MSG_SYS_INST_SYNC,
285 MSG_SYS_BRAND, MSG_SYS_KAIO,
286 MSG_SYS_CPC, MSG_SYS_LGRPSYS,
287 MSG_SYS_RUSAGESYS, MSG_SYS_PORT,
288 MSG_SYS_POLLSYS, MSG_SYS_LABELSYS,
289 MSG_SYS_ACL, MSG_SYS_AUDITSYS,
290 MSG_SYS_PROCESSOR_BIND, MSG_SYS_PROCESSOR_INFO,
291 MSG_SYS_P_ONLINE, MSG_SYS_SIGQUEUE,
292 MSG_SYS_CLOCK_GETTIME, MSG_SYS_CLOCK_SETTIME,
293 MSG_SYS_CLOCK_GETRES, MSG_SYS_TIMER_CREATE,
294 MSG_SYS_TIMER_DELETE, MSG_SYS_TIMER_SETTIME,
295 MSG_SYS_TIMER_GETTIME, MSG_SYS_TIMER_GETOVERRUN,
296 MSG_SYS_NANOSLEEP, MSG_SYS_FACL,
297 MSG_SYS_DOOR, MSG_SYS_SETREUID,
298 MSG_SYS_SETREGID, MSG_SYS_INSTALL_UTRAP,
299 MSG_SYS_SIGNOTIFY, MSG_SYS_SCHEDCTL,
300 MSG_SYS_PSET, MSG_SYS_SPARC_UTRAP_INSTALL,
301 MSG_SYS_RESOLVEPATH, MSG_SYS_LWP_MUTEX_TIMEDLOCK,
302 MSG_SYS_LWP_SEMA_TIMEDWAIT, MSG_SYS_LWP_RWLOCK_SYS,
303 MSG_SYS_GETDENTS64, MSG_SYS_MMAP64,
304 MSG_SYS_STAT64, MSG_SYS_LSTAT64,
305 MSG_SYS_FSTAT64, MSG_SYS_STATVFS64,
306 MSG_SYS_FSTATVFS64, MSG_SYS_SETRLIMIT64,
307 MSG_SYS_GETRLIMIT64, MSG_SYS_PREAD64,
308 MSG_SYS_PWRITE64, MSG_SYS_224,
309 MSG_SYS_OPEN64, MSG_SYS_RPCSYS,
310 MSG_SYS_ZONE, MSG_SYS_AUTOFSSYS,
311 MSG_SYS_GETCWD, MSG_SYS_SO_SOCKET,
312 MSG_SYS_SO_SOCKETPAIR, MSG_SYS_BIND,
313 MSG_SYS_LISTEN, MSG_SYS_ACCEPT,
314 MSG_SYS_CONNECT, MSG_SYS_SHUTDOWN,
315 MSG_SYS_RECV, MSG_SYS_RECVFROM,
316 MSG_SYS_RECVMSG, MSG_SYS_SEND,
317 MSG_SYS_SENDMSG, MSG_SYS_SENDTO,
318 MSG_SYS_GETPEERNAME, MSG_SYS_GETSOCKNAME,
319 MSG_SYS_GETSOCKOPT, MSG_SYS_SETSOCKOPT,
320 MSG_SYS_SOCKCONFIG, MSG_SYS_NTP_GETTIME,
321 MSG_SYS_NTP_ADJTIME, MSG_SYS_LWP_MUTEX_UNLOCK,
322 MSG_SYS_LWP_MUTEX_TRYLOCK, MSG_SYS_LWP_MUTEX_REGISTER,
323 MSG_SYS_CLADM, MSG_SYS_UUCOPY,
324 MSG_SYS_UMOUNT2
325 };
326 static const conv_ds_msg_t ds_sysnumarr = {
327 CONV_DS_MSG_INIT(1, sysnumarr) };
328
329 static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_sysnumarr), NULL };
330
331 int use_num = 0;
332
333 /*
334 * Range check, and handle the unused values in the middle
335 * of the range. Although the missing values have strings,
336 * we still prefer to format them, because those strings are
337 * decimal, and the default behavior, unless the CONV_FMT_DECIMAL
338 * flag is set, is to display such things in hex.
339 */
340 switch (sysnum) {
341 case 0:
342 case 2:
343 case 7:
344 case 8:
345 case 11:
346 case 22:
347 case 30:
348 case 41:
349 case 48:
350 case 76:
351 case 87:
352 case 101:
353 case 102:
354 case 123:
355 case 124:
356 case 125:
357 case 126:
358 case 143:
359 case 147:
360 case 154:
361 case 169:
362 case 224:
363 use_num = 1;
364 break;
365 default:
366 use_num = (sysnum > SYS_umount2);
367 break;
368 }
369 if (use_num)
370 return (conv_invalid_val(inv_buf, sysnum, fmt_flags));
371
372 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, sysnum, ds, fmt_flags,
373 inv_buf));
374 }
375
376
377 const char *
conv_cnote_errno(int errno_val,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)378 conv_cnote_errno(int errno_val, Conv_fmt_flags_t fmt_flags,
379 Conv_inv_buf_t *inv_buf)
380 {
381 static const Msg errarr_1_74[74] = {
382 MSG_ERRNO_EPERM, MSG_ERRNO_ENOENT,
383 MSG_ERRNO_ESRCH, MSG_ERRNO_EINTR,
384 MSG_ERRNO_EIO, MSG_ERRNO_ENXIO,
385 MSG_ERRNO_E2BIG, MSG_ERRNO_ENOEXEC,
386 MSG_ERRNO_EBADF, MSG_ERRNO_ECHILD,
387 MSG_ERRNO_EAGAIN, MSG_ERRNO_ENOMEM,
388 MSG_ERRNO_EACCES, MSG_ERRNO_EFAULT,
389 MSG_ERRNO_ENOTBLK, MSG_ERRNO_EBUSY,
390 MSG_ERRNO_EEXIST, MSG_ERRNO_EXDEV,
391 MSG_ERRNO_ENODEV, MSG_ERRNO_ENOTDIR,
392 MSG_ERRNO_EISDIR, MSG_ERRNO_EINVAL,
393 MSG_ERRNO_ENFILE, MSG_ERRNO_EMFILE,
394 MSG_ERRNO_ENOTTY, MSG_ERRNO_ETXTBSY,
395 MSG_ERRNO_EFBIG, MSG_ERRNO_ENOSPC,
396 MSG_ERRNO_ESPIPE, MSG_ERRNO_EROFS,
397 MSG_ERRNO_EMLINK, MSG_ERRNO_EPIPE,
398 MSG_ERRNO_EDOM, MSG_ERRNO_ERANGE,
399 MSG_ERRNO_ENOMSG, MSG_ERRNO_EIDRM,
400 MSG_ERRNO_ECHRNG, MSG_ERRNO_EL2NSYNC,
401 MSG_ERRNO_EL3HLT, MSG_ERRNO_EL3RST,
402 MSG_ERRNO_ELNRNG, MSG_ERRNO_EUNATCH,
403 MSG_ERRNO_ENOCSI, MSG_ERRNO_EL2HLT,
404 MSG_ERRNO_EDEADLK, MSG_ERRNO_ENOLCK,
405 MSG_ERRNO_ECANCELED, MSG_ERRNO_ENOTSUP,
406 MSG_ERRNO_EDQUOT, MSG_ERRNO_EBADE,
407 MSG_ERRNO_EBADR, MSG_ERRNO_EXFULL,
408 MSG_ERRNO_ENOANO, MSG_ERRNO_EBADRQC,
409 MSG_ERRNO_EBADSLT, MSG_ERRNO_EDEADLOCK,
410 MSG_ERRNO_EBFONT, MSG_ERRNO_EOWNERDEAD,
411 MSG_ERRNO_ENOTRECOVERABLE, MSG_ERRNO_ENOSTR,
412 MSG_ERRNO_ENODATA, MSG_ERRNO_ETIME,
413 MSG_ERRNO_ENOSR, MSG_ERRNO_ENONET,
414 MSG_ERRNO_ENOPKG, MSG_ERRNO_EREMOTE,
415 MSG_ERRNO_ENOLINK, MSG_ERRNO_EADV,
416 MSG_ERRNO_ESRMNT, MSG_ERRNO_ECOMM,
417 MSG_ERRNO_EPROTO, MSG_ERRNO_ELOCKUNMAPPED,
418 MSG_ERRNO_ENOTACTIVE, MSG_ERRNO_EMULTIHOP
419 };
420 static const conv_ds_msg_t ds_errarr_1_74 = {
421 CONV_DS_MSG_INIT(1, errarr_1_74) };
422
423 static const Msg errarr_77_99[23] = {
424 MSG_ERRNO_EBADMSG, MSG_ERRNO_ENAMETOOLONG,
425 MSG_ERRNO_EOVERFLOW, MSG_ERRNO_ENOTUNIQ,
426 MSG_ERRNO_EBADFD, MSG_ERRNO_EREMCHG,
427 MSG_ERRNO_ELIBACC, MSG_ERRNO_ELIBBAD,
428 MSG_ERRNO_ELIBSCN, MSG_ERRNO_ELIBMAX,
429 MSG_ERRNO_ELIBEXEC, MSG_ERRNO_EILSEQ,
430 MSG_ERRNO_ENOSYS, MSG_ERRNO_ELOOP,
431 MSG_ERRNO_ERESTART, MSG_ERRNO_ESTRPIPE,
432 MSG_ERRNO_ENOTEMPTY, MSG_ERRNO_EUSERS,
433 MSG_ERRNO_ENOTSOCK, MSG_ERRNO_EDESTADDRREQ,
434 MSG_ERRNO_EMSGSIZE, MSG_ERRNO_EPROTOTYPE,
435 MSG_ERRNO_ENOPROTOOPT
436 };
437 static const conv_ds_msg_t ds_errarr_77_99 = {
438 CONV_DS_MSG_INIT(77, errarr_77_99) };
439
440 static const Msg errarr_120_134[15] = {
441 MSG_ERRNO_EPROTONOSUPPORT, MSG_ERRNO_ESOCKTNOSUPPORT,
442 MSG_ERRNO_EOPNOTSUPP, MSG_ERRNO_EPFNOSUPPORT,
443 MSG_ERRNO_EAFNOSUPPORT, MSG_ERRNO_EADDRINUSE,
444 MSG_ERRNO_EADDRNOTAVAIL, MSG_ERRNO_ENETDOWN,
445 MSG_ERRNO_ENETUNREACH, MSG_ERRNO_ENETRESET,
446 MSG_ERRNO_ECONNABORTED, MSG_ERRNO_ECONNRESET,
447 MSG_ERRNO_ENOBUFS, MSG_ERRNO_EISCONN,
448 MSG_ERRNO_ENOTCONN
449 };
450 static const conv_ds_msg_t ds_errarr_120_134 = {
451 CONV_DS_MSG_INIT(120, errarr_120_134) };
452
453 static const Msg errarr_143_151[9] = {
454 MSG_ERRNO_ESHUTDOWN, MSG_ERRNO_ETOOMANYREFS,
455 MSG_ERRNO_ETIMEDOUT, MSG_ERRNO_ECONNREFUSED,
456 MSG_ERRNO_EHOSTDOWN, MSG_ERRNO_EHOSTUNREACH,
457 MSG_ERRNO_EALREADY, MSG_ERRNO_EINPROGRESS,
458 MSG_ERRNO_ESTALE
459 };
460 static const conv_ds_msg_t ds_errarr_143_151 = {
461 CONV_DS_MSG_INIT(143, errarr_143_151) };
462
463 static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_errarr_1_74),
464 CONV_DS_ADDR(ds_errarr_77_99), CONV_DS_ADDR(ds_errarr_120_134),
465 CONV_DS_ADDR(ds_errarr_143_151), NULL };
466
467
468 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, errno_val, ds, fmt_flags,
469 inv_buf));
470 }
471
472
473 const char *
conv_cnote_pr_dmodel(Word dmodel,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)474 conv_cnote_pr_dmodel(Word dmodel, Conv_fmt_flags_t fmt_flags,
475 Conv_inv_buf_t *inv_buf)
476 {
477 static const Msg models[] = {
478 MSG_PR_MODEL_UNKNOWN,
479 MSG_PR_MODEL_ILP32,
480 MSG_PR_MODEL_LP64
481 };
482 static const conv_ds_msg_t ds_models = {
483 CONV_DS_MSG_INIT(PR_MODEL_UNKNOWN, models) };
484 static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_models), NULL };
485
486 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, dmodel, ds, fmt_flags,
487 inv_buf));
488 }
489
490
491 const char *
conv_cnote_pr_why(short why,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)492 conv_cnote_pr_why(short why, Conv_fmt_flags_t fmt_flags,
493 Conv_inv_buf_t *inv_buf)
494 {
495 static const Msg why_arr[] = {
496 MSG_PR_WHY_REQUESTED,
497 MSG_PR_WHY_SIGNALLED,
498 MSG_PR_WHY_SYSENTRY,
499 MSG_PR_WHY_SYSEXIT,
500 MSG_PR_WHY_JOBCONTROL,
501 MSG_PR_WHY_FAULTED,
502 MSG_PR_WHY_SUSPENDED,
503 MSG_PR_WHY_CHECKPOINT
504 };
505 static const conv_ds_msg_t ds_why_arr = {
506 CONV_DS_MSG_INIT(1, why_arr) };
507 static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_why_arr), NULL };
508
509 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, why, ds, fmt_flags,
510 inv_buf));
511 }
512
513
514 const char *
conv_cnote_pr_what(short why,short what,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)515 conv_cnote_pr_what(short why, short what, Conv_fmt_flags_t fmt_flags,
516 Conv_inv_buf_t *inv_buf)
517 {
518 /*
519 * The meaning of pr_what depends on the corresponding
520 * value of pr_why, as discussed in the proc(5) manpage.
521 */
522 switch (why) {
523 case PR_SIGNALLED:
524 case PR_JOBCONTROL:
525 return (conv_cnote_signal(what, fmt_flags, inv_buf));
526 case PR_SYSENTRY:
527 case PR_SYSEXIT:
528 return (conv_cnote_syscall(what, fmt_flags, inv_buf));
529 case PR_FAULTED:
530 return (conv_cnote_fault(what, fmt_flags, inv_buf));
531 };
532
533 return (conv_invalid_val(inv_buf, what, fmt_flags));
534 }
535
536
537 /*
538 * Return the name of the general purpose register indexed by
539 * regno in the pr_reg array of lwpstatus_t (<sys/procfs.h>).
540 */
541 const char *
conv_cnote_pr_regname(Half mach,int regno,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)542 conv_cnote_pr_regname(Half mach, int regno, Conv_fmt_flags_t fmt_flags,
543 Conv_inv_buf_t *inv_buf)
544 {
545 static const Msg sparc_gen_reg[32] = {
546 MSG_REG_SPARC_G0, MSG_REG_SPARC_G1,
547 MSG_REG_SPARC_G2, MSG_REG_SPARC_G3,
548 MSG_REG_SPARC_G4, MSG_REG_SPARC_G5,
549 MSG_REG_SPARC_G6, MSG_REG_SPARC_G7,
550 MSG_REG_SPARC_O0, MSG_REG_SPARC_O1,
551 MSG_REG_SPARC_O2, MSG_REG_SPARC_O3,
552 MSG_REG_SPARC_O4, MSG_REG_SPARC_O5,
553 MSG_REG_SPARC_O6, MSG_REG_SPARC_O7,
554 MSG_REG_SPARC_L0, MSG_REG_SPARC_L1,
555 MSG_REG_SPARC_L2, MSG_REG_SPARC_L3,
556 MSG_REG_SPARC_L4, MSG_REG_SPARC_L5,
557 MSG_REG_SPARC_L6, MSG_REG_SPARC_L7,
558 MSG_REG_SPARC_I0, MSG_REG_SPARC_I1,
559 MSG_REG_SPARC_I2, MSG_REG_SPARC_I3,
560 MSG_REG_SPARC_I4, MSG_REG_SPARC_I5,
561 MSG_REG_SPARC_I6, MSG_REG_SPARC_I7
562 };
563 static const conv_ds_msg_t ds_sparc_gen_reg = {
564 CONV_DS_MSG_INIT(0, sparc_gen_reg) };
565
566 static const Msg sparc_32_37_reg[6] = {
567 MSG_REG_SPARC_PSR, MSG_REG_SPARC_PC,
568 MSG_REG_SPARC_nPC, MSG_REG_SPARC_Y,
569 MSG_REG_SPARC_WIM, MSG_REG_SPARC_TBR
570 };
571 static const conv_ds_msg_t ds_sparc_32_37_reg = {
572 CONV_DS_MSG_INIT(32, sparc_32_37_reg) };
573
574 static const Msg sparcv9_32_37_reg[6] = {
575 MSG_REG_SPARC_CCR, MSG_REG_SPARC_PC,
576 MSG_REG_SPARC_nPC, MSG_REG_SPARC_Y,
577 MSG_REG_SPARC_ASI, MSG_REG_SPARC_FPRS
578 };
579 static const conv_ds_msg_t ds_sparcv9_32_37_reg = {
580 CONV_DS_MSG_INIT(32, sparcv9_32_37_reg) };
581
582 static const Msg amd64_reg[28] = {
583 MSG_REG_AMD64_R15, MSG_REG_AMD64_R14,
584 MSG_REG_AMD64_R13, MSG_REG_AMD64_R12,
585 MSG_REG_AMD64_R11, MSG_REG_AMD64_R10,
586 MSG_REG_AMD64_R9, MSG_REG_AMD64_R8,
587 MSG_REG_AMD64_RDI, MSG_REG_AMD64_RSI,
588 MSG_REG_AMD64_RBP, MSG_REG_AMD64_RBX,
589 MSG_REG_AMD64_RDX, MSG_REG_AMD64_RCX,
590 MSG_REG_AMD64_RAX, MSG_REG_AMD64_TRAPNO,
591 MSG_REG_AMD64_ERR, MSG_REG_AMD64_RIP,
592 MSG_REG_AMD64_CS, MSG_REG_AMD64_RFL,
593 MSG_REG_AMD64_RSP, MSG_REG_AMD64_SS,
594 MSG_REG_AMD64_FS, MSG_REG_AMD64_GS,
595 MSG_REG_AMD64_ES, MSG_REG_AMD64_DS,
596 MSG_REG_AMD64_FSBASE, MSG_REG_AMD64_GSBASE
597 };
598 static const conv_ds_msg_t ds_amd64_reg = {
599 CONV_DS_MSG_INIT(0, amd64_reg) };
600
601 static const Msg i86_reg[19] = {
602 MSG_REG_I86_GS, MSG_REG_I86_FS,
603 MSG_REG_I86_ES, MSG_REG_I86_DS,
604 MSG_REG_I86_EDI, MSG_REG_I86_ESI,
605 MSG_REG_I86_EBP, MSG_REG_I86_ESP,
606 MSG_REG_I86_EBX, MSG_REG_I86_EDX,
607 MSG_REG_I86_ECX, MSG_REG_I86_EAX,
608 MSG_REG_I86_TRAPNO, MSG_REG_I86_ERR,
609 MSG_REG_I86_EIP, MSG_REG_I86_CS,
610 MSG_REG_I86_EFL, MSG_REG_I86_UESP,
611 MSG_REG_I86_SS
612 };
613 static const conv_ds_msg_t ds_i86_reg = {
614 CONV_DS_MSG_INIT(0, i86_reg) };
615
616
617 static const conv_ds_t *ds_sparc[] = {
618 CONV_DS_ADDR(ds_sparc_gen_reg),
619 CONV_DS_ADDR(ds_sparc_32_37_reg),
620 NULL
621 };
622 static const conv_ds_t *ds_sparcv9[] = {
623 CONV_DS_ADDR(ds_sparc_gen_reg),
624 CONV_DS_ADDR(ds_sparcv9_32_37_reg),
625 NULL
626 };
627 static const conv_ds_t *ds_amd64[] = {
628 CONV_DS_ADDR(ds_amd64_reg), NULL };
629 static const conv_ds_t *ds_i86[] = {
630 CONV_DS_ADDR(ds_i86_reg), NULL };
631
632 const conv_ds_t **ds;
633
634 switch (mach) {
635 case EM_386:
636 ds = ds_i86;
637 break;
638
639 case EM_AMD64:
640 ds = ds_amd64;
641 break;
642
643 case EM_SPARC:
644 case EM_SPARC32PLUS:
645 ds = ds_sparc;
646 break;
647
648 case EM_SPARCV9:
649 ds = ds_sparcv9;
650 break;
651
652 default:
653 return (conv_invalid_val(inv_buf, regno, fmt_flags));
654 }
655
656 return (conv_map_ds(ELFOSABI_NONE, mach, regno, ds, fmt_flags,
657 inv_buf));
658 }
659
660 const char *
conv_cnote_pr_stype(Word stype,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)661 conv_cnote_pr_stype(Word stype, Conv_fmt_flags_t fmt_flags,
662 Conv_inv_buf_t *inv_buf)
663 {
664 static const Msg types[] = {
665 MSG_SOBJ_NONE, MSG_SOBJ_MUTEX,
666 MSG_SOBJ_RWLOCK, MSG_SOBJ_CV,
667 MSG_SOBJ_SEMA, MSG_SOBJ_USER,
668 MSG_SOBJ_USER_PI, MSG_SOBJ_SHUTTLE
669 };
670 static const conv_ds_msg_t ds_types = { CONV_DS_MSG_INIT(0, types) };
671 static const conv_ds_t *ds[] = { CONV_DS_ADDR(ds_types), NULL };
672
673
674 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, stype, ds, fmt_flags,
675 inv_buf));
676 }
677
678
679 const char *
conv_cnote_priv(int priv,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)680 conv_cnote_priv(int priv, Conv_fmt_flags_t fmt_flags,
681 Conv_inv_buf_t *inv_buf)
682 {
683 const char *fmt;
684
685 /*
686 * The PRIV_ constants defined in <sys/priv.h> are unusual
687 * in that they are negative values. The libconv code is all
688 * built around the Word type, which is unsigned. Rather than
689 * modify libconv for this one case, we simply handle
690 * these constants differently that the usual approach,
691 * and stay away from conv_invalid_val() and conv_map_ds().
692 */
693 switch (priv) {
694 case PRIV_ALL:
695 return (MSG_ORIG(MSG_PRIV_ALL));
696 case PRIV_MULTIPLE:
697 return (MSG_ORIG(MSG_PRIV_MULTIPLE));
698 case PRIV_NONE:
699 return (MSG_ORIG(MSG_PRIV_NONE));
700 case PRIV_ALLZONE:
701 return (MSG_ORIG(MSG_PRIV_ALLZONE));
702 case PRIV_GLOBAL:
703 return (MSG_ORIG(MSG_PRIV_GLOBAL));
704 }
705
706 fmt = (fmt_flags & CONV_FMT_DECIMAL) ?
707 MSG_ORIG(MSG_FMT_INT) : MSG_ORIG(MSG_FMT_HEXINT);
708 (void) snprintf(inv_buf->buf, sizeof (inv_buf->buf), fmt, priv);
709 return (inv_buf->buf);
710 }
711
712
713 const char *
conv_cnote_psetid(int id,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)714 conv_cnote_psetid(int id, Conv_fmt_flags_t fmt_flags,
715 Conv_inv_buf_t *inv_buf)
716 {
717 const char *fmt;
718
719 /*
720 * The PS_ constants defined in <sys/pset.h> are unusual
721 * in that they are negative values. The libconv code is all
722 * built around the Word type, which is unsigned. Rather than
723 * modify libconv for this one case, we simply handle
724 * these constants differently that the usual approach,
725 * and stay away from conv_invalid_val() and conv_map_ds().
726 */
727 switch (id) {
728 case PS_NONE:
729 return (MSG_ORIG(MSG_PS_NONE));
730 case PS_QUERY:
731 return (MSG_ORIG(MSG_PS_QUERY));
732 case PS_MYID:
733 return (MSG_ORIG(MSG_PS_MYID));
734 case PS_SOFT:
735 return (MSG_ORIG(MSG_PS_SOFT));
736 case PS_HARD:
737 return (MSG_ORIG(MSG_PS_HARD));
738 case PS_QUERY_TYPE:
739 return (MSG_ORIG(MSG_PS_QUERY_TYPE));
740 }
741
742 fmt = (fmt_flags & CONV_FMT_DECIMAL) ?
743 MSG_ORIG(MSG_FMT_INT) : MSG_ORIG(MSG_FMT_HEXINT);
744 (void) snprintf(inv_buf->buf, sizeof (inv_buf->buf), fmt, id);
745 return (inv_buf->buf);
746 }
747
748
749 /*
750 * Return a string describing the si_code field of
751 * the siginfo_t struct.
752 *
753 * The meaning of si_code is dependent on both the target
754 * machine (mach) as well as the signal (sig).
755 */
756 const char *
conv_cnote_si_code(Half mach,int sig,int si_code,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)757 conv_cnote_si_code(Half mach, int sig, int si_code,
758 Conv_fmt_flags_t fmt_flags, Conv_inv_buf_t *inv_buf)
759 {
760
761 /* Values of si_code for user generated signals */
762 static const Msg user_arr[6] = {
763 MSG_SI_USER, MSG_SI_LWP,
764 MSG_SI_QUEUE, MSG_SI_TIMER,
765 MSG_SI_ASYNCIO, MSG_SI_MESGQ
766 };
767 static const conv_ds_msg_t ds_msg_user_arr = {
768 CONV_DS_MSG_INIT(0, user_arr) };
769 static const conv_ds_t *ds_user_arr[] = {
770 CONV_DS_ADDR(ds_msg_user_arr), NULL };
771
772
773 /*
774 * Architecture dependent system generated signals. All
775 * versions of Solaris use the same set of these values.
776 */
777 static const Msg trap_arr[6] = {
778 MSG_SI_TRAP_BRKPT, MSG_SI_TRAP_TRACE,
779 MSG_SI_TRAP_RWATCH, MSG_SI_TRAP_WWATCH,
780 MSG_SI_TRAP_XWATCH, MSG_SI_TRAP_DTRACE
781 };
782 static const conv_ds_msg_t ds_msg_trap_arr = {
783 CONV_DS_MSG_INIT(1, trap_arr) };
784 static const conv_ds_t *ds_trap_arr[] = {
785 CONV_DS_ADDR(ds_msg_trap_arr), NULL };
786
787 static const Msg cld_arr[6] = {
788 MSG_SI_CLD_EXITED, MSG_SI_CLD_KILLED,
789 MSG_SI_CLD_DUMPED, MSG_SI_CLD_TRAPPED,
790 MSG_SI_CLD_STOPPED, MSG_SI_CLD_CONTINUED
791 };
792 static const conv_ds_msg_t ds_msg_cld_arr = {
793 CONV_DS_MSG_INIT(1, cld_arr) };
794 static const conv_ds_t *ds_cld_arr[] = {
795 CONV_DS_ADDR(ds_msg_cld_arr), NULL };
796
797 static const Msg poll_arr[6] = {
798 MSG_SI_POLL_IN, MSG_SI_POLL_OUT,
799 MSG_SI_POLL_MSG, MSG_SI_POLL_ERR,
800 MSG_SI_POLL_PRI, MSG_SI_POLL_HUP
801 };
802 static const conv_ds_msg_t ds_msg_poll_arr = {
803 CONV_DS_MSG_INIT(1, poll_arr) };
804 static const conv_ds_t *ds_poll_arr[] = {
805 CONV_DS_ADDR(ds_msg_poll_arr), NULL };
806
807 /*
808 * Architecture dependent system generated signals.
809 * These items (ILL, EMT, FPE, SEGV, BUS) are platform
810 * dependent. Some architectures have extra codes.
811 * The same name may have a different integer value.
812 * Multiple arrays are used when they differ, and one
813 * array when all the architectures agree.
814 */
815
816 /* ILL */
817 static const Msg ill_arr[8] = {
818 MSG_SI_ILL_ILLOPC, MSG_SI_ILL_ILLOPN,
819 MSG_SI_ILL_ILLADR, MSG_SI_ILL_ILLTRP,
820 MSG_SI_ILL_PRVOPC, MSG_SI_ILL_PRVREG,
821 MSG_SI_ILL_COPROC, MSG_SI_ILL_BADSTK
822 };
823 static const conv_ds_msg_t ds_msg_ill_arr = {
824 CONV_DS_MSG_INIT(1, ill_arr) };
825 static const conv_ds_t *ds_ill_arr[] = {
826 CONV_DS_ADDR(ds_msg_ill_arr), NULL };
827
828 /* EMT */
829 static const Msg emt_arr_sparc[2] = {
830 MSG_SI_EMT_TAGOVF, MSG_SI_EMT_CPCOVF
831 };
832 static const conv_ds_msg_t ds_msg_emt_arr_sparc = {
833 CONV_DS_MSG_INIT(1, emt_arr_sparc) };
834 static const conv_ds_t *ds_emt_arr_sparc[] = {
835 CONV_DS_ADDR(ds_msg_emt_arr_sparc), NULL };
836
837 static const Msg emt_arr_x86[1] = {
838 MSG_SI_EMT_CPCOVF
839 };
840 static const conv_ds_msg_t ds_msg_emt_arr_x86 = {
841 CONV_DS_MSG_INIT(1, emt_arr_x86) };
842 static const conv_ds_t *ds_emt_arr_x86[] = {
843 CONV_DS_ADDR(ds_msg_emt_arr_x86), NULL };
844
845
846 /* FPE */
847 static const Msg fpe_arr_sparc[8] = {
848 MSG_SI_FPE_INTDIV, MSG_SI_FPE_INTOVF,
849 MSG_SI_FPE_FLTDIV, MSG_SI_FPE_FLTOVF,
850 MSG_SI_FPE_FLTUND, MSG_SI_FPE_FLTRES,
851 MSG_SI_FPE_FLTINV, MSG_SI_FPE_FLTSUB
852 };
853 static const conv_ds_msg_t ds_msg_fpe_arr_sparc = {
854 CONV_DS_MSG_INIT(1, fpe_arr_sparc) };
855 static const conv_ds_t *ds_fpe_arr_sparc[] = {
856 CONV_DS_ADDR(ds_msg_fpe_arr_sparc), NULL };
857
858 static const Msg fpe_arr_x86[9] = {
859 MSG_SI_FPE_INTDIV, MSG_SI_FPE_INTOVF,
860 MSG_SI_FPE_FLTDIV, MSG_SI_FPE_FLTOVF,
861 MSG_SI_FPE_FLTUND, MSG_SI_FPE_FLTRES,
862 MSG_SI_FPE_FLTINV, MSG_SI_FPE_FLTSUB,
863 MSG_SI_FPE_FLTDEN
864 };
865 static const conv_ds_msg_t ds_msg_fpe_arr_x86 = {
866 CONV_DS_MSG_INIT(1, fpe_arr_x86) };
867 static const conv_ds_t *ds_fpe_arr_x86[] = {
868 CONV_DS_ADDR(ds_msg_fpe_arr_x86), NULL };
869
870 /* SEGV */
871 static const Msg segv_arr[2] = {
872 MSG_SI_SEGV_MAPERR, MSG_SI_SEGV_ACCERR
873 };
874 static const conv_ds_msg_t ds_msg_segv_arr = {
875 CONV_DS_MSG_INIT(1, segv_arr) };
876 static const conv_ds_t *ds_segv_arr[] = {
877 CONV_DS_ADDR(ds_msg_segv_arr), NULL };
878
879 /* BUS */
880 static const Msg bus_arr[3] = {
881 MSG_SI_BUS_ADRALN, MSG_SI_BUS_ADRERR,
882 MSG_SI_BUS_OBJERR
883 };
884 static const conv_ds_msg_t ds_msg_bus_arr = {
885 CONV_DS_MSG_INIT(1, bus_arr) };
886 static const conv_ds_t *ds_bus_arr[] = {
887 CONV_DS_ADDR(ds_msg_bus_arr), NULL };
888
889 enum { ARCH_NONE, ARCH_X86, ARCH_SPARC } arch;
890
891
892 /* Handle the si_code values that do not depend on the signal */
893 switch (si_code) {
894 case SI_NOINFO:
895 return (MSG_ORIG(MSG_SI_NOINFO));
896 case SI_DTRACE:
897 return (MSG_ORIG(MSG_SI_DTRACE));
898 case SI_RCTL:
899 return (MSG_ORIG(MSG_SI_RCTL));
900 default:
901 /* User generated signal codes are <= 0 */
902 if (si_code <= 0) {
903 int ndx = -si_code;
904
905 /*
906 * If no signal was delivered, and si_code is
907 * 0, return "0" rather than "SI_USER".
908 */
909 if ((si_code == 0) && (sig == 0))
910 return (MSG_ORIG(MSG_GBL_ZERO));
911
912 if (ndx >= ARRAY_NELTS(user_arr)) {
913 const char *fmt;
914
915 fmt = (fmt_flags & CONV_FMT_DECIMAL) ?
916 MSG_ORIG(MSG_FMT_INT) :
917 MSG_ORIG(MSG_FMT_HEXINT);
918
919 (void) snprintf(inv_buf->buf,
920 sizeof (inv_buf->buf), fmt, si_code);
921 return (inv_buf->buf);
922 }
923 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, ndx,
924 ds_user_arr, fmt_flags, inv_buf));
925 }
926 }
927
928 /*
929 * If we didn't return above, then this is a
930 * system generated signal, and the meaning of si_code
931 * depends on the signal that was delivered, and possibly
932 * on the target architecture.
933 */
934 switch (mach) {
935 case EM_386:
936 case EM_AMD64:
937 arch = ARCH_X86;
938 break;
939
940 case EM_SPARC:
941 case EM_SPARC32PLUS:
942 case EM_SPARCV9:
943 arch = ARCH_X86;
944 break;
945
946 default:
947 arch = ARCH_NONE;
948 break;
949 }
950
951 switch (sig) {
952 case SIGTRAP:
953 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
954 ds_trap_arr, fmt_flags, inv_buf));
955
956 case SIGCLD:
957 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
958 ds_cld_arr, fmt_flags, inv_buf));
959
960 case SIGPOLL:
961 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
962 ds_poll_arr, fmt_flags, inv_buf));
963
964 case SIGILL:
965 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
966 ds_ill_arr, fmt_flags, inv_buf));
967
968 case SIGEMT:
969 switch (arch) {
970 case ARCH_SPARC:
971 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
972 ds_emt_arr_sparc, fmt_flags, inv_buf));
973 case ARCH_X86:
974 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
975 ds_emt_arr_x86, fmt_flags, inv_buf));
976 case ARCH_NONE:
977 break;
978 }
979 break;
980
981 case SIGFPE:
982 switch (arch) {
983 case ARCH_SPARC:
984 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
985 ds_fpe_arr_sparc, fmt_flags, inv_buf));
986 case ARCH_X86:
987 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
988 ds_fpe_arr_x86, fmt_flags, inv_buf));
989 case ARCH_NONE:
990 break;
991 }
992 break;
993
994 case SIGSEGV:
995 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
996 ds_segv_arr, fmt_flags, inv_buf));
997
998 case SIGBUS:
999 return (conv_map_ds(ELFOSABI_NONE, EM_NONE, si_code,
1000 ds_bus_arr, fmt_flags, inv_buf));
1001 }
1002
1003 /* If not recognized, format as a number */
1004 return (conv_invalid_val(inv_buf, si_code, fmt_flags));
1005
1006 }
1007
1008
1009 #define AUXAFFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1010 MSG_AUXV_AF_SUN_SETUGID_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1011 MSG_AUXV_AF_SUN_HWCAPVERIFY_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1012 MSG_AUXV_AF_SUN_NOPLM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1013 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1014
1015 /*
1016 * Ensure that Conv_cnote_auxv_af_buf_t is large enough:
1017 *
1018 * AUXAFFLGSZ is the real minimum size of the buffer required by
1019 * conv_cnote_auxv_af(). However, Conv_cnote_auxv_af_buf_t
1020 * uses CONV_CNOTE_AUXV_AF_BUFSIZE to set the buffer size. We do
1021 * things this way because the definition of AUXAFFLGSZ uses information
1022 * that is not available in the environment of other programs
1023 * that include the conv.h header file.
1024 */
1025 #if (CONV_CNOTE_AUXV_AF_BUFSIZE != AUXAFFLGSZ) && !defined(__lint)
1026 #define REPORT_BUFSIZE AUXAFFLGSZ
1027 #include "report_bufsize.h"
1028 #error "CONV_CNOTE_AUXV_AF_BUFSIZE does not match AUXAFFLGSZ"
1029 #endif
1030
1031 const char *
conv_cnote_auxv_af(Word flags,Conv_fmt_flags_t fmt_flags,Conv_cnote_auxv_af_buf_t * cnote_auxv_af_buf)1032 conv_cnote_auxv_af(Word flags, Conv_fmt_flags_t fmt_flags,
1033 Conv_cnote_auxv_af_buf_t *cnote_auxv_af_buf)
1034 {
1035 static const Val_desc vda[] = {
1036 { AF_SUN_SETUGID, MSG_AUXV_AF_SUN_SETUGID },
1037 { AF_SUN_HWCAPVERIFY, MSG_AUXV_AF_SUN_HWCAPVERIFY },
1038 { AF_SUN_NOPLM, MSG_AUXV_AF_SUN_NOPLM },
1039 { 0, 0 }
1040 };
1041 static CONV_EXPN_FIELD_ARG conv_arg = {
1042 NULL, sizeof (cnote_auxv_af_buf->buf) };
1043
1044 if (flags == 0)
1045 return (MSG_ORIG(MSG_GBL_ZERO));
1046
1047 conv_arg.buf = cnote_auxv_af_buf->buf;
1048 conv_arg.oflags = conv_arg.rflags = flags;
1049 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
1050
1051 return ((const char *)cnote_auxv_af_buf->buf);
1052 }
1053
1054
1055 #define CCFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1056 MSG_CC_CONTENT_STACK_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1057 MSG_CC_CONTENT_HEAP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1058 MSG_CC_CONTENT_SHFILE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1059 MSG_CC_CONTENT_SHANON_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1060 MSG_CC_CONTENT_TEXT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1061 MSG_CC_CONTENT_DATA_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1062 MSG_CC_CONTENT_RODATA_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1063 MSG_CC_CONTENT_ANON_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1064 MSG_CC_CONTENT_SHM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1065 MSG_CC_CONTENT_ISM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1066 MSG_CC_CONTENT_DISM_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1067 MSG_CC_CONTENT_CTF_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1068 MSG_CC_CONTENT_SYMTAB_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1069 MSG_CC_CONTENT_DEBUG_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1070 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1071
1072 /*
1073 * Ensure that Conv_cnote_cc_content_buf_t is large enough:
1074 *
1075 * CCFLGSZ is the real minimum size of the buffer required by
1076 * conv_cnote_cc_content(). However, Conv_cnote_cc_content_buf_t
1077 * uses CONV_CNOTE_CC_CONTENT_BUFSIZE to set the buffer size. We do
1078 * things this way because the definition of CCFLGSZ uses information
1079 * that is not available in the environment of other programs
1080 * that include the conv.h header file.
1081 */
1082 #if (CONV_CNOTE_CC_CONTENT_BUFSIZE != CCFLGSZ) && !defined(__lint)
1083 #define REPORT_BUFSIZE CCFLGSZ
1084 #include "report_bufsize.h"
1085 #error "CONV_CNOTE_CC_CONTENT_BUFSIZE does not match CCFLGSZ"
1086 #endif
1087
1088 /*
1089 * This is required to work around tools ld bootstrapping issues where
1090 * CC_CONTENT_DEBUG is not present. When an illumos sysroot has this present it
1091 * will probably be safe to remove this.
1092 */
1093 #ifndef CC_CONTENT_DEBUG
1094 #define CC_CONTENT_DEBUG 0x2000ULL
1095 #endif
1096
1097 const char *
conv_cnote_cc_content(Lword flags,Conv_fmt_flags_t fmt_flags,Conv_cnote_cc_content_buf_t * cnote_cc_content_buf)1098 conv_cnote_cc_content(Lword flags, Conv_fmt_flags_t fmt_flags,
1099 Conv_cnote_cc_content_buf_t *cnote_cc_content_buf)
1100 {
1101 /*
1102 * Note: core_content_t is a 64-bit integer value, but our
1103 * conv_expn_field() logic is all built around 32-bit
1104 * Word values. This will probably need changing someday,
1105 * but for now, we make do with the 32-bit engine. This works
1106 * because the number of bits actually assigned in
1107 * the core_content_t data type (<sys/corectl.h>) bits within
1108 * 32-bits.
1109 *
1110 * The downside is that any bits set in the upper half of
1111 * the flags will be ignored. At the time of this writing,
1112 * that can only occur via core file corruption, which presumably
1113 * would be evident in other ways.
1114 */
1115 static const Val_desc vda[] = {
1116 { (Word) CC_CONTENT_STACK, MSG_CC_CONTENT_STACK },
1117 { (Word) CC_CONTENT_HEAP, MSG_CC_CONTENT_HEAP },
1118 { (Word) CC_CONTENT_SHFILE, MSG_CC_CONTENT_SHFILE },
1119 { (Word) CC_CONTENT_SHANON, MSG_CC_CONTENT_SHANON },
1120 { (Word) CC_CONTENT_TEXT, MSG_CC_CONTENT_TEXT },
1121 { (Word) CC_CONTENT_DATA, MSG_CC_CONTENT_DATA },
1122 { (Word) CC_CONTENT_RODATA, MSG_CC_CONTENT_RODATA },
1123 { (Word) CC_CONTENT_ANON, MSG_CC_CONTENT_ANON },
1124 { (Word) CC_CONTENT_SHM, MSG_CC_CONTENT_SHM },
1125 { (Word) CC_CONTENT_ISM, MSG_CC_CONTENT_ISM },
1126 { (Word) CC_CONTENT_DISM, MSG_CC_CONTENT_DISM },
1127 { (Word) CC_CONTENT_CTF, MSG_CC_CONTENT_CTF },
1128 { (Word) CC_CONTENT_SYMTAB, MSG_CC_CONTENT_SYMTAB },
1129 { (Word) CC_CONTENT_DEBUG, MSG_CC_CONTENT_DEBUG },
1130 { 0, 0 }
1131 };
1132 static CONV_EXPN_FIELD_ARG conv_arg = {
1133 NULL, sizeof (cnote_cc_content_buf->buf) };
1134
1135 if (flags == 0)
1136 return (MSG_ORIG(MSG_GBL_ZERO));
1137
1138 conv_arg.buf = cnote_cc_content_buf->buf;
1139 conv_arg.oflags = conv_arg.rflags = flags;
1140 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
1141
1142 return ((const char *)cnote_cc_content_buf->buf);
1143 }
1144
1145
1146 #define PRFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1147 MSG_PR_FLAGS_STOPPED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1148 MSG_PR_FLAGS_ISTOP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1149 MSG_PR_FLAGS_DSTOP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1150 MSG_PR_FLAGS_STEP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1151 MSG_PR_FLAGS_ASLEEP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1152 MSG_PR_FLAGS_PCINVAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1153 MSG_PR_FLAGS_ASLWP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1154 MSG_PR_FLAGS_AGENT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1155 MSG_PR_FLAGS_DETACH_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1156 MSG_PR_FLAGS_DAEMON_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1157 MSG_PR_FLAGS_IDLE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1158 MSG_PR_FLAGS_ISSYS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1159 MSG_PR_FLAGS_VFORKP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1160 MSG_PR_FLAGS_ORPHAN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1161 MSG_PR_FLAGS_NOSIGCHLD_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1162 MSG_PR_FLAGS_WAITPID_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1163 MSG_PR_FLAGS_FORK_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1164 MSG_PR_FLAGS_RLC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1165 MSG_PR_FLAGS_KLC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1166 MSG_PR_FLAGS_ASYNC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1167 MSG_PR_FLAGS_MSACCT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1168 MSG_PR_FLAGS_BPTADJ_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1169 MSG_PR_FLAGS_PTRACE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1170 MSG_PR_FLAGS_MSFORK_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1171 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1172
1173 /*
1174 * Ensure that Conv_cnote_pr_flags_buf_t is large enough:
1175 *
1176 * PRFLGSZ is the real minimum size of the buffer required by
1177 * conv_cnote_pr_flags(). However, Conv_cnote_pr_flags_buf_t
1178 * uses CONV_CNOTE_PR_FLAGS_BUFSIZE to set the buffer size. We do
1179 * things this way because the definition of PRFLGSZ uses information
1180 * that is not available in the environment of other programs
1181 * that include the conv.h header file.
1182 */
1183 #if (CONV_CNOTE_PR_FLAGS_BUFSIZE != PRFLGSZ) && !defined(__lint)
1184 #define REPORT_BUFSIZE PRFLGSZ
1185 #include "report_bufsize.h"
1186 #error "CONV_CNOTE_PR_FLAGS_BUFSIZE does not match PRFLGSZ"
1187 #endif
1188
1189 const char *
conv_cnote_pr_flags(int flags,Conv_fmt_flags_t fmt_flags,Conv_cnote_pr_flags_buf_t * cnote_pr_flags_buf)1190 conv_cnote_pr_flags(int flags, Conv_fmt_flags_t fmt_flags,
1191 Conv_cnote_pr_flags_buf_t *cnote_pr_flags_buf)
1192 {
1193 static const Val_desc vda[] = {
1194 { PR_STOPPED, MSG_PR_FLAGS_STOPPED },
1195 { PR_ISTOP, MSG_PR_FLAGS_ISTOP },
1196 { PR_DSTOP, MSG_PR_FLAGS_DSTOP },
1197 { PR_STEP, MSG_PR_FLAGS_STEP },
1198 { PR_ASLEEP, MSG_PR_FLAGS_ASLEEP },
1199 { PR_PCINVAL, MSG_PR_FLAGS_PCINVAL },
1200 { PR_ASLWP, MSG_PR_FLAGS_ASLWP },
1201 { PR_AGENT, MSG_PR_FLAGS_AGENT },
1202 { PR_DETACH, MSG_PR_FLAGS_DETACH },
1203 { PR_DAEMON, MSG_PR_FLAGS_DAEMON },
1204 { PR_IDLE, MSG_PR_FLAGS_IDLE },
1205 { PR_ISSYS, MSG_PR_FLAGS_ISSYS },
1206 { PR_VFORKP, MSG_PR_FLAGS_VFORKP },
1207 { PR_ORPHAN, MSG_PR_FLAGS_ORPHAN },
1208 { PR_NOSIGCHLD, MSG_PR_FLAGS_NOSIGCHLD },
1209 { PR_WAITPID, MSG_PR_FLAGS_WAITPID },
1210 { PR_FORK, MSG_PR_FLAGS_FORK },
1211 { PR_RLC, MSG_PR_FLAGS_RLC },
1212 { PR_KLC, MSG_PR_FLAGS_KLC },
1213 { PR_ASYNC, MSG_PR_FLAGS_ASYNC },
1214 { PR_MSACCT, MSG_PR_FLAGS_MSACCT },
1215 { PR_BPTADJ, MSG_PR_FLAGS_BPTADJ },
1216 { PR_PTRACE, MSG_PR_FLAGS_PTRACE },
1217 { PR_MSFORK, MSG_PR_FLAGS_MSFORK },
1218 { 0, 0 }
1219 };
1220 static CONV_EXPN_FIELD_ARG conv_arg = {
1221 NULL, sizeof (cnote_pr_flags_buf->buf) };
1222
1223 if (flags == 0)
1224 return (MSG_ORIG(MSG_GBL_ZERO));
1225
1226 conv_arg.buf = cnote_pr_flags_buf->buf;
1227 conv_arg.oflags = conv_arg.rflags = flags;
1228 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
1229
1230 return ((const char *)cnote_pr_flags_buf->buf);
1231 }
1232
1233
1234 #define OLDPRFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1235 MSG_PR_FLAGS_STOPPED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1236 MSG_PR_FLAGS_ISTOP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1237 MSG_PR_FLAGS_DSTOP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1238 MSG_PR_FLAGS_ASLEEP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1239 MSG_PR_FLAGS_FORK_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1240 MSG_PR_FLAGS_RLC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1241 MSG_PR_FLAGS_PTRACE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1242 MSG_PR_FLAGS_PCINVAL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1243 MSG_PR_FLAGS_ISSYS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1244 MSG_PR_FLAGS_STEP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1245 MSG_PR_FLAGS_KLC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1246 MSG_PR_FLAGS_ASYNC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1247 MSG_PR_FLAGS_PCOMPAT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1248 MSG_PR_FLAGS_MSACCT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1249 MSG_PR_FLAGS_BPTADJ_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1250 MSG_PR_FLAGS_ASLWP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1251 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1252
1253 /*
1254 * Ensure that Conv_cnote_old_pr_flags_buf_t is large enough:
1255 *
1256 * OLDPRFLGSZ is the real minimum size of the buffer required by
1257 * conv_cnote_old_pr_flags(). However, Conv_cnote_old_pr_flags_buf_t
1258 * uses CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE to set the buffer size. We do
1259 * things this way because the definition of OLDPRFLGSZ uses information
1260 * that is not available in the environment of other programs
1261 * that include the conv.h header file.
1262 */
1263 #if (CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE != OLDPRFLGSZ) && !defined(__lint)
1264 #define REPORT_BUFSIZE OLDPRFLGSZ
1265 #include "report_bufsize.h"
1266 #error "CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE does not match OLDPRFLGSZ"
1267 #endif
1268
1269 const char *
conv_cnote_old_pr_flags(int flags,Conv_fmt_flags_t fmt_flags,Conv_cnote_old_pr_flags_buf_t * cnote_old_pr_flags_buf)1270 conv_cnote_old_pr_flags(int flags, Conv_fmt_flags_t fmt_flags,
1271 Conv_cnote_old_pr_flags_buf_t *cnote_old_pr_flags_buf)
1272 {
1273 /*
1274 * <sys/old_procfs.h> defines names for many of these flags
1275 * that are also defined in <sys/procfs.h>, but with different
1276 * values. To avoid confusion, we don't include <sys/old_procfs.h>,
1277 * and specify the values directly.
1278 */
1279 static const Val_desc vda[] = {
1280 { 0x0001, MSG_PR_FLAGS_STOPPED },
1281 { 0x0002, MSG_PR_FLAGS_ISTOP },
1282 { 0x0004, MSG_PR_FLAGS_DSTOP },
1283 { 0x0008, MSG_PR_FLAGS_ASLEEP },
1284 { 0x0010, MSG_PR_FLAGS_FORK },
1285 { 0x0020, MSG_PR_FLAGS_RLC },
1286 { 0x0040, MSG_PR_FLAGS_PTRACE },
1287 { 0x0080, MSG_PR_FLAGS_PCINVAL },
1288 { 0x0100, MSG_PR_FLAGS_ISSYS },
1289 { 0x0200, MSG_PR_FLAGS_STEP },
1290 { 0x0400, MSG_PR_FLAGS_KLC },
1291 { 0x0800, MSG_PR_FLAGS_ASYNC },
1292 { 0x1000, MSG_PR_FLAGS_PCOMPAT },
1293 { 0x2000, MSG_PR_FLAGS_MSACCT },
1294 { 0x4000, MSG_PR_FLAGS_BPTADJ },
1295 { 0x8000, MSG_PR_FLAGS_ASLWP },
1296 { 0, 0 }
1297 };
1298 static CONV_EXPN_FIELD_ARG conv_arg = {
1299 NULL, sizeof (cnote_old_pr_flags_buf->buf) };
1300
1301 if (flags == 0)
1302 return (MSG_ORIG(MSG_GBL_ZERO));
1303
1304 conv_arg.buf = cnote_old_pr_flags_buf->buf;
1305 conv_arg.oflags = conv_arg.rflags = flags;
1306 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
1307
1308 return ((const char *)cnote_old_pr_flags_buf->buf);
1309 }
1310
1311
1312 #define PROCFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1313 MSG_PROC_FLAG_SSYS_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1314 MSG_PROC_FLAG_SMSACCT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1315 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1316
1317 /*
1318 * Ensure that Conv_cnote_proc_flag_buf_t is large enough:
1319 *
1320 * PROCFLGSZ is the real minimum size of the buffer required by
1321 * conv_cnote_proc_flag(). However, Conv_cnote_proc_flag_buf_t
1322 * uses CONV_CNOTE_PROC_FLAG_BUFSIZE to set the buffer size. We do
1323 * things this way because the definition of PROCFLGSZ uses information
1324 * that is not available in the environment of other programs
1325 * that include the conv.h header file.
1326 */
1327 #if (CONV_CNOTE_PROC_FLAG_BUFSIZE != PROCFLGSZ) && !defined(__lint)
1328 #define REPORT_BUFSIZE PROCFLGSZ
1329 #include "report_bufsize.h"
1330 #error "CONV_CNOTE_PROC_FLAG_BUFSIZE does not match PROCFLGSZ"
1331 #endif
1332
1333 const char *
conv_cnote_proc_flag(int flags,Conv_fmt_flags_t fmt_flags,Conv_cnote_proc_flag_buf_t * cnote_proc_flag_buf)1334 conv_cnote_proc_flag(int flags, Conv_fmt_flags_t fmt_flags,
1335 Conv_cnote_proc_flag_buf_t *cnote_proc_flag_buf)
1336 {
1337 /*
1338 * Most of the proc flags are implementation dependant, and can
1339 * change between releases. As such, we do not attempt to translate
1340 * them to symbolic form, but simply report them in hex form.
1341 * However, SMSACCT and SSYS are special, and their bit values
1342 * are maintained between releases so they can be used in the
1343 * psinfo_t.p_flag field. We therefore translate these items.
1344 *
1345 * See <system/proc.h>
1346 *
1347 * Note: We don't want to include <sys/proc.h> in this file, because
1348 * it redefines 'struct list', which we have defined in sgs.h. As
1349 * SMSACCT and SSYS are stable public values, we simply use
1350 * their numeric value.
1351 */
1352 static const Val_desc vda[] = {
1353 { 0x00000001, MSG_PROC_FLAG_SSYS },
1354 { 0x02000000, MSG_PROC_FLAG_SMSACCT },
1355 { 0, 0 }
1356 };
1357 static CONV_EXPN_FIELD_ARG conv_arg = {
1358 NULL, sizeof (cnote_proc_flag_buf->buf) };
1359
1360 if (flags == 0)
1361 return (MSG_ORIG(MSG_GBL_ZERO));
1362
1363 conv_arg.buf = cnote_proc_flag_buf->buf;
1364 conv_arg.oflags = conv_arg.rflags = flags;
1365 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
1366
1367 return ((const char *)cnote_proc_flag_buf->buf);
1368 }
1369
1370
1371 #define SAFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1372 MSG_SA_ONSTACK_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1373 MSG_SA_RESETHAND_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1374 MSG_SA_RESTART_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1375 MSG_SA_SIGINFO_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1376 MSG_SA_NODEFER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1377 MSG_SA_NOCLDWAIT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1378 MSG_SA_NOCLDSTOP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1379 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1380
1381 /*
1382 * Ensure that Conv_cnote_sa_flags_buf_t is large enough:
1383 *
1384 * SAFLGSZ is the real minimum size of the buffer required by
1385 * conv_cnote_sa_flags(). However, Conv_cnote_sa_flags_buf_t
1386 * uses CONV_CNOTE_SA_FLAGS_BUFSIZE to set the buffer size. We do
1387 * things this way because the definition of SAFLGSZ uses information
1388 * that is not available in the environment of other programs
1389 * that include the conv.h header file.
1390 */
1391 #if (CONV_CNOTE_SA_FLAGS_BUFSIZE != SAFLGSZ) && !defined(__lint)
1392 #define REPORT_BUFSIZE SAFLGSZ
1393 #include "report_bufsize.h"
1394 #error "CONV_CNOTE_SA_FLAGS_BUFSIZE does not match SAFLGSZ"
1395 #endif
1396
1397 const char *
conv_cnote_sa_flags(int flags,Conv_fmt_flags_t fmt_flags,Conv_cnote_sa_flags_buf_t * cnote_sa_flags_buf)1398 conv_cnote_sa_flags(int flags, Conv_fmt_flags_t fmt_flags,
1399 Conv_cnote_sa_flags_buf_t *cnote_sa_flags_buf)
1400 {
1401 static const Val_desc vda[] = {
1402 { SA_ONSTACK, MSG_SA_ONSTACK },
1403 { SA_RESETHAND, MSG_SA_RESETHAND },
1404 { SA_RESTART, MSG_SA_RESTART },
1405 { SA_SIGINFO, MSG_SA_SIGINFO },
1406 { SA_NODEFER, MSG_SA_NODEFER },
1407 { SA_NOCLDWAIT, MSG_SA_NOCLDWAIT },
1408 { SA_NOCLDSTOP, MSG_SA_NOCLDSTOP },
1409 { 0, 0 }
1410 };
1411 static CONV_EXPN_FIELD_ARG conv_arg = {
1412 NULL, sizeof (cnote_sa_flags_buf->buf) };
1413
1414 if (flags == 0)
1415 return (MSG_ORIG(MSG_GBL_ZERO));
1416
1417 conv_arg.buf = cnote_sa_flags_buf->buf;
1418 conv_arg.oflags = conv_arg.rflags = flags;
1419 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
1420
1421 return ((const char *)cnote_sa_flags_buf->buf);
1422 }
1423
1424
1425 #define SSFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1426 MSG_SS_ONSTACK_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1427 MSG_SS_DISABLE_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1428 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1429
1430 /*
1431 * Ensure that Conv_cnote_ss_flags_buf_t is large enough:
1432 *
1433 * SSFLGSZ is the real minimum size of the buffer required by
1434 * conv_cnote_ss_flags(). However, Conv_cnote_ss_flags_buf_t
1435 * uses CONV_CNOTE_SS_FLAGS_BUFSIZE to set the buffer size. We do
1436 * things this way because the definition of SSFLGSZ uses information
1437 * that is not available in the environment of other programs
1438 * that include the conv.h header file.
1439 */
1440 #if (CONV_CNOTE_SS_FLAGS_BUFSIZE != SSFLGSZ) && !defined(__lint)
1441 #define REPORT_BUFSIZE SSFLGSZ
1442 #include "report_bufsize.h"
1443 #error "CONV_CNOTE_SS_FLAGS_BUFSIZE does not match SSFLGSZ"
1444 #endif
1445
1446 const char *
conv_cnote_ss_flags(int flags,Conv_fmt_flags_t fmt_flags,Conv_cnote_ss_flags_buf_t * cnote_ss_flags_buf)1447 conv_cnote_ss_flags(int flags, Conv_fmt_flags_t fmt_flags,
1448 Conv_cnote_ss_flags_buf_t *cnote_ss_flags_buf)
1449 {
1450 static const Val_desc vda[] = {
1451 { SS_ONSTACK, MSG_SS_ONSTACK },
1452 { SS_DISABLE, MSG_SS_DISABLE },
1453 { 0, 0 }
1454 };
1455 static CONV_EXPN_FIELD_ARG conv_arg = {
1456 NULL, sizeof (cnote_ss_flags_buf->buf) };
1457
1458 if (flags == 0)
1459 return (MSG_ORIG(MSG_GBL_ZERO));
1460
1461 conv_arg.buf = cnote_ss_flags_buf->buf;
1462 conv_arg.oflags = conv_arg.rflags = flags;
1463 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
1464
1465 return ((const char *)cnote_ss_flags_buf->buf);
1466 }
1467
1468
1469 /*
1470 * Solaris has a variety of types that use bitmasks to represent
1471 * sets of things like signals (sigset_t), faults (fltset_t), and
1472 * system calls (sysset_t). These types use arrays of unsigned 32-bit
1473 * integers to represent the set. These are public types that
1474 * cannot be changed, so they are generously oversized to allow
1475 * for future growth. Hence, there are usually unused bits.
1476 *
1477 * conv_bitmaskset() generalizes the process of displaying these items.
1478 */
1479
1480 typedef struct {
1481 const Val_desc *vdp; /* NULL, or bitmask description */
1482 uint32_t unused_bits; /* Mask of undefined bits */
1483 } conv_bitmaskset_desc_t;
1484
1485 /*
1486 * entry:
1487 * n_mask - # of 32-bit masks that make up this bitmask type.
1488 * maskarr - Array of n_mask 32-bit mask values
1489 * bitmask_descarr - Array of n_mask bitmask_desc_t descriptors,
1490 * one for each mask, specifying the bitmask names, and
1491 * a mask of the bits that are not defined by the system.
1492 * fmt_flags - CONV_FMT_* values, used to specify formatting details.
1493 * conv_buf - Buffer to receive formatted results
1494 * conv_buf_size - Size of conv_buf, including room for NULL termination
1495 */
1496 static const char *
conv_bitmaskset(uint32_t * maskarr,int n_mask,const conv_bitmaskset_desc_t * bitmask_descarr,Conv_fmt_flags_t fmt_flags,char * conv_buf,size_t conv_buf_size)1497 conv_bitmaskset(uint32_t *maskarr, int n_mask,
1498 const conv_bitmaskset_desc_t *bitmask_descarr, Conv_fmt_flags_t fmt_flags,
1499 char *conv_buf, size_t conv_buf_size)
1500 {
1501 CONV_EXPN_FIELD_ARG conv_arg;
1502 int i, need_sep = 0;
1503
1504 /* If every bit of every mask is 0, return 0 as the result */
1505 for (i = 0; i < n_mask; i++)
1506 if (maskarr[i] != 0)
1507 break;
1508 if (i == n_mask)
1509 return (MSG_ORIG(MSG_GBL_ZERO));
1510
1511 /*
1512 * At least one bit is non-zero. Move through the masks
1513 * and process each one.
1514 */
1515 (void) memset(&conv_arg, 0, sizeof (conv_arg));
1516 conv_arg.bufsize = conv_buf_size;
1517 conv_arg.buf = conv_buf;
1518 if ((fmt_flags & CONV_FMT_NOBKT) == 0) {
1519 *conv_arg.buf++ = '[';
1520 *conv_arg.buf++ = ' ';
1521 conv_arg.bufsize -= 2;
1522 }
1523
1524 /*
1525 * conv_expn_field() orders its output with the most significant
1526 * bits on the left. To preserve this ordering across the
1527 * subwords or our "virtual bitmask", we need to process
1528 * the sub-words in the same order, from most significant down
1529 * to least significant. Since unassigned bits tend to be at
1530 * the MSB end of the word, we process the unused bits first.
1531 *
1532 * One implication of this is that the caller should not use
1533 * the unassigned bits for "abandoned" bits in the middle of
1534 * a used range, but should instead define the string for
1535 * that bit as being the string representation of that decimal
1536 * value (i.e. "65"). That will cause the bit to be properly
1537 * sorted among the named bits to either side of it.
1538 */
1539 for (i = 0; i < n_mask; i++) {
1540 size_t n;
1541 uint32_t mask, unused_bits;
1542 const int bits_per_mask = sizeof (mask) * 8;
1543
1544 mask = maskarr[i];
1545 unused_bits = mask & bitmask_descarr[i].unused_bits;
1546 mask &= ~unused_bits;
1547
1548 if (mask != 0) {
1549
1550 conv_arg.oflags = conv_arg.rflags = mask;
1551 if (need_sep) {
1552 *conv_arg.buf++ = ' ';
1553 conv_arg.bufsize--;
1554 }
1555 need_sep = 1;
1556 (void) conv_expn_field(&conv_arg,
1557 bitmask_descarr[i].vdp, fmt_flags | CONV_FMT_NOBKT);
1558 n = strlen(conv_arg.buf);
1559 conv_arg.bufsize -= n;
1560 conv_arg.buf += n;
1561 }
1562
1563 if (unused_bits != 0) {
1564 uint32_t bit = 0x00000001;
1565 int j;
1566
1567 for (j = 1; j <= bits_per_mask; j++, bit *= 2) {
1568 if ((unused_bits & bit) == 0)
1569 continue;
1570
1571 if (need_sep) {
1572 *conv_arg.buf++ = ' ';
1573 conv_arg.bufsize--;
1574 }
1575 need_sep = 1;
1576 n = snprintf(conv_arg.buf, conv_arg.bufsize,
1577 MSG_ORIG(MSG_FMT_WORD),
1578 EC_WORD(j + (bits_per_mask * i)));
1579 conv_arg.buf += n;
1580 conv_arg.bufsize -= n;
1581 }
1582 }
1583 }
1584 if ((fmt_flags & CONV_FMT_NOBKT) == 0) {
1585 *conv_arg.buf++ = ' ';
1586 *conv_arg.buf++ = ']';
1587 }
1588 *conv_arg.buf = '\0';
1589
1590 return ((const char *) conv_buf);
1591 }
1592
1593
1594 #define SIGSET_FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1595 /* sigset_t [0] - Signals [1 - 32] */ \
1596 MSG_SIGHUP_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1597 MSG_SIGINT_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1598 MSG_SIGQUIT_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1599 MSG_SIGILL_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1600 MSG_SIGTRAP_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1601 MSG_SIGABRT_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1602 MSG_SIGEMT_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1603 MSG_SIGFPE_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1604 MSG_SIGKILL_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1605 MSG_SIGBUS_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1606 MSG_SIGSEGV_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1607 MSG_SIGSYS_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1608 MSG_SIGPIPE_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1609 MSG_SIGALRM_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1610 MSG_SIGTERM_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1611 MSG_SIGUSR1_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1612 MSG_SIGUSR2_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1613 MSG_SIGCHLD_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1614 MSG_SIGPWR_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1615 MSG_SIGWINCH_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1616 MSG_SIGURG_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1617 MSG_SIGPOLL_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1618 MSG_SIGSTOP_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1619 MSG_SIGTSTP_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1620 MSG_SIGCONT_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1621 MSG_SIGTTIN_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1622 MSG_SIGTTOU_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1623 MSG_SIGVTALRM_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1624 MSG_SIGPROF_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1625 MSG_SIGXCPU_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1626 MSG_SIGXFSZ_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1627 MSG_SIGWAITING_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1628 \
1629 /* \
1630 * sigset_t [1] - Signals [33 - 64] \
1631 * There are 24 unused bits, each of which needs two \
1632 * characters plus a separator. \
1633 */ \
1634 MSG_SIGLWP_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1635 MSG_SIGFREEZE_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1636 MSG_SIGTHAW_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1637 MSG_SIGCANCEL_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1638 MSG_SIGLOST_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1639 MSG_SIGXRES_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1640 MSG_SIGJVM1_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1641 MSG_SIGJVM2_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1642 (24 * (2 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1643 \
1644 /* \
1645 * sigset_t [2] - Signals [65 - 96] \
1646 * There are 32 unused bits, each of which needs two \
1647 * characters plus a separator. \
1648 */ \
1649 (32 * (2 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1650 \
1651 /* \
1652 * sigset_t [2] - Signals [97 - 128] \
1653 * There are 32 unused bits. Three of these need two \
1654 * characters, and 29 need 3. Each one needs a separator. \
1655 */ \
1656 (3 * (2 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1657 (29 * (3 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1658 \
1659 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1660
1661 /*
1662 * Ensure that Conv_cnote_sigset_buf_t is large enough:
1663 *
1664 * SIGSET_FLAGSZ is the real minimum size of the buffer required by
1665 * conv_cnote_sigset(). However, Conv_cnote_sigset_buf_t
1666 * uses CONV_CNOTE_SIGSET_BUFSIZE to set the buffer size. We do
1667 * things this way because the definition of SIGSET_FLAGSZ uses information
1668 * that is not available in the environment of other programs
1669 * that include the conv.h header file.
1670 */
1671 #if (CONV_CNOTE_SIGSET_BUFSIZE != SIGSET_FLAGSZ) && !defined(__lint)
1672 #define REPORT_BUFSIZE SIGSET_FLAGSZ
1673 #include "report_bufsize.h"
1674 #error "CONV_CNOTE_SIGSET_BUFSIZE does not match SIGSET_FLAGSZ"
1675 #endif
1676
1677 const char *
conv_cnote_sigset(uint32_t * maskarr,int n_mask,Conv_fmt_flags_t fmt_flags,Conv_cnote_sigset_buf_t * cnote_sigset_buf)1678 conv_cnote_sigset(uint32_t *maskarr, int n_mask,
1679 Conv_fmt_flags_t fmt_flags, Conv_cnote_sigset_buf_t *cnote_sigset_buf)
1680 {
1681 #define N_MASK 4
1682
1683 static const Val_desc vda0[] = {
1684 { 0x00000001, MSG_SIGHUP_ALT },
1685 { 0x00000002, MSG_SIGINT_ALT },
1686 { 0x00000004, MSG_SIGQUIT_ALT },
1687 { 0x00000008, MSG_SIGILL_ALT },
1688 { 0x00000010, MSG_SIGTRAP_ALT },
1689 { 0x00000020, MSG_SIGABRT_ALT },
1690 { 0x00000040, MSG_SIGEMT_ALT },
1691 { 0x00000080, MSG_SIGFPE_ALT },
1692 { 0x00000100, MSG_SIGKILL_ALT },
1693 { 0x00000200, MSG_SIGBUS_ALT },
1694 { 0x00000400, MSG_SIGSEGV_ALT },
1695 { 0x00000800, MSG_SIGSYS_ALT },
1696 { 0x00001000, MSG_SIGPIPE_ALT },
1697 { 0x00002000, MSG_SIGALRM_ALT },
1698 { 0x00004000, MSG_SIGTERM_ALT },
1699 { 0x00008000, MSG_SIGUSR1_ALT },
1700 { 0x00010000, MSG_SIGUSR2_ALT },
1701 { 0x00020000, MSG_SIGCHLD_ALT },
1702 { 0x00040000, MSG_SIGPWR_ALT },
1703 { 0x00080000, MSG_SIGWINCH_ALT },
1704 { 0x00100000, MSG_SIGURG_ALT },
1705 { 0x00200000, MSG_SIGPOLL_ALT },
1706 { 0x00400000, MSG_SIGSTOP_ALT },
1707 { 0x00800000, MSG_SIGTSTP_ALT },
1708 { 0x01000000, MSG_SIGCONT_ALT },
1709 { 0x02000000, MSG_SIGTTIN_ALT },
1710 { 0x04000000, MSG_SIGTTOU_ALT },
1711 { 0x08000000, MSG_SIGVTALRM_ALT },
1712 { 0x10000000, MSG_SIGPROF_ALT },
1713 { 0x20000000, MSG_SIGXCPU_ALT },
1714 { 0x40000000, MSG_SIGXFSZ_ALT },
1715 { 0x80000000, MSG_SIGWAITING_ALT },
1716 { 0, 0 }
1717 };
1718 static const Val_desc vda1[] = {
1719 { 0x00000001, MSG_SIGLWP_ALT },
1720 { 0x00000002, MSG_SIGFREEZE_ALT },
1721 { 0x00000004, MSG_SIGTHAW_ALT },
1722 { 0x00000008, MSG_SIGCANCEL_ALT },
1723 { 0x00000010, MSG_SIGLOST_ALT },
1724 { 0x00000020, MSG_SIGXRES_ALT },
1725 { 0x00000040, MSG_SIGJVM1_ALT },
1726 { 0x00000080, MSG_SIGJVM2_ALT },
1727 { 0, 0 }
1728 };
1729 static const conv_bitmaskset_desc_t bitmask_desc[N_MASK] = {
1730 { vda0, 0 },
1731 { vda1, 0xffffff00 },
1732 { NULL, 0xffffffff },
1733 { NULL, 0xffffffff }
1734 };
1735
1736 if (n_mask > N_MASK)
1737 n_mask = N_MASK;
1738 return (conv_bitmaskset(maskarr, n_mask, bitmask_desc, fmt_flags,
1739 cnote_sigset_buf->buf, CONV_CNOTE_SIGSET_BUFSIZE));
1740
1741 #undef N_MASK
1742 }
1743
1744
1745 #define FLTSET_FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1746 /* \
1747 * fltset_t[0] - Faults [1 - 32] \
1748 * There are 19 unused bits, each of which needs two \
1749 * characters plus a separator. \
1750 */ \
1751 MSG_FLTILL_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1752 MSG_FLTPRIV_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1753 MSG_FLTBPT_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1754 MSG_FLTTRACE_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1755 MSG_FLTACCESS_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1756 MSG_FLTBOUNDS_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1757 MSG_FLTIOVF_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1758 MSG_FLTIZDIV_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1759 MSG_FLTFPE_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1760 MSG_FLTSTACK_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1761 MSG_FLTPAGE_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1762 MSG_FLTWATCH_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1763 MSG_FLTCPCOVF_ALT_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
1764 (19 * (2 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1765 /* \
1766 * fltset_t [1] - Faults [33 - 64] \
1767 * There are 32 unused bits, each of which needs two \
1768 * characters plus a separator. \
1769 */ \
1770 (32 * (2 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1771 /* \
1772 * fltset_t [2] - Faults [65 - 96] \
1773 * There are 32 unused bits, each of which needs two \
1774 * characters plus a separator. \
1775 */ \
1776 (32 * (2 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1777 /* \
1778 * fltset_t [3] - Faults [97 - 128] \
1779 * There are 32 unused bits. Three of these need two \
1780 * characters, and 29 need 3. Each one needs a separator. \
1781 */ \
1782 (3 * (2 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1783 (29 * (3 + CONV_EXPN_FIELD_DEF_SEP_SIZE)) + \
1784 \
1785 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
1786
1787 /*
1788 * Ensure that Conv_cnote_fltset_buf_t is large enough:
1789 *
1790 * FLTSET_FLAGSZ is the real minimum size of the buffer required by
1791 * conv_cnote_fltset(). However, Conv_cnote_fltset_buf_t
1792 * uses CONV_CNOTE_FLTSET_BUFSIZE to set the buffer size. We do
1793 * things this way because the definition of FLTSET_FLAGSZ uses information
1794 * that is not available in the environment of other programs
1795 * that include the conv.h header file.
1796 */
1797 #if (CONV_CNOTE_FLTSET_BUFSIZE != FLTSET_FLAGSZ) && !defined(__lint)
1798 #define REPORT_BUFSIZE FLTSET_FLAGSZ
1799 #include "report_bufsize.h"
1800 #error "CONV_CNOTE_FLTSET_BUFSIZE does not match FLTSET_FLAGSZ"
1801 #endif
1802
1803 const char *
conv_cnote_fltset(uint32_t * maskarr,int n_mask,Conv_fmt_flags_t fmt_flags,Conv_cnote_fltset_buf_t * cnote_fltset_buf)1804 conv_cnote_fltset(uint32_t *maskarr, int n_mask,
1805 Conv_fmt_flags_t fmt_flags, Conv_cnote_fltset_buf_t *cnote_fltset_buf)
1806 {
1807 #define N_MASK 4
1808
1809 static const Val_desc vda0[] = {
1810 { 0x00000001, MSG_FLTILL_ALT },
1811 { 0x00000002, MSG_FLTPRIV_ALT },
1812 { 0x00000004, MSG_FLTBPT_ALT },
1813 { 0x00000008, MSG_FLTTRACE_ALT },
1814 { 0x00000010, MSG_FLTACCESS_ALT },
1815 { 0x00000020, MSG_FLTBOUNDS_ALT },
1816 { 0x00000040, MSG_FLTIOVF_ALT },
1817 { 0x00000080, MSG_FLTIZDIV_ALT },
1818 { 0x00000100, MSG_FLTFPE_ALT },
1819 { 0x00000200, MSG_FLTSTACK_ALT },
1820 { 0x00000400, MSG_FLTPAGE_ALT },
1821 { 0x00000800, MSG_FLTWATCH_ALT },
1822 { 0x00001000, MSG_FLTCPCOVF_ALT },
1823 { 0, 0 }
1824 };
1825 static const conv_bitmaskset_desc_t bitmask_desc[N_MASK] = {
1826 { vda0, 0xffffe000 },
1827 { NULL, 0xffffffff },
1828 { NULL, 0xffffffff },
1829 { NULL, 0xffffffff }
1830 };
1831
1832 if (n_mask > N_MASK)
1833 n_mask = N_MASK;
1834 return (conv_bitmaskset(maskarr, n_mask, bitmask_desc, fmt_flags,
1835 cnote_fltset_buf->buf, CONV_CNOTE_FLTSET_BUFSIZE));
1836
1837 #undef N_MASK
1838 }
1839
1840
1841
1842 #define SYSSET_FLAGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
1843 (512 * CONV_EXPN_FIELD_DEF_SEP_SIZE) + \
1844 \
1845 /* sysset_t[0] - System Calls [1 - 32] */ \
1846 MSG_SYS_EXIT_ALT_SIZE /* 1 */ + \
1847 MSG_SYS_2_SIZE /* 2 (unused) */ + \
1848 MSG_SYS_READ_ALT_SIZE /* 3 */ + \
1849 MSG_SYS_WRITE_ALT_SIZE /* 4 */ + \
1850 MSG_SYS_OPEN_ALT_SIZE /* 5 */ + \
1851 MSG_SYS_CLOSE_ALT_SIZE /* 6 */ + \
1852 MSG_SYS_7_SIZE /* 7 (unused) */ + \
1853 MSG_SYS_8_SIZE /* 8 (unused) */ + \
1854 MSG_SYS_LINK_ALT_SIZE /* 9 */ + \
1855 MSG_SYS_UNLINK_ALT_SIZE /* 10 */ + \
1856 MSG_SYS_11_SIZE /* 11 (unused) */ + \
1857 MSG_SYS_CHDIR_ALT_SIZE /* 12 */ + \
1858 MSG_SYS_TIME_ALT_SIZE /* 13 */ + \
1859 MSG_SYS_MKNOD_ALT_SIZE /* 14 */ + \
1860 MSG_SYS_CHMOD_ALT_SIZE /* 15 */ + \
1861 MSG_SYS_CHOWN_ALT_SIZE /* 16 */ + \
1862 MSG_SYS_BRK_ALT_SIZE /* 17 */ + \
1863 MSG_SYS_STAT_ALT_SIZE /* 18 */ + \
1864 MSG_SYS_LSEEK_ALT_SIZE /* 19 */ + \
1865 MSG_SYS_GETPID_ALT_SIZE /* 20 */ + \
1866 MSG_SYS_MOUNT_ALT_SIZE /* 21 */ + \
1867 MSG_SYS_22_SIZE /* 22 (unused) */ + \
1868 MSG_SYS_SETUID_ALT_SIZE /* 23 */ + \
1869 MSG_SYS_GETUID_ALT_SIZE /* 24 */ + \
1870 MSG_SYS_STIME_ALT_SIZE /* 25 */ + \
1871 MSG_SYS_PCSAMPLE_ALT_SIZE /* 26 */ + \
1872 MSG_SYS_ALARM_ALT_SIZE /* 27 */ + \
1873 MSG_SYS_FSTAT_ALT_SIZE /* 28 */ + \
1874 MSG_SYS_PAUSE_ALT_SIZE /* 29 */ + \
1875 MSG_SYS_30_SIZE /* 30 (unused) */ + \
1876 MSG_SYS_STTY_ALT_SIZE /* 31 */ + \
1877 MSG_SYS_GTTY_ALT_SIZE /* 32 */ + \
1878 \
1879 /* sysset_t[1] - System Calls [33 - 64] */ \
1880 MSG_SYS_ACCESS_ALT_SIZE /* 33 */ + \
1881 MSG_SYS_NICE_ALT_SIZE /* 34 */ + \
1882 MSG_SYS_STATFS_ALT_SIZE /* 35 */ + \
1883 MSG_SYS_SYNC_ALT_SIZE /* 36 */ + \
1884 MSG_SYS_KILL_ALT_SIZE /* 37 */ + \
1885 MSG_SYS_FSTATFS_ALT_SIZE /* 38 */ + \
1886 MSG_SYS_PGRPSYS_ALT_SIZE /* 39 */ + \
1887 MSG_SYS_UUCOPYSTR_ALT_SIZE /* 40 */ + \
1888 MSG_SYS_41_SIZE /* 41 (unused) */ + \
1889 MSG_SYS_PIPE_ALT_SIZE /* 42 */ + \
1890 MSG_SYS_TIMES_ALT_SIZE /* 43 */ + \
1891 MSG_SYS_PROFIL_ALT_SIZE /* 44 */ + \
1892 MSG_SYS_FACCESSAT_ALT_SIZE /* 45 */ + \
1893 MSG_SYS_SETGID_ALT_SIZE /* 46 */ + \
1894 MSG_SYS_GETGID_ALT_SIZE /* 47 */ + \
1895 MSG_SYS_48_SIZE /* 48 (unused) */ + \
1896 MSG_SYS_MSGSYS_ALT_SIZE /* 49 */ + \
1897 MSG_SYS_SYSI86_ALT_SIZE /* 50 */ + \
1898 MSG_SYS_ACCT_ALT_SIZE /* 51 */ + \
1899 MSG_SYS_SHMSYS_ALT_SIZE /* 52 */ + \
1900 MSG_SYS_SEMSYS_ALT_SIZE /* 53 */ + \
1901 MSG_SYS_IOCTL_ALT_SIZE /* 54 */ + \
1902 MSG_SYS_UADMIN_ALT_SIZE /* 55 */ + \
1903 MSG_SYS_FCHOWNAT_ALT_SIZE /* 56 */ + \
1904 MSG_SYS_UTSSYS_ALT_SIZE /* 57 */ + \
1905 MSG_SYS_FDSYNC_ALT_SIZE /* 58 */ + \
1906 MSG_SYS_EXECVE_ALT_SIZE /* 59 */ + \
1907 MSG_SYS_UMASK_ALT_SIZE /* 60 */ + \
1908 MSG_SYS_CHROOT_ALT_SIZE /* 61 */ + \
1909 MSG_SYS_FCNTL_ALT_SIZE /* 62 */ + \
1910 MSG_SYS_ULIMIT_ALT_SIZE /* 63 */ + \
1911 MSG_SYS_RENAMEAT_ALT_SIZE /* 64 */ + \
1912 \
1913 /* sysset_t[2] - System Calls [65 - 96] */ \
1914 MSG_SYS_UNLINKAT_ALT_SIZE /* 65 */ + \
1915 MSG_SYS_FSTATAT_ALT_SIZE /* 66 */ + \
1916 MSG_SYS_FSTATAT64_ALT_SIZE /* 67 */ + \
1917 MSG_SYS_OPENAT_ALT_SIZE /* 68 */ + \
1918 MSG_SYS_OPENAT64_ALT_SIZE /* 69 */ + \
1919 MSG_SYS_TASKSYS_ALT_SIZE /* 70 */ + \
1920 MSG_SYS_ACCTCTL_ALT_SIZE /* 71 */ + \
1921 MSG_SYS_EXACCTSYS_ALT_SIZE /* 72 */ + \
1922 MSG_SYS_GETPAGESIZES_ALT_SIZE /* 73 */ + \
1923 MSG_SYS_RCTLSYS_ALT_SIZE /* 74 */ + \
1924 MSG_SYS_SIDSYS_ALT_SIZE /* 75 */ + \
1925 MSG_SYS_76_SIZE /* 76 (unused) */ + \
1926 MSG_SYS_LWP_PARK_ALT_SIZE /* 77 */ + \
1927 MSG_SYS_SENDFILEV_ALT_SIZE /* 78 */ + \
1928 MSG_SYS_RMDIR_ALT_SIZE /* 79 */ + \
1929 MSG_SYS_MKDIR_ALT_SIZE /* 80 */ + \
1930 MSG_SYS_GETDENTS_ALT_SIZE /* 81 */ + \
1931 MSG_SYS_PRIVSYS_ALT_SIZE /* 82 */ + \
1932 MSG_SYS_UCREDSYS_ALT_SIZE /* 83 */ + \
1933 MSG_SYS_SYSFS_ALT_SIZE /* 84 */ + \
1934 MSG_SYS_GETMSG_ALT_SIZE /* 85 */ + \
1935 MSG_SYS_PUTMSG_ALT_SIZE /* 86 */ + \
1936 MSG_SYS_87_SIZE /* 87 (unused) */ + \
1937 MSG_SYS_LSTAT_ALT_SIZE /* 88 */ + \
1938 MSG_SYS_SYMLINK_ALT_SIZE /* 89 */ + \
1939 MSG_SYS_READLINK_ALT_SIZE /* 90 */ + \
1940 MSG_SYS_SETGROUPS_ALT_SIZE /* 91 */ + \
1941 MSG_SYS_GETGROUPS_ALT_SIZE /* 92 */ + \
1942 MSG_SYS_FCHMOD_ALT_SIZE /* 93 */ + \
1943 MSG_SYS_FCHOWN_ALT_SIZE /* 94 */ + \
1944 MSG_SYS_SIGPROCMASK_ALT_SIZE /* 95 */ + \
1945 MSG_SYS_SIGSUSPEND_ALT_SIZE /* 96 */ + \
1946 \
1947 /* sysset_t[3] - System Calls [97 - 128] */ \
1948 MSG_SYS_SIGALTSTACK_ALT_SIZE /* 97 */ + \
1949 MSG_SYS_SIGACTION_ALT_SIZE /* 98 */ + \
1950 MSG_SYS_SIGPENDING_ALT_SIZE /* 99 */ + \
1951 MSG_SYS_CONTEXT_ALT_SIZE /* 100 */ + \
1952 MSG_SYS_101_SIZE /* 101 (unused) */ + \
1953 MSG_SYS_102_SIZE /* 102 (unused) */ + \
1954 MSG_SYS_STATVFS_ALT_SIZE /* 103 */ + \
1955 MSG_SYS_FSTATVFS_ALT_SIZE /* 104 */ + \
1956 MSG_SYS_GETLOADAVG_ALT_SIZE /* 105 */ + \
1957 MSG_SYS_NFSSYS_ALT_SIZE /* 106 */ + \
1958 MSG_SYS_WAITID_ALT_SIZE /* 107 */ + \
1959 MSG_SYS_SIGSENDSYS_ALT_SIZE /* 108 */ + \
1960 MSG_SYS_HRTSYS_ALT_SIZE /* 109 */ + \
1961 MSG_SYS_UTIMESYS_ALT_SIZE /* 110 */ + \
1962 MSG_SYS_SIGRESEND_ALT_SIZE /* 111 */ + \
1963 MSG_SYS_PRIOCNTLSYS_ALT_SIZE /* 112 */ + \
1964 MSG_SYS_PATHCONF_ALT_SIZE /* 113 */ + \
1965 MSG_SYS_MINCORE_ALT_SIZE /* 114 */ + \
1966 MSG_SYS_MMAP_ALT_SIZE /* 115 */ + \
1967 MSG_SYS_MPROTECT_ALT_SIZE /* 116 */ + \
1968 MSG_SYS_MUNMAP_ALT_SIZE /* 117 */ + \
1969 MSG_SYS_FPATHCONF_ALT_SIZE /* 118 */ + \
1970 MSG_SYS_VFORK_ALT_SIZE /* 119 */ + \
1971 MSG_SYS_FCHDIR_ALT_SIZE /* 120 */ + \
1972 MSG_SYS_READV_ALT_SIZE /* 121 */ + \
1973 MSG_SYS_WRITEV_ALT_SIZE /* 122 */ + \
1974 MSG_SYS_PREADV_SIZE /* 123 */ + \
1975 MSG_SYS_PWRITEV_SIZE /* 124 */ + \
1976 MSG_SYS_UPANIC_SIZE /* 125 */ + \
1977 MSG_SYS_GETRANDOM_SIZE /* 126 */ + \
1978 MSG_SYS_MMAPOBJ_ALT_SIZE /* 127 */ + \
1979 MSG_SYS_SETRLIMIT_ALT_SIZE /* 128 */ + \
1980 \
1981 /* sysset_t[4] - System Calls [129 - 160] */ \
1982 MSG_SYS_GETRLIMIT_ALT_SIZE /* 129 */ + \
1983 MSG_SYS_LCHOWN_ALT_SIZE /* 130 */ + \
1984 MSG_SYS_MEMCNTL_ALT_SIZE /* 131 */ + \
1985 MSG_SYS_GETPMSG_ALT_SIZE /* 132 */ + \
1986 MSG_SYS_PUTPMSG_ALT_SIZE /* 133 */ + \
1987 MSG_SYS_RENAME_ALT_SIZE /* 134 */ + \
1988 MSG_SYS_UNAME_ALT_SIZE /* 135 */ + \
1989 MSG_SYS_SETEGID_ALT_SIZE /* 136 */ + \
1990 MSG_SYS_SYSCONFIG_ALT_SIZE /* 137 */ + \
1991 MSG_SYS_ADJTIME_ALT_SIZE /* 138 */ + \
1992 MSG_SYS_SYSTEMINFO_ALT_SIZE /* 139 */ + \
1993 MSG_SYS_SHAREFS_ALT_SIZE /* 140 */ + \
1994 MSG_SYS_SETEUID_ALT_SIZE /* 141 */ + \
1995 MSG_SYS_FORKSYS_ALT_SIZE /* 142 */ + \
1996 MSG_SYS_143_SIZE /* 143 (unused) */ + \
1997 MSG_SYS_SIGTIMEDWAIT_ALT_SIZE /* 144 */ + \
1998 MSG_SYS_LWP_INFO_ALT_SIZE /* 145 */ + \
1999 MSG_SYS_YIELD_ALT_SIZE /* 146 */ + \
2000 MSG_SYS_147_SIZE /* 147 (unused) */ + \
2001 MSG_SYS_LWP_SEMA_POST_ALT_SIZE /* 148 */ + \
2002 MSG_SYS_LWP_SEMA_TRYWAIT_ALT_SIZE /* 149 */ + \
2003 MSG_SYS_LWP_DETACH_ALT_SIZE /* 150 */ + \
2004 MSG_SYS_CORECTL_ALT_SIZE /* 151 */ + \
2005 MSG_SYS_MODCTL_ALT_SIZE /* 152 */ + \
2006 MSG_SYS_FCHROOT_ALT_SIZE /* 153 */ + \
2007 MSG_SYS_154_SIZE /* 154 (unused) */ + \
2008 MSG_SYS_VHANGUP_ALT_SIZE /* 155 */ + \
2009 MSG_SYS_GETTIMEOFDAY_ALT_SIZE /* 156 */ + \
2010 MSG_SYS_GETITIMER_ALT_SIZE /* 157 */ + \
2011 MSG_SYS_SETITIMER_ALT_SIZE /* 158 */ + \
2012 MSG_SYS_LWP_CREATE_ALT_SIZE /* 159 */ + \
2013 MSG_SYS_LWP_EXIT_ALT_SIZE /* 160 */ + \
2014 \
2015 /* sysset_t[5] - System Calls [161 - 192] */ \
2016 MSG_SYS_LWP_SUSPEND_ALT_SIZE /* 161 */ + \
2017 MSG_SYS_LWP_CONTINUE_ALT_SIZE /* 162 */ + \
2018 MSG_SYS_LWP_KILL_ALT_SIZE /* 163 */ + \
2019 MSG_SYS_LWP_SELF_ALT_SIZE /* 164 */ + \
2020 MSG_SYS_LWP_SIGMASK_ALT_SIZE /* 165 */ + \
2021 MSG_SYS_LWP_PRIVATE_ALT_SIZE /* 166 */ + \
2022 MSG_SYS_LWP_WAIT_ALT_SIZE /* 167 */ + \
2023 MSG_SYS_LWP_MUTEX_WAKEUP_ALT_SIZE /* 168 */ + \
2024 MSG_SYS_169_SIZE /* 169 (unused) */ + \
2025 MSG_SYS_LWP_COND_WAIT_ALT_SIZE /* 170 */ + \
2026 MSG_SYS_LWP_COND_SIGNAL_ALT_SIZE /* 171 */ + \
2027 MSG_SYS_LWP_COND_BROADCAST_ALT_SIZE /* 172 */ + \
2028 MSG_SYS_PREAD_ALT_SIZE /* 173 */ + \
2029 MSG_SYS_PWRITE_ALT_SIZE /* 174 */ + \
2030 MSG_SYS_LLSEEK_ALT_SIZE /* 175 */ + \
2031 MSG_SYS_INST_SYNC_ALT_SIZE /* 176 */ + \
2032 MSG_SYS_BRAND_ALT_SIZE /* 177 */ + \
2033 MSG_SYS_KAIO_ALT_SIZE /* 178 */ + \
2034 MSG_SYS_CPC_ALT_SIZE /* 179 */ + \
2035 MSG_SYS_LGRPSYS_ALT_SIZE /* 180 */ + \
2036 MSG_SYS_RUSAGESYS_ALT_SIZE /* 181 */ + \
2037 MSG_SYS_PORT_ALT_SIZE /* 182 */ + \
2038 MSG_SYS_POLLSYS_ALT_SIZE /* 183 */ + \
2039 MSG_SYS_LABELSYS_ALT_SIZE /* 184 */ + \
2040 MSG_SYS_ACL_ALT_SIZE /* 185 */ + \
2041 MSG_SYS_AUDITSYS_ALT_SIZE /* 186 */ + \
2042 MSG_SYS_PROCESSOR_BIND_ALT_SIZE /* 187 */ + \
2043 MSG_SYS_PROCESSOR_INFO_ALT_SIZE /* 188 */ + \
2044 MSG_SYS_P_ONLINE_ALT_SIZE /* 189 */ + \
2045 MSG_SYS_SIGQUEUE_ALT_SIZE /* 190 */ + \
2046 MSG_SYS_CLOCK_GETTIME_ALT_SIZE /* 191 */ + \
2047 MSG_SYS_CLOCK_SETTIME_ALT_SIZE /* 192 */ + \
2048 \
2049 /* sysset_t[6] - System Calls [193 - 224] */ \
2050 MSG_SYS_CLOCK_GETRES_ALT_SIZE /* 193 */ + \
2051 MSG_SYS_TIMER_CREATE_ALT_SIZE /* 194 */ + \
2052 MSG_SYS_TIMER_DELETE_ALT_SIZE /* 195 */ + \
2053 MSG_SYS_TIMER_SETTIME_ALT_SIZE /* 196 */ + \
2054 MSG_SYS_TIMER_GETTIME_ALT_SIZE /* 197 */ + \
2055 MSG_SYS_TIMER_GETOVERRUN_ALT_SIZE /* 198 */ + \
2056 MSG_SYS_NANOSLEEP_ALT_SIZE /* 199 */ + \
2057 MSG_SYS_FACL_ALT_SIZE /* 200 */ + \
2058 MSG_SYS_DOOR_ALT_SIZE /* 201 */ + \
2059 MSG_SYS_SETREUID_ALT_SIZE /* 202 */ + \
2060 MSG_SYS_SETREGID_ALT_SIZE /* 203 */ + \
2061 MSG_SYS_INSTALL_UTRAP_ALT_SIZE /* 204 */ + \
2062 MSG_SYS_SIGNOTIFY_ALT_SIZE /* 205 */ + \
2063 MSG_SYS_SCHEDCTL_ALT_SIZE /* 206 */ + \
2064 MSG_SYS_PSET_ALT_SIZE /* 207 */ + \
2065 MSG_SYS_SPARC_UTRAP_INSTALL_ALT_SIZE /* 208 */ + \
2066 MSG_SYS_RESOLVEPATH_ALT_SIZE /* 209 */ + \
2067 MSG_SYS_LWP_MUTEX_TIMEDLOCK_ALT_SIZE /* 210 */ + \
2068 MSG_SYS_LWP_SEMA_TIMEDWAIT_ALT_SIZE /* 211 */ + \
2069 MSG_SYS_LWP_RWLOCK_SYS_ALT_SIZE /* 212 */ + \
2070 MSG_SYS_GETDENTS64_ALT_SIZE /* 213 */ + \
2071 MSG_SYS_MMAP64_ALT_SIZE /* 214 */ + \
2072 MSG_SYS_STAT64_ALT_SIZE /* 215 */ + \
2073 MSG_SYS_LSTAT64_ALT_SIZE /* 216 */ + \
2074 MSG_SYS_FSTAT64_ALT_SIZE /* 217 */ + \
2075 MSG_SYS_STATVFS64_ALT_SIZE /* 218 */ + \
2076 MSG_SYS_FSTATVFS64_ALT_SIZE /* 219 */ + \
2077 MSG_SYS_SETRLIMIT64_ALT_SIZE /* 220 */ + \
2078 MSG_SYS_GETRLIMIT64_ALT_SIZE /* 221 */ + \
2079 MSG_SYS_PREAD64_ALT_SIZE /* 222 */ + \
2080 MSG_SYS_PWRITE64_ALT_SIZE /* 223 */ + \
2081 MSG_SYS_224_SIZE /* 224 (unused) */ + \
2082 \
2083 /* sysset_t[7] - System Calls [225 - 256] */ \
2084 MSG_SYS_OPEN64_ALT_SIZE /* 225 */ + \
2085 MSG_SYS_RPCSYS_ALT_SIZE /* 226 */ + \
2086 MSG_SYS_ZONE_ALT_SIZE /* 227 */ + \
2087 MSG_SYS_AUTOFSSYS_ALT_SIZE /* 228 */ + \
2088 MSG_SYS_GETCWD_ALT_SIZE /* 229 */ + \
2089 MSG_SYS_SO_SOCKET_ALT_SIZE /* 230 */ + \
2090 MSG_SYS_SO_SOCKETPAIR_ALT_SIZE /* 231 */ + \
2091 MSG_SYS_BIND_ALT_SIZE /* 232 */ + \
2092 MSG_SYS_LISTEN_ALT_SIZE /* 233 */ + \
2093 MSG_SYS_ACCEPT_ALT_SIZE /* 234 */ + \
2094 MSG_SYS_CONNECT_ALT_SIZE /* 235 */ + \
2095 MSG_SYS_SHUTDOWN_ALT_SIZE /* 236 */ + \
2096 MSG_SYS_RECV_ALT_SIZE /* 237 */ + \
2097 MSG_SYS_RECVFROM_ALT_SIZE /* 238 */ + \
2098 MSG_SYS_RECVMSG_ALT_SIZE /* 239 */ + \
2099 MSG_SYS_SEND_ALT_SIZE /* 240 */ + \
2100 MSG_SYS_SENDMSG_ALT_SIZE /* 241 */ + \
2101 MSG_SYS_SENDTO_ALT_SIZE /* 242 */ + \
2102 MSG_SYS_GETPEERNAME_ALT_SIZE /* 243 */ + \
2103 MSG_SYS_GETSOCKNAME_ALT_SIZE /* 244 */ + \
2104 MSG_SYS_GETSOCKOPT_ALT_SIZE /* 245 */ + \
2105 MSG_SYS_SETSOCKOPT_ALT_SIZE /* 246 */ + \
2106 MSG_SYS_SOCKCONFIG_ALT_SIZE /* 247 */ + \
2107 MSG_SYS_NTP_GETTIME_ALT_SIZE /* 248 */ + \
2108 MSG_SYS_NTP_ADJTIME_ALT_SIZE /* 249 */ + \
2109 MSG_SYS_LWP_MUTEX_UNLOCK_ALT_SIZE /* 250 */ + \
2110 MSG_SYS_LWP_MUTEX_TRYLOCK_ALT_SIZE /* 251 */ + \
2111 MSG_SYS_LWP_MUTEX_REGISTER_ALT_SIZE /* 252 */ + \
2112 MSG_SYS_CLADM_ALT_SIZE /* 253 */ + \
2113 MSG_SYS_UUCOPY_ALT_SIZE /* 254 */ + \
2114 MSG_SYS_UMOUNT2_ALT_SIZE /* 255 */ + \
2115 3 /* 256 (unused) */ + \
2116 \
2117 /* sysset_t[8] - System Calls [257 - 288] */ \
2118 (32 * 3) /* 257 - 288 (unused) */ + \
2119 \
2120 /* sysset_t[9] - System Calls [289 - 320] */ \
2121 (32 * 3) /* 289 - 320 (unused) */ + \
2122 \
2123 /* sysset_t[10] - System Calls [321 - 352] */ \
2124 (32 * 3) /* 321 - 352 (unused) */ + \
2125 \
2126 /* sysset_t[11] - System Calls [353 - 384] */ \
2127 (32 * 3) /* 353 - 384 (unused) */ + \
2128 \
2129 /* sysset_t[12] - System Calls [385 - 416] */ \
2130 (32 * 3) /* 385 - 416 (unused) */ + \
2131 \
2132 /* sysset_t[13] - System Calls [417 - 448] */ \
2133 (32 * 3) /* 417 - 448 (unused) */ + \
2134 \
2135 /* sysset_t[14] - System Calls [449 - 480] */ \
2136 (32 * 3) /* 449 - 480 (unused) */ + \
2137 \
2138 /* sysset_t[15] - System Calls [481 - 512] */ \
2139 (32 * 3) /* 481 - 512 (unused) */ + \
2140 \
2141 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
2142
2143 /*
2144 * Ensure that Conv_cnote_sysset_buf_t is large enough:
2145 *
2146 * SYSSET_FLAGSZ is the real minimum size of the buffer required by
2147 * conv_cnote_sysset(). However, Conv_cnote_sysset_buf_t
2148 * uses CONV_CNOTE_SYSSET_BUFSIZE to set the buffer size. We do
2149 * things this way because the definition of SYSSET_FLAGSZ uses information
2150 * that is not available in the environment of other programs
2151 * that include the conv.h header file.
2152 */
2153 #if (CONV_CNOTE_SYSSET_BUFSIZE != SYSSET_FLAGSZ) && !defined(__lint)
2154 #define REPORT_BUFSIZE SYSSET_FLAGSZ
2155 #include "report_bufsize.h"
2156 #error "CONV_CNOTE_SYSSET_BUFSIZE does not match SYSSET_FLAGSZ"
2157 #endif
2158
2159 const char *
conv_cnote_sysset(uint32_t * maskarr,int n_mask,Conv_fmt_flags_t fmt_flags,Conv_cnote_sysset_buf_t * cnote_sysset_buf)2160 conv_cnote_sysset(uint32_t *maskarr, int n_mask,
2161 Conv_fmt_flags_t fmt_flags, Conv_cnote_sysset_buf_t *cnote_sysset_buf)
2162 {
2163 #define N_MASK 16
2164
2165 static const Val_desc vda0[] = { /* System Calls [1 - 32] */
2166 { 0x00000001, MSG_SYS_EXIT_ALT },
2167 { 0x00000002, MSG_SYS_2 },
2168 { 0x00000004, MSG_SYS_READ_ALT },
2169 { 0x00000008, MSG_SYS_WRITE_ALT },
2170 { 0x00000010, MSG_SYS_OPEN_ALT },
2171 { 0x00000020, MSG_SYS_CLOSE_ALT },
2172 { 0x00000040, MSG_SYS_7 },
2173 { 0x00000080, MSG_SYS_8 },
2174 { 0x00000100, MSG_SYS_LINK_ALT },
2175 { 0x00000200, MSG_SYS_UNLINK_ALT },
2176 { 0x00000400, MSG_SYS_11 },
2177 { 0x00000800, MSG_SYS_CHDIR_ALT },
2178 { 0x00001000, MSG_SYS_TIME_ALT },
2179 { 0x00002000, MSG_SYS_MKNOD_ALT },
2180 { 0x00004000, MSG_SYS_CHMOD_ALT },
2181 { 0x00008000, MSG_SYS_CHOWN_ALT },
2182 { 0x00010000, MSG_SYS_BRK_ALT },
2183 { 0x00020000, MSG_SYS_STAT_ALT },
2184 { 0x00040000, MSG_SYS_LSEEK_ALT },
2185 { 0x00080000, MSG_SYS_GETPID_ALT },
2186 { 0x00100000, MSG_SYS_MOUNT_ALT },
2187 { 0x00200000, MSG_SYS_22 },
2188 { 0x00400000, MSG_SYS_SETUID_ALT },
2189 { 0x00800000, MSG_SYS_GETUID_ALT },
2190 { 0x01000000, MSG_SYS_STIME_ALT },
2191 { 0x02000000, MSG_SYS_PCSAMPLE_ALT },
2192 { 0x04000000, MSG_SYS_ALARM_ALT },
2193 { 0x08000000, MSG_SYS_FSTAT_ALT },
2194 { 0x10000000, MSG_SYS_PAUSE_ALT },
2195 { 0x20000000, MSG_SYS_30 },
2196 { 0x40000000, MSG_SYS_STTY_ALT },
2197 { 0x80000000, MSG_SYS_GTTY_ALT },
2198 { 0, 0 }
2199 };
2200 static const Val_desc vda1[] = { /* System Calls [33 - 64] */
2201 { 0x00000001, MSG_SYS_ACCESS_ALT },
2202 { 0x00000002, MSG_SYS_NICE_ALT },
2203 { 0x00000004, MSG_SYS_STATFS_ALT },
2204 { 0x00000008, MSG_SYS_SYNC_ALT },
2205 { 0x00000010, MSG_SYS_KILL_ALT },
2206 { 0x00000020, MSG_SYS_FSTATFS_ALT },
2207 { 0x00000040, MSG_SYS_PGRPSYS_ALT },
2208 { 0x00000080, MSG_SYS_UUCOPYSTR_ALT },
2209 { 0x00000100, MSG_SYS_41 },
2210 { 0x00000200, MSG_SYS_PIPE_ALT },
2211 { 0x00000400, MSG_SYS_TIMES_ALT },
2212 { 0x00000800, MSG_SYS_PROFIL_ALT },
2213 { 0x00001000, MSG_SYS_FACCESSAT_ALT },
2214 { 0x00002000, MSG_SYS_SETGID_ALT },
2215 { 0x00004000, MSG_SYS_GETGID_ALT },
2216 { 0x00008000, MSG_SYS_48 },
2217 { 0x00010000, MSG_SYS_MSGSYS_ALT },
2218 { 0x00020000, MSG_SYS_SYSI86_ALT },
2219 { 0x00040000, MSG_SYS_ACCT_ALT },
2220 { 0x00080000, MSG_SYS_SHMSYS_ALT },
2221 { 0x00100000, MSG_SYS_SEMSYS_ALT },
2222 { 0x00200000, MSG_SYS_IOCTL_ALT },
2223 { 0x00400000, MSG_SYS_UADMIN_ALT },
2224 { 0x00800000, MSG_SYS_FCHOWNAT_ALT },
2225 { 0x01000000, MSG_SYS_UTSSYS_ALT },
2226 { 0x0200000, MSG_SYS_FDSYNC_ALT },
2227 { 0x04000000, MSG_SYS_EXECVE_ALT },
2228 { 0x08000000, MSG_SYS_UMASK_ALT },
2229 { 0x10000000, MSG_SYS_CHROOT_ALT },
2230 { 0x20000000, MSG_SYS_FCNTL_ALT },
2231 { 0x40000000, MSG_SYS_ULIMIT_ALT },
2232 { 0x80000000, MSG_SYS_RENAMEAT_ALT },
2233 { 0, 0 }
2234 };
2235 static const Val_desc vda2[] = { /* System Calls [65 - 96] */
2236 { 0x00000001, MSG_SYS_UNLINKAT_ALT },
2237 { 0x00000002, MSG_SYS_FSTATAT_ALT },
2238 { 0x00000004, MSG_SYS_FSTATAT64_ALT },
2239 { 0x00000008, MSG_SYS_OPENAT_ALT },
2240 { 0x00000010, MSG_SYS_OPENAT64_ALT },
2241 { 0x00000020, MSG_SYS_TASKSYS_ALT },
2242 { 0x00000040, MSG_SYS_ACCTCTL_ALT },
2243 { 0x00000080, MSG_SYS_EXACCTSYS_ALT },
2244 { 0x00000100, MSG_SYS_GETPAGESIZES_ALT },
2245 { 0x00000200, MSG_SYS_RCTLSYS_ALT },
2246 { 0x00000400, MSG_SYS_SIDSYS_ALT },
2247 { 0x00000800, MSG_SYS_76 },
2248 { 0x00001000, MSG_SYS_LWP_PARK_ALT },
2249 { 0x00002000, MSG_SYS_SENDFILEV_ALT },
2250 { 0x00004000, MSG_SYS_RMDIR_ALT },
2251 { 0x00008000, MSG_SYS_MKDIR_ALT },
2252 { 0x00010000, MSG_SYS_GETDENTS_ALT },
2253 { 0x00020000, MSG_SYS_PRIVSYS_ALT },
2254 { 0x00040000, MSG_SYS_UCREDSYS_ALT },
2255 { 0x00080000, MSG_SYS_SYSFS_ALT },
2256 { 0x00100000, MSG_SYS_GETMSG_ALT },
2257 { 0x00200000, MSG_SYS_PUTMSG_ALT },
2258 { 0x00400000, MSG_SYS_87 },
2259 { 0x00800000, MSG_SYS_LSTAT_ALT },
2260 { 0x01000000, MSG_SYS_SYMLINK_ALT },
2261 { 0x02000000, MSG_SYS_READLINK_ALT },
2262 { 0x04000000, MSG_SYS_SETGROUPS_ALT },
2263 { 0x08000000, MSG_SYS_GETGROUPS_ALT },
2264 { 0x10000000, MSG_SYS_FCHMOD_ALT },
2265 { 0x20000000, MSG_SYS_FCHOWN_ALT },
2266 { 0x40000000, MSG_SYS_SIGPROCMASK_ALT },
2267 { 0x80000000, MSG_SYS_SIGSUSPEND_ALT },
2268 { 0, 0 }
2269 };
2270 static const Val_desc vda3[] = { /* System Calls [97 - 128] */
2271 { 0x00000001, MSG_SYS_SIGALTSTACK_ALT },
2272 { 0x00000002, MSG_SYS_SIGACTION_ALT },
2273 { 0x00000004, MSG_SYS_SIGPENDING_ALT },
2274 { 0x00000008, MSG_SYS_CONTEXT_ALT },
2275 { 0x00000010, MSG_SYS_101 },
2276 { 0x00000020, MSG_SYS_102 },
2277 { 0x00000040, MSG_SYS_STATVFS_ALT },
2278 { 0x00000080, MSG_SYS_FSTATVFS_ALT },
2279 { 0x00000100, MSG_SYS_GETLOADAVG_ALT },
2280 { 0x00000200, MSG_SYS_NFSSYS_ALT },
2281 { 0x00000400, MSG_SYS_WAITID_ALT },
2282 { 0x00000800, MSG_SYS_SIGSENDSYS_ALT },
2283 { 0x00001000, MSG_SYS_HRTSYS_ALT },
2284 { 0x00002000, MSG_SYS_UTIMESYS_ALT },
2285 { 0x00004000, MSG_SYS_SIGRESEND_ALT },
2286 { 0x00008000, MSG_SYS_PRIOCNTLSYS_ALT },
2287 { 0x00010000, MSG_SYS_PATHCONF_ALT },
2288 { 0x00020000, MSG_SYS_MINCORE_ALT },
2289 { 0x00040000, MSG_SYS_MMAP_ALT },
2290 { 0x00080000, MSG_SYS_MPROTECT_ALT },
2291 { 0x00100000, MSG_SYS_MUNMAP_ALT },
2292 { 0x00200000, MSG_SYS_FPATHCONF_ALT },
2293 { 0x00400000, MSG_SYS_VFORK_ALT },
2294 { 0x00800000, MSG_SYS_FCHDIR_ALT },
2295 { 0x01000000, MSG_SYS_READV_ALT },
2296 { 0x02000000, MSG_SYS_WRITEV_ALT },
2297 { 0x04000000, MSG_SYS_PREADV_ALT },
2298 { 0x08000000, MSG_SYS_PWRITEV_ALT },
2299 { 0x10000000, MSG_SYS_UPANIC_ALT },
2300 { 0x20000000, MSG_SYS_GETRANDOM_ALT },
2301 { 0x40000000, MSG_SYS_MMAPOBJ_ALT },
2302 { 0x80000000, MSG_SYS_SETRLIMIT_ALT },
2303 { 0, 0 }
2304 };
2305 static const Val_desc vda4[] = { /* System Calls [129 - 160] */
2306 { 0x00000001, MSG_SYS_GETRLIMIT_ALT },
2307 { 0x00000002, MSG_SYS_LCHOWN_ALT },
2308 { 0x00000004, MSG_SYS_MEMCNTL_ALT },
2309 { 0x00000008, MSG_SYS_GETPMSG_ALT },
2310 { 0x00000010, MSG_SYS_PUTPMSG_ALT },
2311 { 0x00000020, MSG_SYS_RENAME_ALT },
2312 { 0x00000040, MSG_SYS_UNAME_ALT },
2313 { 0x00000080, MSG_SYS_SETEGID_ALT },
2314 { 0x00000100, MSG_SYS_SYSCONFIG_ALT },
2315 { 0x00000200, MSG_SYS_ADJTIME_ALT },
2316 { 0x00000400, MSG_SYS_SYSTEMINFO_ALT },
2317 { 0x00000800, MSG_SYS_SHAREFS_ALT },
2318 { 0x00001000, MSG_SYS_SETEUID_ALT },
2319 { 0x00002000, MSG_SYS_FORKSYS_ALT },
2320 { 0x00004000, MSG_SYS_143 },
2321 { 0x00008000, MSG_SYS_SIGTIMEDWAIT_ALT },
2322 { 0x00010000, MSG_SYS_LWP_INFO_ALT },
2323 { 0x00020000, MSG_SYS_YIELD_ALT },
2324 { 0x00040000, MSG_SYS_147 },
2325 { 0x00080000, MSG_SYS_LWP_SEMA_POST_ALT },
2326 { 0x00100000, MSG_SYS_LWP_SEMA_TRYWAIT_ALT },
2327 { 0x00200000, MSG_SYS_LWP_DETACH_ALT },
2328 { 0x00400000, MSG_SYS_CORECTL_ALT },
2329 { 0x00800000, MSG_SYS_MODCTL_ALT },
2330 { 0x01000000, MSG_SYS_FCHROOT_ALT },
2331 { 0x02000000, MSG_SYS_154 },
2332 { 0x04000000, MSG_SYS_VHANGUP_ALT },
2333 { 0x08000000, MSG_SYS_GETTIMEOFDAY_ALT },
2334 { 0x10000000, MSG_SYS_GETITIMER_ALT },
2335 { 0x20000000, MSG_SYS_SETITIMER_ALT },
2336 { 0x40000000, MSG_SYS_LWP_CREATE_ALT },
2337 { 0x80000000, MSG_SYS_LWP_EXIT_ALT },
2338 { 0, 0 }
2339 };
2340 static const Val_desc vda5[] = { /* System Calls [161 - 192] */
2341 { 0x00000001, MSG_SYS_LWP_SUSPEND_ALT },
2342 { 0x00000002, MSG_SYS_LWP_CONTINUE_ALT },
2343 { 0x00000004, MSG_SYS_LWP_KILL_ALT },
2344 { 0x00000008, MSG_SYS_LWP_SELF_ALT },
2345 { 0x00000010, MSG_SYS_LWP_SIGMASK_ALT },
2346 { 0x00000020, MSG_SYS_LWP_PRIVATE_ALT },
2347 { 0x00000040, MSG_SYS_LWP_WAIT_ALT },
2348 { 0x00000080, MSG_SYS_LWP_MUTEX_WAKEUP_ALT },
2349 { 0x00000100, MSG_SYS_169 },
2350 { 0x00000200, MSG_SYS_LWP_COND_WAIT_ALT },
2351 { 0x00000400, MSG_SYS_LWP_COND_SIGNAL_ALT },
2352 { 0x00000800, MSG_SYS_LWP_COND_BROADCAST_ALT },
2353 { 0x00001000, MSG_SYS_PREAD_ALT },
2354 { 0x00002000, MSG_SYS_PWRITE_ALT },
2355 { 0x00004000, MSG_SYS_LLSEEK_ALT },
2356 { 0x00008000, MSG_SYS_INST_SYNC_ALT },
2357 { 0x00010000, MSG_SYS_BRAND_ALT },
2358 { 0x00020000, MSG_SYS_KAIO_ALT },
2359 { 0x00040000, MSG_SYS_CPC_ALT },
2360 { 0x00080000, MSG_SYS_LGRPSYS_ALT },
2361 { 0x00100000, MSG_SYS_RUSAGESYS_ALT },
2362 { 0x00200000, MSG_SYS_PORT_ALT },
2363 { 0x00400000, MSG_SYS_POLLSYS_ALT },
2364 { 0x00800000, MSG_SYS_LABELSYS_ALT },
2365 { 0x01000000, MSG_SYS_ACL_ALT },
2366 { 0x02000000, MSG_SYS_AUDITSYS_ALT },
2367 { 0x04000000, MSG_SYS_PROCESSOR_BIND_ALT },
2368 { 0x08000000, MSG_SYS_PROCESSOR_INFO_ALT },
2369 { 0x10000000, MSG_SYS_P_ONLINE_ALT },
2370 { 0x20000000, MSG_SYS_SIGQUEUE_ALT },
2371 { 0x40000000, MSG_SYS_CLOCK_GETTIME_ALT },
2372 { 0x80000000, MSG_SYS_CLOCK_SETTIME_ALT },
2373 { 0, 0 }
2374 };
2375 static const Val_desc vda6[] = { /* System Calls [193 - 224] */
2376 { 0x00000001, MSG_SYS_CLOCK_GETRES_ALT },
2377 { 0x00000002, MSG_SYS_TIMER_CREATE_ALT },
2378 { 0x00000004, MSG_SYS_TIMER_DELETE_ALT },
2379 { 0x00000008, MSG_SYS_TIMER_SETTIME_ALT },
2380 { 0x00000010, MSG_SYS_TIMER_GETTIME_ALT },
2381 { 0x00000020, MSG_SYS_TIMER_GETOVERRUN_ALT },
2382 { 0x00000040, MSG_SYS_NANOSLEEP_ALT },
2383 { 0x00000080, MSG_SYS_FACL_ALT },
2384 { 0x00000100, MSG_SYS_DOOR_ALT },
2385 { 0x00000200, MSG_SYS_SETREUID_ALT },
2386 { 0x00000400, MSG_SYS_SETREGID_ALT },
2387 { 0x00000800, MSG_SYS_INSTALL_UTRAP_ALT },
2388 { 0x00001000, MSG_SYS_SIGNOTIFY_ALT },
2389 { 0x00002000, MSG_SYS_SCHEDCTL_ALT },
2390 { 0x00004000, MSG_SYS_PSET_ALT },
2391 { 0x00008000, MSG_SYS_SPARC_UTRAP_INSTALL_ALT },
2392 { 0x00010000, MSG_SYS_RESOLVEPATH_ALT },
2393 { 0x00020000, MSG_SYS_LWP_MUTEX_TIMEDLOCK_ALT },
2394 { 0x00040000, MSG_SYS_LWP_SEMA_TIMEDWAIT_ALT },
2395 { 0x00080000, MSG_SYS_LWP_RWLOCK_SYS_ALT },
2396 { 0x00100000, MSG_SYS_GETDENTS64_ALT },
2397 { 0x00200000, MSG_SYS_MMAP64_ALT },
2398 { 0x00400000, MSG_SYS_STAT64_ALT },
2399 { 0x00800000, MSG_SYS_LSTAT64_ALT },
2400 { 0x01000000, MSG_SYS_FSTAT64_ALT },
2401 { 0x02000000, MSG_SYS_STATVFS64_ALT },
2402 { 0x04000000, MSG_SYS_FSTATVFS64_ALT },
2403 { 0x08000000, MSG_SYS_SETRLIMIT64_ALT },
2404 { 0x10000000, MSG_SYS_GETRLIMIT64_ALT },
2405 { 0x20000000, MSG_SYS_PREAD64_ALT },
2406 { 0x40000000, MSG_SYS_PWRITE64_ALT },
2407 { 0x80000000, MSG_SYS_224 },
2408 { 0, 0 }
2409 };
2410 static const Val_desc vda7[] = { /* System Calls [225 - 256] */
2411 { 0x00000001, MSG_SYS_OPEN64_ALT },
2412 { 0x00000002, MSG_SYS_RPCSYS_ALT },
2413 { 0x00000004, MSG_SYS_ZONE_ALT },
2414 { 0x00000008, MSG_SYS_AUTOFSSYS_ALT },
2415 { 0x00000010, MSG_SYS_GETCWD_ALT },
2416 { 0x00000020, MSG_SYS_SO_SOCKET_ALT },
2417 { 0x00000040, MSG_SYS_SO_SOCKETPAIR_ALT },
2418 { 0x00000080, MSG_SYS_BIND_ALT },
2419 { 0x00000100, MSG_SYS_LISTEN_ALT },
2420 { 0x00000200, MSG_SYS_ACCEPT_ALT },
2421 { 0x00000400, MSG_SYS_CONNECT_ALT },
2422 { 0x00000800, MSG_SYS_SHUTDOWN_ALT },
2423 { 0x00001000, MSG_SYS_RECV_ALT },
2424 { 0x00002000, MSG_SYS_RECVFROM_ALT },
2425 { 0x00004000, MSG_SYS_RECVMSG_ALT },
2426 { 0x00008000, MSG_SYS_SEND_ALT },
2427 { 0x00010000, MSG_SYS_SENDMSG_ALT },
2428 { 0x00020000, MSG_SYS_SENDTO_ALT },
2429 { 0x00040000, MSG_SYS_GETPEERNAME_ALT },
2430 { 0x00080000, MSG_SYS_GETSOCKNAME_ALT },
2431 { 0x00100000, MSG_SYS_GETSOCKOPT_ALT },
2432 { 0x00200000, MSG_SYS_SETSOCKOPT_ALT },
2433 { 0x00400000, MSG_SYS_SOCKCONFIG_ALT },
2434 { 0x00800000, MSG_SYS_NTP_GETTIME_ALT },
2435 { 0x01000000, MSG_SYS_NTP_ADJTIME_ALT },
2436 { 0x02000000, MSG_SYS_LWP_MUTEX_UNLOCK_ALT },
2437 { 0x04000000, MSG_SYS_LWP_MUTEX_TRYLOCK_ALT },
2438 { 0x08000000, MSG_SYS_LWP_MUTEX_REGISTER_ALT },
2439 { 0x10000000, MSG_SYS_CLADM_ALT },
2440 { 0x20000000, MSG_SYS_UUCOPY_ALT },
2441 { 0x40000000, MSG_SYS_UMOUNT2_ALT },
2442 /* 256 (unused) */
2443 { 0, 0 }
2444 };
2445 static const conv_bitmaskset_desc_t bitmask_desc[N_MASK] = {
2446 { vda0, 0x00000000 },
2447 { vda1, 0x00000000 },
2448 { vda2, 0x00000000 },
2449 { vda3, 0x00000000 },
2450 { vda4, 0x00000000 },
2451 { vda5, 0x00000000 },
2452 { vda6, 0x00000000 },
2453 { vda7, 0x80000000 },
2454 { NULL, 0xffffffff },
2455 { NULL, 0xffffffff },
2456 { NULL, 0xffffffff },
2457 { NULL, 0xffffffff },
2458 { NULL, 0xffffffff },
2459 { NULL, 0xffffffff },
2460 { NULL, 0xffffffff },
2461 { NULL, 0xffffffff }
2462 };
2463
2464 if (n_mask > N_MASK)
2465 n_mask = N_MASK;
2466 return (conv_bitmaskset(maskarr, n_mask, bitmask_desc, fmt_flags,
2467 cnote_sysset_buf->buf, CONV_CNOTE_SYSSET_BUFSIZE));
2468
2469 #undef N_MASK
2470 }
2471
2472 const char *
conv_cnote_fileflags(uint32_t fileflags,Conv_fmt_flags_t fmt_flags,char * buf,size_t bufsize)2473 conv_cnote_fileflags(uint32_t fileflags, Conv_fmt_flags_t fmt_flags,
2474 char *buf, size_t bufsize)
2475 {
2476 CONV_EXPN_FIELD_ARG arg = { 0 };
2477
2478 Val_desc vda[] = {
2479 { 0x0001, MSG_PR_O_WRONLY },
2480 { 0x0002, MSG_PR_O_RDONLY },
2481 { 0x200000, MSG_PR_O_SEARCH },
2482 { 0x400000, MSG_PR_O_EXEC },
2483 { 0x0004, MSG_PR_O_NDELAY },
2484 { 0x0008, MSG_PR_O_APPEND },
2485 { 0x0010, MSG_PR_O_SYNC },
2486 { 0x0040, MSG_PR_O_DSYNC },
2487 { 0x0080, MSG_PR_O_NONBLOCK },
2488 { 0x0100, MSG_PR_O_CREAT },
2489 { 0x0200, MSG_PR_O_TRUNC },
2490 { 0x0400, MSG_PR_O_EXCL },
2491 { 0x0800, MSG_PR_O_NOCTTY },
2492 { 0x4000, MSG_PR_O_XATTR },
2493 { 0x8000, MSG_PR_O_RSYNC },
2494 { 0x2000, MSG_PR_O_LARGEFILE },
2495 { 0x20000, MSG_PR_O_NOFOLLOW },
2496 { 0x40000, MSG_PR_O_NOLINKS },
2497 { 0, 0 },
2498 };
2499
2500 arg.oflags = arg.rflags = fileflags;
2501 arg.buf = buf;
2502 arg.bufsize = bufsize;
2503
2504 switch (fileflags & (0x600003)) {
2505 case 0: /* RDONLY */
2506 vda[0].v_msg = MSG_PR_O_RDONLY;
2507 arg.oflags |= 1;
2508 arg.rflags |= 1;
2509 break;
2510 case 1: /* WRONLY */
2511 case 2: /* RDWR */
2512 case 0x200000: /* SEARCH */
2513 case 0x400000:
2514 /* In isolate, treat these as normal bits */
2515 break;
2516 default:
2517 /* More than one bit set in this group, emit numerically */
2518 arg.oflags &= ~(fileflags & 0x600003);
2519 }
2520
2521 if (fileflags == 0)
2522 return (MSG_ORIG(MSG_GBL_ZERO));
2523
2524 (void) conv_expn_field(&arg, vda, fmt_flags);
2525 return (buf);
2526 }
2527
2528 const char *
conv_cnote_filemode(uint32_t mode,Conv_fmt_flags_t fmt_flags,char * buf,size_t bufsize)2529 conv_cnote_filemode(uint32_t mode, Conv_fmt_flags_t fmt_flags,
2530 char *buf, size_t bufsize)
2531 {
2532 CONV_EXPN_FIELD_ARG arg = { 0 };
2533 Msg s;
2534
2535 Val_desc vda[] = {
2536 { 0x1000, MSG_S_IFIFO },
2537 { 0x800, MSG_S_ISUID },
2538 { 0x400, MSG_S_ISGID },
2539 { 0x200, MSG_S_ISVTX },
2540 { 0400, MSG_S_IRUSR },
2541 { 0200, MSG_S_IWUSR },
2542 { 0100, MSG_S_IXUSR },
2543 { 0040, MSG_S_IRGRP },
2544 { 0020, MSG_S_IWGRP },
2545 { 0010, MSG_S_IXGRP },
2546 { 0004, MSG_S_IROTH },
2547 { 0002, MSG_S_IWOTH },
2548 { 0001, MSG_S_IXOTH },
2549 { 0, 0 },
2550 };
2551
2552 arg.oflags = arg.rflags = mode & ~(0xf000);
2553 arg.buf = buf;
2554 arg.bufsize = bufsize;
2555
2556 switch (mode & (0xf000)) {
2557 case 0x1000:
2558 s = MSG_S_IFIFO;
2559 break;
2560 case 0x2000:
2561 s = MSG_S_IFCHR;
2562 break;
2563 case 0x4000:
2564 s = MSG_S_IFDIR;
2565 break;
2566 case 0x5000:
2567 s = MSG_S_IFNAM;
2568 break;
2569 case 0x6000:
2570 s = MSG_S_IFBLK;
2571 break;
2572 case 0x8000:
2573 s = MSG_S_IFREG;
2574 break;
2575 case 0xA000:
2576 s = MSG_S_IFLNK;
2577 break;
2578 case 0xc000:
2579 s = MSG_S_IFSOCK;
2580 break;
2581 case 0xd000:
2582 s = MSG_S_IFDOOR;
2583 break;
2584 case 0xe000:
2585 s = MSG_S_IFPORT;
2586 break;
2587 default:
2588 s = 0;
2589 break;
2590 }
2591
2592 if (s) {
2593 arg.oflags |= 0x1000;
2594 arg.rflags |= 0x1000;
2595 vda[0].v_msg = s;
2596 } else {
2597 arg.rflags = mode;
2598 }
2599
2600 if (mode == 0)
2601 return (MSG_ORIG(MSG_GBL_ZERO));
2602
2603 (void) conv_expn_field(&arg, vda, fmt_flags);
2604 return (buf);
2605 }
2606
2607
2608 #define PROCSECFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
2609 MSG_ASLR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2610 MSG_FORBIDNULLMAP_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2611 MSG_NOEXECSTACK_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2612 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
2613
2614 /*
2615 * Ensure that Conv_cnote_pr_secflags_buf_t is large enough:
2616 *
2617 * PROCSECFLGSZ is the real minimum size of the buffer required by
2618 * conv_prsecflags(). However, Conv_cnote_pr_secflags_buf_t uses
2619 * CONV_CNOTE_PSECFLAGS_FLAG_BUFSIZE to set the buffer size. We do things this
2620 * way because the definition of PROCSECFLGSZ uses information that is not
2621 * available in the environment of other programs that include the conv.h
2622 * header file.
2623 */
2624 #if (CONV_PRSECFLAGS_BUFSIZE != PROCSECFLGSZ) && !defined(__lint)
2625 #define REPORT_BUFSIZE PROCSECFLGSZ
2626 #include "report_bufsize.h"
2627 #error "CONV_PRSECFLAGS_BUFSIZE does not match PROCSECFLGSZ"
2628 #endif
2629
2630 const char *
conv_prsecflags(secflagset_t flags,Conv_fmt_flags_t fmt_flags,Conv_secflags_buf_t * secflags_buf)2631 conv_prsecflags(secflagset_t flags, Conv_fmt_flags_t fmt_flags,
2632 Conv_secflags_buf_t *secflags_buf)
2633 {
2634 /*
2635 * The values are initialized later, based on position in this array
2636 */
2637 static Val_desc vda[] = {
2638 { 0, MSG_ASLR },
2639 { 0, MSG_FORBIDNULLMAP },
2640 { 0, MSG_NOEXECSTACK },
2641 { 0, 0 }
2642 };
2643 static CONV_EXPN_FIELD_ARG conv_arg = {
2644 NULL, sizeof (secflags_buf->buf)
2645 };
2646 int i;
2647
2648 for (i = 0; vda[i].v_msg != 0; i++)
2649 vda[i].v_val = secflag_to_bit(i);
2650
2651 if (flags == 0)
2652 return (MSG_ORIG(MSG_GBL_ZERO));
2653
2654 conv_arg.buf = secflags_buf->buf;
2655 conv_arg.oflags = conv_arg.rflags = flags;
2656 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
2657
2658 return ((const char *)secflags_buf->buf);
2659 }
2660
2661
2662 #define UPANICFLGSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
2663 MSG_MSG_VALID_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2664 MSG_MSG_ERROR_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2665 MSG_MSG_TRUNC_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
2666 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
2667
2668 /*
2669 * Ensure that Conv_upanic_buf_t is large enough:
2670 *
2671 * UPANICFLGSZ is the real minimum size of the buffer required by
2672 * conv_prsecflags(). However, Conv_upanic_buf_t uses CONV_PRUPANIC_BUFSIZE to
2673 * set the buffer size. We do things this way because the definition of
2674 * UPANICFLGSZ uses information that is not available in the environment of
2675 * other programs that include the conv.h header file.
2676 */
2677 #if (CONV_PRUPANIC_BUFSIZE != UPANICFLGSZ)
2678 #define REPORT_BUFSIZE UPANICFLGSZ
2679 #include "report_bufsize.h"
2680 #error "CONV_PRUPANIC_BUFSIZE does not match UPANICFLGSZ"
2681 #endif
2682
2683 const char *
conv_prupanic(uint32_t flags,Conv_fmt_flags_t fmt_flags,Conv_upanic_buf_t * upanic_buf)2684 conv_prupanic(uint32_t flags, Conv_fmt_flags_t fmt_flags,
2685 Conv_upanic_buf_t *upanic_buf)
2686 {
2687 /*
2688 * Unfortunately, we cannot directly use the PRUPANIC_FLAG_* macros here
2689 * because of the fact that this is also built natively and that would
2690 * create an unresolvable flag day.
2691 */
2692 static Val_desc vda[] = {
2693 { 0x01, MSG_MSG_VALID },
2694 { 0x02, MSG_MSG_ERROR },
2695 { 0x04, MSG_MSG_TRUNC },
2696 { 0, 0 }
2697 };
2698 static CONV_EXPN_FIELD_ARG conv_arg = {
2699 NULL, sizeof (upanic_buf->buf)
2700 };
2701
2702 if (flags == 0)
2703 return (MSG_ORIG(MSG_GBL_ZERO));
2704
2705 conv_arg.buf = upanic_buf->buf;
2706 conv_arg.oflags = conv_arg.rflags = flags;
2707 (void) conv_expn_field(&conv_arg, vda, fmt_flags);
2708
2709 return ((const char *)upanic_buf->buf);
2710 }
2711