summaryrefslogtreecommitdiff
path: root/usr.bin/fstat/fstat.c
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>1999-04-30 02:27:00 +0000
committerArtur Grabowski <art@cvs.openbsd.org>1999-04-30 02:27:00 +0000
commit7ad973bb2f6434381f6134878bec6c44506b2bc7 (patch)
tree21b769d21338687aff635d0d247b47edd868088f /usr.bin/fstat/fstat.c
parent25b3207011e1cbebe531f0319c11fa3f41f9388b (diff)
add support for pipes since sparc uses new pipe code by default now
Diffstat (limited to 'usr.bin/fstat/fstat.c')
-rw-r--r--usr.bin/fstat/fstat.c52
1 files changed, 48 insertions, 4 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index 02aaec475ca..7d982c87341 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fstat.c,v 1.21 1998/11/30 10:19:02 deraadt Exp $ */
+/* $OpenBSD: fstat.c,v 1.22 1999/04/30 02:26:59 art Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -41,7 +41,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)fstat.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$OpenBSD: fstat.c,v 1.21 1998/11/30 10:19:02 deraadt Exp $";
+static char *rcsid = "$OpenBSD: fstat.c,v 1.22 1999/04/30 02:26:59 art Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -80,6 +80,10 @@ static char *rcsid = "$OpenBSD: fstat.c,v 1.21 1998/11/30 10:19:02 deraadt Exp $
#include <arpa/inet.h>
+#define PIPE_NODIRECT /* XXX - define here, since it's not defined
+ outside _KERNEL */
+#include <sys/pipe.h>
+
#include <ctype.h>
#include <errno.h>
#include <kvm.h>
@@ -144,6 +148,7 @@ void socktrans __P((struct socket *, int));
void usage __P((void));
void vtrans __P((struct vnode *, int, int));
int getfname __P((char *));
+void pipetrans __P((struct pipe *, int));
int
main(argc, argv)
@@ -350,8 +355,10 @@ dofiles(kp)
else if (file.f_type == DTYPE_SOCKET) {
if (checkfile == 0)
socktrans((struct socket *)file.f_data, i);
- }
- else {
+ } else if (file.f_type == DTYPE_PIPE) {
+ if (checkfile == 0)
+ pipetrans((struct pipe *)file.f_data, i);
+ } else {
dprintf("unknown file type %d for file %d of pid %d",
file.f_type, i, Pid);
}
@@ -626,6 +633,43 @@ getmnton(m)
}
void
+pipetrans(pipe, i)
+ struct pipe *pipe;
+ int i;
+{
+ struct pipe pi;
+ void *maxaddr;
+
+ PREFIX(i);
+
+ printf(" ");
+
+ /* fill in socket */
+ if (!KVM_READ(pipe, &pi, sizeof(struct pipe))) {
+ dprintf("can't read pipe at %p", pipe);
+ goto bad;
+ }
+
+ /*
+ * We don't have enough space to fit both peer and own address, so
+ * we select the higher address so both ends of the pipe have the
+ * same visible addr. (it's the higher address because when the other
+ * end closes, it becomes 0)
+ */
+ maxaddr = MAX(pipe, pi.pipe_peer);
+
+ printf("pipe %p state: %s%s%s", maxaddr,
+ (pi.pipe_state & PIPE_WANTR) ? "R" : "",
+ (pi.pipe_state & PIPE_WANTW) ? "W" : "",
+ (pi.pipe_state & PIPE_EOF) ? "E" : "");
+
+ printf("\n");
+ return;
+bad:
+ printf("* error\n");
+}
+
+void
socktrans(sock, i)
struct socket *sock;
int i;