10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
51548Srshoaib * Common Development and Distribution License (the "License").
61548Srshoaib * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
211548Srshoaib
220Sstevel@tonic-gate /*
2312643SAnders.Persson@Sun.COM * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <stdio.h>
270Sstevel@tonic-gate #include <stdlib.h>
280Sstevel@tonic-gate #include <unistd.h>
290Sstevel@tonic-gate #include <fcntl.h>
300Sstevel@tonic-gate #include <ctype.h>
310Sstevel@tonic-gate #include <string.h>
320Sstevel@tonic-gate #include <signal.h>
330Sstevel@tonic-gate #include <dirent.h>
340Sstevel@tonic-gate #include <limits.h>
350Sstevel@tonic-gate #include <door.h>
360Sstevel@tonic-gate #include <sys/types.h>
371095Spriyanka #include <sys/socket.h>
380Sstevel@tonic-gate #include <sys/stat.h>
390Sstevel@tonic-gate #include <sys/mkdev.h>
406583Smeem #include <sys/stropts.h>
416583Smeem #include <sys/timod.h>
420Sstevel@tonic-gate #include <sys/un.h>
430Sstevel@tonic-gate #include <libproc.h>
441095Spriyanka #include <netinet/in.h>
454987Sdanmcd #include <netinet/udp.h>
460Sstevel@tonic-gate #include <arpa/inet.h>
470Sstevel@tonic-gate
483507Svb160487 #define copyflock(dst, src) \
493507Svb160487 (dst).l_type = (src).l_type; \
503507Svb160487 (dst).l_whence = (src).l_whence; \
513507Svb160487 (dst).l_start = (src).l_start; \
523507Svb160487 (dst).l_len = (src).l_len; \
533507Svb160487 (dst).l_sysid = (src).l_sysid; \
543507Svb160487 (dst).l_pid = (src).l_pid;
553507Svb160487
560Sstevel@tonic-gate static char *command;
570Sstevel@tonic-gate static volatile int interrupt;
580Sstevel@tonic-gate static int Fflag;
590Sstevel@tonic-gate static boolean_t nflag = B_FALSE;
600Sstevel@tonic-gate
610Sstevel@tonic-gate static void intr(int);
620Sstevel@tonic-gate static void dofcntl(struct ps_prochandle *, int, int, int);
630Sstevel@tonic-gate static void dosocket(struct ps_prochandle *, int);
646583Smeem static void dotli(struct ps_prochandle *, int);
650Sstevel@tonic-gate static void show_files(struct ps_prochandle *);
660Sstevel@tonic-gate static void show_fileflags(int);
670Sstevel@tonic-gate static void show_door(struct ps_prochandle *, int);
683507Svb160487 static int getflock(struct ps_prochandle *, int, struct flock *);
690Sstevel@tonic-gate
700Sstevel@tonic-gate int
main(int argc,char ** argv)710Sstevel@tonic-gate main(int argc, char **argv)
720Sstevel@tonic-gate {
730Sstevel@tonic-gate int retc = 0;
740Sstevel@tonic-gate int opt;
750Sstevel@tonic-gate int errflg = 0;
760Sstevel@tonic-gate struct ps_prochandle *Pr;
770Sstevel@tonic-gate
780Sstevel@tonic-gate if ((command = strrchr(argv[0], '/')) != NULL)
790Sstevel@tonic-gate command++;
800Sstevel@tonic-gate else
810Sstevel@tonic-gate command = argv[0];
820Sstevel@tonic-gate
830Sstevel@tonic-gate /* options */
840Sstevel@tonic-gate while ((opt = getopt(argc, argv, "Fn")) != EOF) {
850Sstevel@tonic-gate switch (opt) {
860Sstevel@tonic-gate case 'F': /* force grabbing (no O_EXCL) */
870Sstevel@tonic-gate Fflag = PGRAB_FORCE;
880Sstevel@tonic-gate break;
890Sstevel@tonic-gate case 'n':
900Sstevel@tonic-gate nflag = B_TRUE;
910Sstevel@tonic-gate break;
920Sstevel@tonic-gate default:
930Sstevel@tonic-gate errflg = 1;
940Sstevel@tonic-gate break;
950Sstevel@tonic-gate }
960Sstevel@tonic-gate }
970Sstevel@tonic-gate
980Sstevel@tonic-gate argc -= optind;
990Sstevel@tonic-gate argv += optind;
1000Sstevel@tonic-gate
1010Sstevel@tonic-gate if (errflg || argc <= 0) {
1020Sstevel@tonic-gate (void) fprintf(stderr, "usage:\t%s [-F] pid ...\n",
1034987Sdanmcd command);
1040Sstevel@tonic-gate (void) fprintf(stderr,
1054987Sdanmcd " (report open files of each process)\n");
1060Sstevel@tonic-gate (void) fprintf(stderr,
1074987Sdanmcd " -F: force grabbing of the target process\n");
1080Sstevel@tonic-gate exit(2);
1090Sstevel@tonic-gate }
1100Sstevel@tonic-gate
1110Sstevel@tonic-gate /* catch signals from terminal */
1120Sstevel@tonic-gate if (sigset(SIGHUP, SIG_IGN) == SIG_DFL)
1130Sstevel@tonic-gate (void) sigset(SIGHUP, intr);
1140Sstevel@tonic-gate if (sigset(SIGINT, SIG_IGN) == SIG_DFL)
1150Sstevel@tonic-gate (void) sigset(SIGINT, intr);
1160Sstevel@tonic-gate if (sigset(SIGQUIT, SIG_IGN) == SIG_DFL)
1170Sstevel@tonic-gate (void) sigset(SIGQUIT, intr);
1180Sstevel@tonic-gate (void) sigset(SIGPIPE, intr);
1190Sstevel@tonic-gate (void) sigset(SIGTERM, intr);
1200Sstevel@tonic-gate
1210Sstevel@tonic-gate (void) proc_initstdio();
1220Sstevel@tonic-gate
1230Sstevel@tonic-gate
1240Sstevel@tonic-gate while (--argc >= 0 && !interrupt) {
1250Sstevel@tonic-gate char *arg;
1260Sstevel@tonic-gate psinfo_t psinfo;
1270Sstevel@tonic-gate pid_t pid;
1280Sstevel@tonic-gate int gret;
1290Sstevel@tonic-gate
1300Sstevel@tonic-gate (void) proc_flushstdio();
1310Sstevel@tonic-gate
1320Sstevel@tonic-gate /* get the specified pid and the psinfo struct */
1330Sstevel@tonic-gate if ((pid = proc_arg_psinfo(arg = *argv++, PR_ARG_PIDS,
1340Sstevel@tonic-gate &psinfo, &gret)) == -1) {
1350Sstevel@tonic-gate (void) fprintf(stderr, "%s: cannot examine %s: %s\n",
1364987Sdanmcd command, arg, Pgrab_error(gret));
1370Sstevel@tonic-gate retc++;
1380Sstevel@tonic-gate } else if ((Pr = Pgrab(pid, Fflag, &gret)) != NULL) {
1390Sstevel@tonic-gate if (Pcreate_agent(Pr) == 0) {
1400Sstevel@tonic-gate proc_unctrl_psinfo(&psinfo);
1410Sstevel@tonic-gate (void) printf("%d:\t%.70s\n",
1424987Sdanmcd (int)pid, psinfo.pr_psargs);
1430Sstevel@tonic-gate show_files(Pr);
1440Sstevel@tonic-gate Pdestroy_agent(Pr);
1450Sstevel@tonic-gate } else {
1460Sstevel@tonic-gate (void) fprintf(stderr,
1474987Sdanmcd "%s: cannot control process %d\n",
1484987Sdanmcd command, (int)pid);
1490Sstevel@tonic-gate retc++;
1500Sstevel@tonic-gate }
1510Sstevel@tonic-gate Prelease(Pr, 0);
1520Sstevel@tonic-gate Pr = NULL;
1530Sstevel@tonic-gate } else {
1540Sstevel@tonic-gate switch (gret) {
1550Sstevel@tonic-gate case G_SYS:
1560Sstevel@tonic-gate case G_SELF:
1570Sstevel@tonic-gate proc_unctrl_psinfo(&psinfo);
1580Sstevel@tonic-gate (void) printf("%d:\t%.70s\n", (int)pid,
1594987Sdanmcd psinfo.pr_psargs);
1600Sstevel@tonic-gate if (gret == G_SYS)
1610Sstevel@tonic-gate (void) printf(" [system process]\n");
1620Sstevel@tonic-gate else
1630Sstevel@tonic-gate show_files(NULL);
1640Sstevel@tonic-gate break;
1650Sstevel@tonic-gate default:
1660Sstevel@tonic-gate (void) fprintf(stderr, "%s: %s: %d\n",
1674987Sdanmcd command, Pgrab_error(gret), (int)pid);
1680Sstevel@tonic-gate retc++;
1690Sstevel@tonic-gate break;
1700Sstevel@tonic-gate }
1710Sstevel@tonic-gate }
1720Sstevel@tonic-gate }
1730Sstevel@tonic-gate
1740Sstevel@tonic-gate (void) proc_finistdio();
1750Sstevel@tonic-gate
1760Sstevel@tonic-gate if (interrupt && retc == 0)
1770Sstevel@tonic-gate retc++;
1780Sstevel@tonic-gate return (retc);
1790Sstevel@tonic-gate }
1800Sstevel@tonic-gate
1810Sstevel@tonic-gate /* ARGSUSED */
1820Sstevel@tonic-gate static void
intr(int sig)1830Sstevel@tonic-gate intr(int sig)
1840Sstevel@tonic-gate {
1850Sstevel@tonic-gate interrupt = 1;
1860Sstevel@tonic-gate }
1870Sstevel@tonic-gate
1880Sstevel@tonic-gate /* ------ begin specific code ------ */
1890Sstevel@tonic-gate
1900Sstevel@tonic-gate static void
show_files(struct ps_prochandle * Pr)1910Sstevel@tonic-gate show_files(struct ps_prochandle *Pr)
1920Sstevel@tonic-gate {
1930Sstevel@tonic-gate DIR *dirp;
1940Sstevel@tonic-gate struct dirent *dentp;
1956583Smeem const char *dev;
1960Sstevel@tonic-gate char pname[100];
1970Sstevel@tonic-gate char fname[PATH_MAX];
1980Sstevel@tonic-gate struct stat64 statb;
1990Sstevel@tonic-gate struct rlimit rlim;
2000Sstevel@tonic-gate pid_t pid;
2010Sstevel@tonic-gate int fd;
2020Sstevel@tonic-gate char *s;
2030Sstevel@tonic-gate int ret;
2040Sstevel@tonic-gate
2050Sstevel@tonic-gate if (pr_getrlimit(Pr, RLIMIT_NOFILE, &rlim) == 0) {
2060Sstevel@tonic-gate ulong_t nfd = rlim.rlim_cur;
2070Sstevel@tonic-gate if (nfd == RLIM_INFINITY)
2080Sstevel@tonic-gate (void) printf(
2090Sstevel@tonic-gate " Current rlimit: unlimited file descriptors\n");
2100Sstevel@tonic-gate else
2110Sstevel@tonic-gate (void) printf(
2120Sstevel@tonic-gate " Current rlimit: %lu file descriptors\n", nfd);
2130Sstevel@tonic-gate }
2140Sstevel@tonic-gate
2150Sstevel@tonic-gate /* in case we are doing this to ourself */
2160Sstevel@tonic-gate pid = (Pr == NULL)? getpid() : Pstatus(Pr)->pr_pid;
2170Sstevel@tonic-gate
2180Sstevel@tonic-gate (void) sprintf(pname, "/proc/%d/fd", (int)pid);
2190Sstevel@tonic-gate if ((dirp = opendir(pname)) == NULL) {
2200Sstevel@tonic-gate (void) fprintf(stderr, "%s: cannot open directory %s\n",
2210Sstevel@tonic-gate command, pname);
2220Sstevel@tonic-gate return;
2230Sstevel@tonic-gate }
2240Sstevel@tonic-gate
2250Sstevel@tonic-gate /* for each open file --- */
2260Sstevel@tonic-gate while ((dentp = readdir(dirp)) != NULL && !interrupt) {
2270Sstevel@tonic-gate char unknown[12];
2280Sstevel@tonic-gate dev_t rdev;
2290Sstevel@tonic-gate
2300Sstevel@tonic-gate /* skip '.' and '..' */
2310Sstevel@tonic-gate if (!isdigit(dentp->d_name[0]))
2320Sstevel@tonic-gate continue;
2330Sstevel@tonic-gate
2340Sstevel@tonic-gate fd = atoi(dentp->d_name);
2350Sstevel@tonic-gate if (pr_fstat64(Pr, fd, &statb) == -1) {
2360Sstevel@tonic-gate s = unknown;
2370Sstevel@tonic-gate (void) sprintf(s, "%4d", fd);
2380Sstevel@tonic-gate perror(s);
2390Sstevel@tonic-gate continue;
2400Sstevel@tonic-gate }
2410Sstevel@tonic-gate
2420Sstevel@tonic-gate rdev = NODEV;
2430Sstevel@tonic-gate switch (statb.st_mode & S_IFMT) {
2440Sstevel@tonic-gate case S_IFCHR: s = "S_IFCHR"; rdev = statb.st_rdev; break;
2450Sstevel@tonic-gate case S_IFBLK: s = "S_IFBLK"; rdev = statb.st_rdev; break;
2460Sstevel@tonic-gate case S_IFIFO: s = "S_IFIFO"; break;
2470Sstevel@tonic-gate case S_IFDIR: s = "S_IFDIR"; break;
2480Sstevel@tonic-gate case S_IFREG: s = "S_IFREG"; break;
2490Sstevel@tonic-gate case S_IFLNK: s = "S_IFLNK"; break;
2500Sstevel@tonic-gate case S_IFSOCK: s = "S_IFSOCK"; break;
2510Sstevel@tonic-gate case S_IFDOOR: s = "S_IFDOOR"; break;
2520Sstevel@tonic-gate case S_IFPORT: s = "S_IFPORT"; break;
2530Sstevel@tonic-gate default:
2540Sstevel@tonic-gate s = unknown;
2550Sstevel@tonic-gate (void) sprintf(s, "0x%.4x ",
2564987Sdanmcd (int)statb.st_mode & S_IFMT);
2570Sstevel@tonic-gate break;
2580Sstevel@tonic-gate }
2590Sstevel@tonic-gate
2604987Sdanmcd (void) printf("%4d: %s mode:0%.3o", fd, s,
2614987Sdanmcd (int)statb.st_mode & ~S_IFMT);
2620Sstevel@tonic-gate
2630Sstevel@tonic-gate if (major(statb.st_dev) != (major_t)NODEV &&
2640Sstevel@tonic-gate minor(statb.st_dev) != (minor_t)NODEV)
2650Sstevel@tonic-gate (void) printf(" dev:%lu,%lu",
2664987Sdanmcd (ulong_t)major(statb.st_dev),
2674987Sdanmcd (ulong_t)minor(statb.st_dev));
2680Sstevel@tonic-gate else
2690Sstevel@tonic-gate (void) printf(" dev:0x%.8lX", (long)statb.st_dev);
2700Sstevel@tonic-gate
2710Sstevel@tonic-gate if ((statb.st_mode & S_IFMT) == S_IFPORT) {
2720Sstevel@tonic-gate (void) printf(" uid:%d gid:%d",
2730Sstevel@tonic-gate (int)statb.st_uid,
2740Sstevel@tonic-gate (int)statb.st_gid);
2750Sstevel@tonic-gate (void) printf(" size:%lld\n",
2760Sstevel@tonic-gate (longlong_t)statb.st_size);
2770Sstevel@tonic-gate continue;
2780Sstevel@tonic-gate }
2790Sstevel@tonic-gate
2800Sstevel@tonic-gate (void) printf(" ino:%llu uid:%d gid:%d",
2814987Sdanmcd (u_longlong_t)statb.st_ino,
2824987Sdanmcd (int)statb.st_uid, (int)statb.st_gid);
2830Sstevel@tonic-gate
2840Sstevel@tonic-gate if (rdev == NODEV)
2850Sstevel@tonic-gate (void) printf(" size:%lld\n",
2864987Sdanmcd (longlong_t)statb.st_size);
2870Sstevel@tonic-gate else if (major(rdev) != (major_t)NODEV &&
2880Sstevel@tonic-gate minor(rdev) != (minor_t)NODEV)
2890Sstevel@tonic-gate (void) printf(" rdev:%lu,%lu\n",
2904987Sdanmcd (ulong_t)major(rdev), (ulong_t)minor(rdev));
2910Sstevel@tonic-gate else
2920Sstevel@tonic-gate (void) printf(" rdev:0x%.8lX\n", (long)rdev);
2930Sstevel@tonic-gate
2940Sstevel@tonic-gate if (!nflag) {
29511281SDan.Mick@Sun.COM off_t offset;
29611281SDan.Mick@Sun.COM
2970Sstevel@tonic-gate dofcntl(Pr, fd,
2984987Sdanmcd (statb.st_mode & (S_IFMT|S_ENFMT|S_IXGRP))
2994987Sdanmcd == (S_IFREG|S_ENFMT),
3004987Sdanmcd (statb.st_mode & S_IFMT) == S_IFDOOR);
3010Sstevel@tonic-gate
3020Sstevel@tonic-gate if ((statb.st_mode & S_IFMT) == S_IFSOCK)
3030Sstevel@tonic-gate dosocket(Pr, fd);
3040Sstevel@tonic-gate
3050Sstevel@tonic-gate (void) sprintf(pname, "/proc/%d/path/%d", (int)pid, fd);
3060Sstevel@tonic-gate
3076583Smeem if ((ret = readlink(pname, fname, PATH_MAX - 1)) <= 0)
3086583Smeem continue;
3096583Smeem
3106583Smeem fname[ret] = '\0';
3116583Smeem
3126583Smeem if ((statb.st_mode & S_IFMT) == S_IFCHR &&
3136583Smeem (dev = strrchr(fname, ':')) != NULL) {
3146583Smeem /*
3156583Smeem * There's no elegant way to determine if a
3166583Smeem * character device supports TLI, so we lame
3176583Smeem * out and just check a hardcoded list of
3186583Smeem * known TLI devices.
3196583Smeem */
3206583Smeem int i;
3216583Smeem const char *tlidevs[] =
3226583Smeem { "tcp", "tcp6", "udp", "udp6", NULL };
3236583Smeem
3246583Smeem dev++; /* skip past the `:' */
3256583Smeem for (i = 0; tlidevs[i] != NULL; i++) {
3266583Smeem if (strcmp(dev, tlidevs[i]) == 0) {
3276583Smeem dotli(Pr, fd);
3286583Smeem break;
3296583Smeem }
3306583Smeem }
3310Sstevel@tonic-gate }
3326583Smeem (void) printf(" %s\n", fname);
33311281SDan.Mick@Sun.COM
33411281SDan.Mick@Sun.COM offset = pr_lseek(Pr, fd, 0, SEEK_CUR);
33511281SDan.Mick@Sun.COM if (offset != -1) {
33611281SDan.Mick@Sun.COM (void) printf(" offset:%ld\n", offset);
33711281SDan.Mick@Sun.COM }
33811281SDan.Mick@Sun.COM
3390Sstevel@tonic-gate }
3400Sstevel@tonic-gate }
3410Sstevel@tonic-gate (void) closedir(dirp);
3420Sstevel@tonic-gate }
3430Sstevel@tonic-gate
3443507Svb160487
3453507Svb160487 static int
getflock(struct ps_prochandle * Pr,int fd,struct flock * flock_native)3463507Svb160487 getflock(struct ps_prochandle *Pr, int fd, struct flock *flock_native)
3473507Svb160487 {
3483507Svb160487 int ret;
3493507Svb160487 #ifdef _LP64
3503507Svb160487 struct flock64_32 flock_target;
3513507Svb160487
3523507Svb160487 if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) {
3533507Svb160487 copyflock(flock_target, *flock_native);
3543507Svb160487 ret = pr_fcntl(Pr, fd, F_GETLK, &flock_target);
3553507Svb160487 copyflock(*flock_native, flock_target);
3563507Svb160487 return (ret);
3573507Svb160487 }
3583507Svb160487 #endif /* _LP64 */
3593507Svb160487 ret = pr_fcntl(Pr, fd, F_GETLK, flock_native);
3603507Svb160487 return (ret);
3613507Svb160487 }
3623507Svb160487
3630Sstevel@tonic-gate /* examine open file with fcntl() */
3640Sstevel@tonic-gate static void
dofcntl(struct ps_prochandle * Pr,int fd,int mandatory,int isdoor)3654987Sdanmcd dofcntl(struct ps_prochandle *Pr, int fd, int mandatory, int isdoor)
3660Sstevel@tonic-gate {
3670Sstevel@tonic-gate struct flock flock;
3680Sstevel@tonic-gate int fileflags;
3690Sstevel@tonic-gate int fdflags;
3700Sstevel@tonic-gate
3710Sstevel@tonic-gate fileflags = pr_fcntl(Pr, fd, F_GETXFL, 0);
3720Sstevel@tonic-gate fdflags = pr_fcntl(Pr, fd, F_GETFD, 0);
3730Sstevel@tonic-gate
3740Sstevel@tonic-gate if (fileflags != -1 || fdflags != -1) {
3750Sstevel@tonic-gate (void) printf(" ");
3760Sstevel@tonic-gate if (fileflags != -1)
3770Sstevel@tonic-gate show_fileflags(fileflags);
3780Sstevel@tonic-gate if (fdflags != -1 && (fdflags & FD_CLOEXEC))
3790Sstevel@tonic-gate (void) printf(" FD_CLOEXEC");
3800Sstevel@tonic-gate if (isdoor)
3810Sstevel@tonic-gate show_door(Pr, fd);
3820Sstevel@tonic-gate (void) fputc('\n', stdout);
3830Sstevel@tonic-gate } else if (isdoor) {
3840Sstevel@tonic-gate (void) printf(" ");
3850Sstevel@tonic-gate show_door(Pr, fd);
3860Sstevel@tonic-gate (void) fputc('\n', stdout);
3870Sstevel@tonic-gate }
3880Sstevel@tonic-gate
3890Sstevel@tonic-gate flock.l_type = F_WRLCK;
3900Sstevel@tonic-gate flock.l_whence = 0;
3910Sstevel@tonic-gate flock.l_start = 0;
3920Sstevel@tonic-gate flock.l_len = 0;
3930Sstevel@tonic-gate flock.l_sysid = 0;
3940Sstevel@tonic-gate flock.l_pid = 0;
3953507Svb160487 if (getflock(Pr, fd, &flock) != -1) {
3960Sstevel@tonic-gate if (flock.l_type != F_UNLCK && (flock.l_sysid || flock.l_pid)) {
3970Sstevel@tonic-gate unsigned long sysid = flock.l_sysid;
3980Sstevel@tonic-gate
3990Sstevel@tonic-gate (void) printf(" %s %s lock set by",
4004987Sdanmcd mandatory ? "mandatory" : "advisory",
4014987Sdanmcd flock.l_type == F_RDLCK? "read" : "write");
4020Sstevel@tonic-gate if (sysid)
4030Sstevel@tonic-gate (void) printf(" system 0x%lX", sysid);
4040Sstevel@tonic-gate if (flock.l_pid)
4050Sstevel@tonic-gate (void) printf(" process %d", (int)flock.l_pid);
4060Sstevel@tonic-gate (void) fputc('\n', stdout);
4070Sstevel@tonic-gate }
4080Sstevel@tonic-gate }
4090Sstevel@tonic-gate }
4100Sstevel@tonic-gate
4110Sstevel@tonic-gate #define ALL_O_FLAGS O_ACCMODE | O_NDELAY | O_NONBLOCK | O_APPEND | \
4120Sstevel@tonic-gate O_SYNC | O_DSYNC | O_RSYNC | O_XATTR | \
4130Sstevel@tonic-gate O_CREAT | O_TRUNC | O_EXCL | O_NOCTTY | O_LARGEFILE
4140Sstevel@tonic-gate
4150Sstevel@tonic-gate static void
show_fileflags(int flags)4160Sstevel@tonic-gate show_fileflags(int flags)
4170Sstevel@tonic-gate {
4180Sstevel@tonic-gate char buffer[136];
4190Sstevel@tonic-gate char *str = buffer;
4200Sstevel@tonic-gate
4210Sstevel@tonic-gate switch (flags & O_ACCMODE) {
4220Sstevel@tonic-gate case O_RDONLY:
4230Sstevel@tonic-gate (void) strcpy(str, "O_RDONLY");
4240Sstevel@tonic-gate break;
4250Sstevel@tonic-gate case O_WRONLY:
4260Sstevel@tonic-gate (void) strcpy(str, "O_WRONLY");
4270Sstevel@tonic-gate break;
4280Sstevel@tonic-gate case O_RDWR:
4290Sstevel@tonic-gate (void) strcpy(str, "O_RDWR");
4300Sstevel@tonic-gate break;
431*12789SRoger.Faulkner@Oracle.COM case O_SEARCH:
432*12789SRoger.Faulkner@Oracle.COM (void) strcpy(str, "O_SEARCH");
433*12789SRoger.Faulkner@Oracle.COM break;
434*12789SRoger.Faulkner@Oracle.COM case O_EXEC:
435*12789SRoger.Faulkner@Oracle.COM (void) strcpy(str, "O_EXEC");
436*12789SRoger.Faulkner@Oracle.COM break;
4370Sstevel@tonic-gate default:
4380Sstevel@tonic-gate (void) sprintf(str, "0x%x", flags & O_ACCMODE);
4390Sstevel@tonic-gate break;
4400Sstevel@tonic-gate }
4410Sstevel@tonic-gate
4420Sstevel@tonic-gate if (flags & O_NDELAY)
4430Sstevel@tonic-gate (void) strcat(str, "|O_NDELAY");
4440Sstevel@tonic-gate if (flags & O_NONBLOCK)
4450Sstevel@tonic-gate (void) strcat(str, "|O_NONBLOCK");
4460Sstevel@tonic-gate if (flags & O_APPEND)
4470Sstevel@tonic-gate (void) strcat(str, "|O_APPEND");
4480Sstevel@tonic-gate if (flags & O_SYNC)
4490Sstevel@tonic-gate (void) strcat(str, "|O_SYNC");
4500Sstevel@tonic-gate if (flags & O_DSYNC)
4510Sstevel@tonic-gate (void) strcat(str, "|O_DSYNC");
4520Sstevel@tonic-gate if (flags & O_RSYNC)
4530Sstevel@tonic-gate (void) strcat(str, "|O_RSYNC");
4540Sstevel@tonic-gate if (flags & O_CREAT)
4550Sstevel@tonic-gate (void) strcat(str, "|O_CREAT");
4560Sstevel@tonic-gate if (flags & O_TRUNC)
4570Sstevel@tonic-gate (void) strcat(str, "|O_TRUNC");
4580Sstevel@tonic-gate if (flags & O_EXCL)
4590Sstevel@tonic-gate (void) strcat(str, "|O_EXCL");
4600Sstevel@tonic-gate if (flags & O_NOCTTY)
4610Sstevel@tonic-gate (void) strcat(str, "|O_NOCTTY");
4620Sstevel@tonic-gate if (flags & O_LARGEFILE)
4630Sstevel@tonic-gate (void) strcat(str, "|O_LARGEFILE");
4640Sstevel@tonic-gate if (flags & O_XATTR)
4650Sstevel@tonic-gate (void) strcat(str, "|O_XATTR");
4660Sstevel@tonic-gate if (flags & ~(ALL_O_FLAGS))
4670Sstevel@tonic-gate (void) sprintf(str + strlen(str), "|0x%x",
4684987Sdanmcd flags & ~(ALL_O_FLAGS));
4690Sstevel@tonic-gate
4700Sstevel@tonic-gate (void) printf("%s", str);
4710Sstevel@tonic-gate }
4720Sstevel@tonic-gate
4730Sstevel@tonic-gate /* show door info */
4740Sstevel@tonic-gate static void
show_door(struct ps_prochandle * Pr,int fd)4750Sstevel@tonic-gate show_door(struct ps_prochandle *Pr, int fd)
4760Sstevel@tonic-gate {
4770Sstevel@tonic-gate door_info_t door_info;
4780Sstevel@tonic-gate psinfo_t psinfo;
4790Sstevel@tonic-gate
4800Sstevel@tonic-gate if (pr_door_info(Pr, fd, &door_info) != 0)
4810Sstevel@tonic-gate return;
4820Sstevel@tonic-gate
4830Sstevel@tonic-gate if (proc_get_psinfo(door_info.di_target, &psinfo) != 0)
4840Sstevel@tonic-gate psinfo.pr_fname[0] = '\0';
4850Sstevel@tonic-gate
4860Sstevel@tonic-gate (void) printf(" door to ");
4870Sstevel@tonic-gate if (psinfo.pr_fname[0] != '\0')
4880Sstevel@tonic-gate (void) printf("%s[%d]", psinfo.pr_fname,
4894987Sdanmcd (int)door_info.di_target);
4900Sstevel@tonic-gate else
4910Sstevel@tonic-gate (void) printf("pid %d", (int)door_info.di_target);
4920Sstevel@tonic-gate }
4930Sstevel@tonic-gate
4946583Smeem /*
4956583Smeem * Print out the socket address pointed to by `sa'. `len' is only
4966583Smeem * needed for AF_UNIX sockets.
4976583Smeem */
4980Sstevel@tonic-gate static void
show_sockaddr(const char * str,struct sockaddr * sa,socklen_t len)4990Sstevel@tonic-gate show_sockaddr(const char *str, struct sockaddr *sa, socklen_t len)
5000Sstevel@tonic-gate {
5016583Smeem struct sockaddr_in *so_in = (struct sockaddr_in *)(void *)sa;
5026583Smeem struct sockaddr_in6 *so_in6 = (struct sockaddr_in6 *)(void *)sa;
5030Sstevel@tonic-gate struct sockaddr_un *so_un = (struct sockaddr_un *)sa;
5040Sstevel@tonic-gate char abuf[INET6_ADDRSTRLEN];
5050Sstevel@tonic-gate const char *p;
5060Sstevel@tonic-gate
5070Sstevel@tonic-gate switch (sa->sa_family) {
5080Sstevel@tonic-gate default:
5090Sstevel@tonic-gate return;
5100Sstevel@tonic-gate case AF_INET:
5116583Smeem (void) printf("\t%s: AF_INET %s port: %u\n", str,
5120Sstevel@tonic-gate inet_ntop(AF_INET, &so_in->sin_addr, abuf, sizeof (abuf)),
5130Sstevel@tonic-gate ntohs(so_in->sin_port));
5140Sstevel@tonic-gate return;
5150Sstevel@tonic-gate case AF_INET6:
5166583Smeem (void) printf("\t%s: AF_INET6 %s port: %u\n", str,
5170Sstevel@tonic-gate inet_ntop(AF_INET6, &so_in6->sin6_addr,
5180Sstevel@tonic-gate abuf, sizeof (abuf)),
5190Sstevel@tonic-gate ntohs(so_in->sin_port));
5200Sstevel@tonic-gate return;
5210Sstevel@tonic-gate case AF_UNIX:
5220Sstevel@tonic-gate if (len >= sizeof (so_un->sun_family)) {
5230Sstevel@tonic-gate /* Null terminate */
5240Sstevel@tonic-gate len -= sizeof (so_un->sun_family);
5256583Smeem so_un->sun_path[len] = '\0';
5260Sstevel@tonic-gate (void) printf("\t%s: AF_UNIX %s\n",
5274987Sdanmcd str, so_un->sun_path);
5280Sstevel@tonic-gate }
5290Sstevel@tonic-gate return;
5300Sstevel@tonic-gate case AF_IMPLINK: p = "AF_IMPLINK"; break;
5310Sstevel@tonic-gate case AF_PUP: p = "AF_PUP"; break;
5320Sstevel@tonic-gate case AF_CHAOS: p = "AF_CHAOS"; break;
5330Sstevel@tonic-gate case AF_NS: p = "AF_NS"; break;
5340Sstevel@tonic-gate case AF_NBS: p = "AF_NBS"; break;
5350Sstevel@tonic-gate case AF_ECMA: p = "AF_ECMA"; break;
5360Sstevel@tonic-gate case AF_DATAKIT: p = "AF_DATAKIT"; break;
5370Sstevel@tonic-gate case AF_CCITT: p = "AF_CCITT"; break;
5380Sstevel@tonic-gate case AF_SNA: p = "AF_SNA"; break;
5390Sstevel@tonic-gate case AF_DECnet: p = "AF_DECnet"; break;
5400Sstevel@tonic-gate case AF_DLI: p = "AF_DLI"; break;
5410Sstevel@tonic-gate case AF_LAT: p = "AF_LAT"; break;
5420Sstevel@tonic-gate case AF_HYLINK: p = "AF_HYLINK"; break;
5430Sstevel@tonic-gate case AF_APPLETALK: p = "AF_APPLETALK"; break;
5440Sstevel@tonic-gate case AF_NIT: p = "AF_NIT"; break;
5450Sstevel@tonic-gate case AF_802: p = "AF_802"; break;
5460Sstevel@tonic-gate case AF_OSI: p = "AF_OSI"; break;
5470Sstevel@tonic-gate case AF_X25: p = "AF_X25"; break;
5480Sstevel@tonic-gate case AF_OSINET: p = "AF_OSINET"; break;
5490Sstevel@tonic-gate case AF_GOSIP: p = "AF_GOSIP"; break;
5500Sstevel@tonic-gate case AF_IPX: p = "AF_IPX"; break;
5510Sstevel@tonic-gate case AF_ROUTE: p = "AF_ROUTE"; break;
5520Sstevel@tonic-gate case AF_LINK: p = "AF_LINK"; break;
5530Sstevel@tonic-gate }
5540Sstevel@tonic-gate
5550Sstevel@tonic-gate (void) printf("\t%s: %s\n", str, p);
5560Sstevel@tonic-gate }
5570Sstevel@tonic-gate
5580Sstevel@tonic-gate static void
show_socktype(uint_t type)5590Sstevel@tonic-gate show_socktype(uint_t type)
5600Sstevel@tonic-gate {
5610Sstevel@tonic-gate static const char *types[] = {
5620Sstevel@tonic-gate NULL, "DGRAM", "STREAM", NULL, "RAW", "RDM", "SEQPACKET"
5630Sstevel@tonic-gate };
5640Sstevel@tonic-gate
5650Sstevel@tonic-gate if (type < sizeof (types) / sizeof (*types) && types[type] != NULL)
5660Sstevel@tonic-gate (void) printf("\tSOCK_%s\n", types[type]);
5670Sstevel@tonic-gate else
5680Sstevel@tonic-gate (void) printf("\tunknown socket type %u\n", type);
5690Sstevel@tonic-gate }
5700Sstevel@tonic-gate
5711095Spriyanka #define BUFSIZE 200
5720Sstevel@tonic-gate static void
show_sockopts(struct ps_prochandle * Pr,int fd)5730Sstevel@tonic-gate show_sockopts(struct ps_prochandle *Pr, int fd)
5740Sstevel@tonic-gate {
5750Sstevel@tonic-gate int val, vlen;
5761095Spriyanka char buf[BUFSIZE];
5770Sstevel@tonic-gate char buf1[32];
5781095Spriyanka char ipaddr[INET_ADDRSTRLEN];
5790Sstevel@tonic-gate int i;
5801095Spriyanka in_addr_t nexthop_val;
5810Sstevel@tonic-gate struct boolopt {
5824987Sdanmcd int level;
5830Sstevel@tonic-gate int opt;
5840Sstevel@tonic-gate const char *name;
5850Sstevel@tonic-gate };
5860Sstevel@tonic-gate static struct boolopt boolopts[] = {
5874987Sdanmcd { SOL_SOCKET, SO_DEBUG, "SO_DEBUG," },
5884987Sdanmcd { SOL_SOCKET, SO_REUSEADDR, "SO_REUSEADDR," },
5894987Sdanmcd { SOL_SOCKET, SO_KEEPALIVE, "SO_KEEPALIVE," },
5904987Sdanmcd { SOL_SOCKET, SO_DONTROUTE, "SO_DONTROUTE," },
5914987Sdanmcd { SOL_SOCKET, SO_BROADCAST, "SO_BROADCAST," },
5924987Sdanmcd { SOL_SOCKET, SO_OOBINLINE, "SO_OOBINLINE," },
5934987Sdanmcd { SOL_SOCKET, SO_DGRAM_ERRIND, "SO_DGRAM_ERRIND,"},
5944987Sdanmcd { SOL_SOCKET, SO_ALLZONES, "SO_ALLZONES," },
59510934Ssommerfeld@sun.com { SOL_SOCKET, SO_MAC_EXEMPT, "SO_MAC_EXEMPT," },
59610934Ssommerfeld@sun.com { SOL_SOCKET, SO_MAC_IMPLICIT, "SO_MAC_IMPLICIT," },
5974987Sdanmcd { SOL_SOCKET, SO_EXCLBIND, "SO_EXCLBIND," },
59811076SCathy.Zhou@Sun.COM { SOL_SOCKET, SO_VRRP, "SO_VRRP," },
5994987Sdanmcd { IPPROTO_UDP, UDP_NAT_T_ENDPOINT, "UDP_NAT_T_ENDPOINT," },
6000Sstevel@tonic-gate };
6010Sstevel@tonic-gate struct linger l;
6020Sstevel@tonic-gate
6032263Ssommerfe buf[0] = '!'; /* sentinel value, never printed */
6040Sstevel@tonic-gate buf[1] = '\0';
6050Sstevel@tonic-gate
6060Sstevel@tonic-gate for (i = 0; i < sizeof (boolopts) / sizeof (boolopts[0]); i++) {
6070Sstevel@tonic-gate vlen = sizeof (val);
6084987Sdanmcd if (pr_getsockopt(Pr, fd, boolopts[i].level, boolopts[i].opt,
6094987Sdanmcd &val, &vlen) == 0 && val != 0)
6100Sstevel@tonic-gate (void) strlcat(buf, boolopts[i].name, sizeof (buf));
6110Sstevel@tonic-gate }
6120Sstevel@tonic-gate
6130Sstevel@tonic-gate vlen = sizeof (l);
6140Sstevel@tonic-gate if (pr_getsockopt(Pr, fd, SOL_SOCKET, SO_LINGER, &l, &vlen) == 0 &&
6150Sstevel@tonic-gate l.l_onoff != 0) {
6160Sstevel@tonic-gate (void) snprintf(buf1, sizeof (buf1), "SO_LINGER(%d),",
6170Sstevel@tonic-gate l.l_linger);
6180Sstevel@tonic-gate (void) strlcat(buf, buf1, sizeof (buf));
6190Sstevel@tonic-gate }
6200Sstevel@tonic-gate
6210Sstevel@tonic-gate vlen = sizeof (val);
6220Sstevel@tonic-gate if (pr_getsockopt(Pr, fd, SOL_SOCKET, SO_SNDBUF, &val, &vlen) == 0) {
6230Sstevel@tonic-gate (void) snprintf(buf1, sizeof (buf1), "SO_SNDBUF(%d),", val);
6240Sstevel@tonic-gate (void) strlcat(buf, buf1, sizeof (buf));
6250Sstevel@tonic-gate }
6260Sstevel@tonic-gate vlen = sizeof (val);
6270Sstevel@tonic-gate if (pr_getsockopt(Pr, fd, SOL_SOCKET, SO_RCVBUF, &val, &vlen) == 0) {
6280Sstevel@tonic-gate (void) snprintf(buf1, sizeof (buf1), "SO_RCVBUF(%d),", val);
6290Sstevel@tonic-gate (void) strlcat(buf, buf1, sizeof (buf));
6300Sstevel@tonic-gate }
6311095Spriyanka vlen = sizeof (nexthop_val);
6321095Spriyanka if (pr_getsockopt(Pr, fd, IPPROTO_IP, IP_NEXTHOP, &nexthop_val,
6331095Spriyanka &vlen) == 0) {
6341628Spriyanka if (vlen > 0) {
6351628Spriyanka (void) inet_ntop(AF_INET, (void *) &nexthop_val,
6361628Spriyanka ipaddr, sizeof (ipaddr));
6371628Spriyanka (void) snprintf(buf1, sizeof (buf1), "IP_NEXTHOP(%s),",
6381628Spriyanka ipaddr);
6391628Spriyanka (void) strlcat(buf, buf1, sizeof (buf));
6401628Spriyanka }
6411095Spriyanka }
6420Sstevel@tonic-gate
6432263Ssommerfe buf[strlen(buf) - 1] = '\0'; /* overwrites sentinel if no options */
6440Sstevel@tonic-gate if (buf[1] != '\0')
6450Sstevel@tonic-gate (void) printf("\t%s\n", buf+1);
6460Sstevel@tonic-gate }
6470Sstevel@tonic-gate
64812643SAnders.Persson@Sun.COM #define MAXNALLOC 32
64912643SAnders.Persson@Sun.COM static void
show_sockfilters(struct ps_prochandle * Pr,int fd)65012643SAnders.Persson@Sun.COM show_sockfilters(struct ps_prochandle *Pr, int fd)
65112643SAnders.Persson@Sun.COM {
65212643SAnders.Persson@Sun.COM struct fil_info *fi;
65312643SAnders.Persson@Sun.COM int i = 0, nalloc = 2, len = nalloc * sizeof (*fi);
65412643SAnders.Persson@Sun.COM boolean_t printhdr = B_TRUE;
65512643SAnders.Persson@Sun.COM
65612643SAnders.Persson@Sun.COM fi = calloc(nalloc, sizeof (*fi));
65712643SAnders.Persson@Sun.COM if (fi == NULL) {
65812643SAnders.Persson@Sun.COM perror("calloc");
65912643SAnders.Persson@Sun.COM return;
66012643SAnders.Persson@Sun.COM }
66112643SAnders.Persson@Sun.COM /* CONSTCOND */
66212643SAnders.Persson@Sun.COM while (1) {
66312643SAnders.Persson@Sun.COM if (pr_getsockopt(Pr, fd, SOL_FILTER, FIL_LIST, fi, &len) != 0)
66412643SAnders.Persson@Sun.COM break;
66512643SAnders.Persson@Sun.COM /* No filters */
66612643SAnders.Persson@Sun.COM if (len == 0)
66712643SAnders.Persson@Sun.COM break;
66812643SAnders.Persson@Sun.COM /* Make sure buffer was large enough */
66912643SAnders.Persson@Sun.COM if (fi->fi_pos >= nalloc) {
67012643SAnders.Persson@Sun.COM struct fil_info *new;
67112643SAnders.Persson@Sun.COM
67212643SAnders.Persson@Sun.COM nalloc = fi->fi_pos + 1;
67312643SAnders.Persson@Sun.COM if (nalloc > MAXNALLOC)
67412643SAnders.Persson@Sun.COM break;
67512643SAnders.Persson@Sun.COM len = nalloc * sizeof (*fi);
67612643SAnders.Persson@Sun.COM new = realloc(fi, nalloc * sizeof (*fi));
67712643SAnders.Persson@Sun.COM if (new == NULL) {
67812643SAnders.Persson@Sun.COM perror("realloc");
67912643SAnders.Persson@Sun.COM break;
68012643SAnders.Persson@Sun.COM }
68112643SAnders.Persson@Sun.COM fi = new;
68212643SAnders.Persson@Sun.COM continue;
68312643SAnders.Persson@Sun.COM }
68412643SAnders.Persson@Sun.COM
68512643SAnders.Persson@Sun.COM for (i = 0; (i + 1) * sizeof (*fi) <= len; i++) {
68612643SAnders.Persson@Sun.COM if (fi[i].fi_flags & FILF_BYPASS)
68712643SAnders.Persson@Sun.COM continue;
68812643SAnders.Persson@Sun.COM if (printhdr) {
68912643SAnders.Persson@Sun.COM (void) printf("\tfilters: ");
69012643SAnders.Persson@Sun.COM printhdr = B_FALSE;
69112643SAnders.Persson@Sun.COM }
69212643SAnders.Persson@Sun.COM (void) printf("%s", fi[i].fi_name);
69312643SAnders.Persson@Sun.COM if (fi[i].fi_flags != 0) {
69412643SAnders.Persson@Sun.COM (void) printf("(");
69512643SAnders.Persson@Sun.COM if (fi[i].fi_flags & FILF_AUTO)
69612643SAnders.Persson@Sun.COM (void) printf("auto,");
69712643SAnders.Persson@Sun.COM if (fi[i].fi_flags & FILF_PROG)
69812643SAnders.Persson@Sun.COM (void) printf("prog,");
69912643SAnders.Persson@Sun.COM (void) printf("\b)");
70012643SAnders.Persson@Sun.COM }
70112643SAnders.Persson@Sun.COM if (fi[i].fi_pos == 0) /* last one */
70212643SAnders.Persson@Sun.COM break;
70312643SAnders.Persson@Sun.COM (void) printf(",");
70412643SAnders.Persson@Sun.COM }
70512643SAnders.Persson@Sun.COM if (!printhdr)
70612643SAnders.Persson@Sun.COM (void) printf("\n");
70712643SAnders.Persson@Sun.COM break;
70812643SAnders.Persson@Sun.COM }
70912643SAnders.Persson@Sun.COM free(fi);
71012643SAnders.Persson@Sun.COM }
71112643SAnders.Persson@Sun.COM
7120Sstevel@tonic-gate /* the file is a socket */
7130Sstevel@tonic-gate static void
dosocket(struct ps_prochandle * Pr,int fd)7140Sstevel@tonic-gate dosocket(struct ps_prochandle *Pr, int fd)
7150Sstevel@tonic-gate {
7160Sstevel@tonic-gate /* A buffer large enough for PATH_MAX size AF_UNIX address */
7170Sstevel@tonic-gate long buf[(sizeof (short) + PATH_MAX + sizeof (long) - 1)
7184987Sdanmcd / sizeof (long)];
7190Sstevel@tonic-gate struct sockaddr *sa = (struct sockaddr *)buf;
7200Sstevel@tonic-gate socklen_t len;
7210Sstevel@tonic-gate int type, tlen;
7220Sstevel@tonic-gate
7230Sstevel@tonic-gate tlen = sizeof (type);
7246583Smeem if (pr_getsockopt(Pr, fd, SOL_SOCKET, SO_TYPE, &type, &tlen) == 0)
7250Sstevel@tonic-gate show_socktype((uint_t)type);
7260Sstevel@tonic-gate
7270Sstevel@tonic-gate show_sockopts(Pr, fd);
72812643SAnders.Persson@Sun.COM show_sockfilters(Pr, fd);
7290Sstevel@tonic-gate
7300Sstevel@tonic-gate len = sizeof (buf);
7310Sstevel@tonic-gate if (pr_getsockname(Pr, fd, sa, &len) == 0)
7320Sstevel@tonic-gate show_sockaddr("sockname", sa, len);
7330Sstevel@tonic-gate
7340Sstevel@tonic-gate len = sizeof (buf);
7350Sstevel@tonic-gate if (pr_getpeername(Pr, fd, sa, &len) == 0)
7360Sstevel@tonic-gate show_sockaddr("peername", sa, len);
7370Sstevel@tonic-gate }
7386583Smeem
7396583Smeem /* the file is a TLI endpoint */
7406583Smeem static void
dotli(struct ps_prochandle * Pr,int fd)7416583Smeem dotli(struct ps_prochandle *Pr, int fd)
7426583Smeem {
7436583Smeem struct strcmd strcmd;
7446583Smeem
7456583Smeem strcmd.sc_len = STRCMDBUFSIZE;
7466583Smeem strcmd.sc_timeout = 5;
7476583Smeem
7486583Smeem strcmd.sc_cmd = TI_GETMYNAME;
7496583Smeem if (pr_ioctl(Pr, fd, _I_CMD, &strcmd, sizeof (strcmd)) == 0)
7506583Smeem show_sockaddr("sockname", (void *)&strcmd.sc_buf, 0);
7516583Smeem
7526583Smeem strcmd.sc_cmd = TI_GETPEERNAME;
7536583Smeem if (pr_ioctl(Pr, fd, _I_CMD, &strcmd, sizeof (strcmd)) == 0)
7546583Smeem show_sockaddr("peername", (void *)&strcmd.sc_buf, 0);
7556583Smeem }
756