diff options
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/fstat/fstat.c | 52 | ||||
| -rw-r--r-- | usr.bin/procstat/procstat.1 | 4 | ||||
| -rw-r--r-- | usr.bin/procstat/procstat_files.c | 5 |
3 files changed, 60 insertions, 1 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 886c3bb4746c..6ed707681d4c 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include <sys/un.h> #include <sys/unpcb.h> #include <sys/sysctl.h> +#include <sys/tty.h> #include <sys/filedesc.h> #include <sys/queue.h> #define _WANT_FILE @@ -154,6 +155,7 @@ int devfs_filestat(struct vnode *vp, struct filestat *fsp); char *getmnton(struct mount *m); void pipetrans(struct pipe *pi, int i, int flag); void socktrans(struct socket *sock, int i); +void ptstrans(struct tty *tp, int i, int flag); void getinetproto(int number); int getfname(const char *filename); void usage(void); @@ -411,6 +413,12 @@ dofiles(struct kinfo_proc *kp) vtrans(file.f_vnode, i, file.f_flag); } #endif +#ifdef DTYPE_PTS + else if (file.f_type == DTYPE_PTS) { + if (checkfile == 0) + ptstrans(file.f_data, i, file.f_flag); + } +#endif else { dprintf(stderr, "unknown file type %d for file %d of pid %d\n", @@ -887,6 +895,50 @@ bad: printf("* error\n"); } +void +ptstrans(struct tty *tp, int i, int flag) +{ + struct tty tty; + char *name; + char rw[3]; + dev_t rdev; + + PREFIX(i); + + /* Obtain struct tty. */ + if (!KVM_READ(tp, &tty, sizeof(struct tty))) { + dprintf(stderr, "can't read tty at %p\n", (void *)tp); + goto bad; + } + + /* Figure out the device name. */ + name = kdevtoname(tty.t_dev); + if (name == NULL) { + dprintf(stderr, "can't determine tty name at %p\n", (void *)tp); + goto bad; + } + + rw[0] = '\0'; + if (flag & FREAD) + strcat(rw, "r"); + if (flag & FWRITE) + strcat(rw, "w"); + + printf("* pseudo-terminal master "); + if (nflg || !name) { + rdev = dev2udev(tty.t_dev); + printf("%10d,%-2d", major(rdev), minor(rdev)); + } else { + printf("%10s", name); + } + printf(" %2s\n", rw); + + free(name); + + return; +bad: + printf("* error\n"); +} /* * Read the cdev structure in the kernel in order to work out the diff --git a/usr.bin/procstat/procstat.1 b/usr.bin/procstat/procstat.1 index daffbbf33a36..43761fd20d34 100644 --- a/usr.bin/procstat/procstat.1 +++ b/usr.bin/procstat/procstat.1 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 19, 2008 +.Dd August 20, 2008 .Dt PROCSTAT 1 .Os .Sh NAME @@ -153,6 +153,8 @@ message queue pipe .It s socket +.It t +pseudo-terminal master .It v vnode .El diff --git a/usr.bin/procstat/procstat_files.c b/usr.bin/procstat/procstat_files.c index 39ce82b4f44c..3667913a9666 100644 --- a/usr.bin/procstat/procstat_files.c +++ b/usr.bin/procstat/procstat_files.c @@ -222,6 +222,10 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp) str = "h"; break; + case KF_TYPE_PTS: + str = "t"; + break; + case KF_TYPE_SEM: str = "e"; break; @@ -296,6 +300,7 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp) switch (kif->kf_type) { case KF_TYPE_VNODE: case KF_TYPE_FIFO: + case KF_TYPE_PTS: printf("%-3s ", "-"); printf("%-18s", kif->kf_path); break; |
