*** ../ps-0.98/fstat.c	Tue Oct 20 14:33:17 1992
--- fstat.c	Thu Dec 24 02:37:38 1992
***************
*** 21,26 ****
--- 21,29 ----
  struct inode *ino_table;
  struct file *fil_table;
  
+ int _read_pipe_fops;
+ int _write_pipe_fops;
+ 
  caddr_t kbase;
  
  #define	KWORD(a)	(*((unsigned long *)(kbase + (a))))
***************
*** 119,125 ****
      }
  
      mmap_mem();
!     ino_table = KPTR(k_addr("_inode_table"));
      fil_table = KPTR(k_addr("_file_table"));
      p = KPTR(k_addr("_task"));
      for (n = NR_TASKS; n > 0; --n, ++p) {
--- 122,128 ----
      }
  
      mmap_mem();
!     ino_table = KPTR(KWORD(k_addr("_inode_table")));
      fil_table = KPTR(k_addr("_file_table"));
      p = KPTR(k_addr("_task"));
      for (n = NR_TASKS; n > 0; --n, ++p) {
***************
*** 190,196 ****
      int i;
      static int pid = -1;
  
!     if (!inop)
  	return;
  
      inop = KPTR(ino);
--- 193,199 ----
      int i;
      static int pid = -1;
  
!     if (!ino)
  	return;
  
      inop = KPTR(ino);
***************
*** 228,234 ****
  	printf("%5d", type);
      
      if (inop->i_mode == 0 && inop->i_pipe) {
! 	printf("* (pipe %#x)\n", PIPE_BASE(*inop));
  	return;
      }
      if (S_ISSOCK(inop->i_mode)) {
--- 231,248 ----
  	printf("%5d", type);
      
      if (inop->i_mode == 0 && inop->i_pipe) {
! 	char *rw = "?";
! 	if (!_read_pipe_fops) {
! 	    _read_pipe_fops = k_addr("_read_pipe_fops");
! 	    _write_pipe_fops = k_addr("_write_pipe_fops");
! 	}
! 	if ((long)((struct file *)KPTR(task->filp[i]))->f_op == _read_pipe_fops)
! 	    rw = "<-";
! 	else if ((long)((struct file *)KPTR(task->filp[i]))->f_op == _write_pipe_fops)
! 	    rw = "->";
! 	printf("* (pipe %s %#x %d %dr %dw)\n", rw, PIPE_BASE(*inop),
! 		PIPE_SIZE(*inop),
! 		PIPE_READERS(*inop), PIPE_WRITERS(*inop));
  	return;
      }
      if (S_ISSOCK(inop->i_mode)) {
***************
*** 337,342 ****
--- 351,359 ----
  
  #include <linux/socket.h>
  #include "/usr/src/linux/net/kern_sock.h"
+ #include "/usr/src/linux/net/tcp/timer.h"
+ #include "/usr/src/linux/net/tcp/tcp.h"
+ #include "/usr/src/linux/net/tcp/sock.h"
  
  #define	SOCK_INODE(x)	((x)->dummy)
  
***************
*** 345,350 ****
--- 362,373 ----
  int _unix_proto_ops;
  int _inet_proto_ops;
  
+ char *af_name[] = {
+     "????",
+     "unix",
+     "inet",
+ };
+ 
  struct socket *sockets;
  
  print_sock(ino)
***************
*** 351,356 ****
--- 374,380 ----
  struct inode *ino;
  {
      struct socket *sock;
+     int af = 0;
  
      if (sockets == NULL)
  	sock_init();
***************
*** 359,370 ****
  	return;
      }
      if ((long) sock->ops == _unix_proto_ops)
! 	printf("* (unix ");
      else if (_inet_proto_ops != -1 && (long) sock->ops == _inet_proto_ops)
! 	printf("* (inet ");
!     else
! 	printf("* (???? ");
  
      switch (sock->type) {
  	case SOCK_STREAM: printf("stream"); break;
  	case SOCK_DGRAM: printf("dgram"); break;
--- 383,393 ----
  	return;
      }
      if ((long) sock->ops == _unix_proto_ops)
! 	af = AF_UNIX;
      else if (_inet_proto_ops != -1 && (long) sock->ops == _inet_proto_ops)
! 	af = AF_INET;
  
+     printf("* (%s ", af_name[af]);
      switch (sock->type) {
  	case SOCK_STREAM: printf("stream"); break;
  	case SOCK_DGRAM: printf("dgram"); break;
***************
*** 374,380 ****
  	case SOCK_PACKET: printf("packet"); break;
  	default: printf("???");
      }
!     printf(" %x)\n", sock->flags);
  }
  
  struct socket *
--- 397,413 ----
  	case SOCK_PACKET: printf("packet"); break;
  	default: printf("???");
      }
!     printf(" %x", sock->flags);
! 
!     if (af == AF_INET) {
! 	struct sock sk;
! 
! 	if (sock->data) {
! 	    kmemread(&sk, sock->data, sizeof sk);
! 	    printf(" %d", sk.num);
! 	}
!     }
!     printf(")\n");
  }
  
  struct socket *
***************
*** 465,471 ****
  #if 0
      end_mem = get_kword(k_addr("_high_memory"));
  #else
!     end_mem = k_addr("_end");
  #endif
      if (kbase == NULL) {
  	if ((kbase = (caddr_t) malloc(end_mem)) == NULL || ((long) kbase & 0xfff)) {
--- 498,504 ----
  #if 0
      end_mem = get_kword(k_addr("_high_memory"));
  #else
!     end_mem = get_kword(k_addr("_memory_start"));
  #endif
      if (kbase == NULL) {
  	if ((kbase = (caddr_t) malloc(end_mem)) == NULL || ((long) kbase & 0xfff)) {
