home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / linux / 22439 < prev    next >
Encoding:
Text File  |  1993-01-02  |  10.1 KB  |  387 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!aurora.cc.monash.edu.au!andrewc
  3. From: andrewc@aurora.cc.monash.edu.au (Andrew J. Cosgriff !)
  4. Subject: [FIX] PS FIX FOR 99p2 !!!
  5. Message-ID: <andrewc.725976478@aurora.cc.monash.edu.au>
  6. Summary: Patches for ps for 99p2
  7. Keywords: ps fix 99 p2
  8. Sender: news@monu6.cc.monash.edu.au (Usenet system)
  9. Organization: Monash University, Melb., Australia.
  10. Date: Sat, 2 Jan 1993 12:07:58 GMT
  11. Lines: 374
  12.  
  13. Okay, in my quest to do something useful for the Linux community, here are some patches to get
  14. ps up and running with 99p2..just a header file location change and an already-used variable,
  15. but, well, it's handy to have it done for you, I guess...
  16.  
  17. (After spending all day downloading gcc 2.3.3 and patch 2 for the kernel, I needed to compile
  18. something, and ps just happened to need it...)
  19.  
  20. One note, this patch also includes the fstat patches posted not too long ago, in case people 
  21. missed them (if not, you can ignore them or reverse them first)
  22.  
  23.  
  24. Enjoy !
  25.  
  26. Happy New Year everybody !
  27.  
  28. Cos !
  29.  
  30. -----------------------------------------------
  31. diff -c +recursive ps-0.98/Makefile ps/Makefile
  32. *** ps-0.98/Makefile    Wed Oct 21 00:14:19 1992
  33. --- ps/Makefile    Sat Jan  2 22:16:55 1993
  34. ***************
  35. *** 2,14 ****
  36.   # for Linux version 0.98
  37.   #
  38.   
  39. ! CFLAGS= -O -DVERSION_CHECK
  40. ! CFLAGS= -O
  41.   
  42.   # uncomment next line if you are using a compiler older than 2.2.2d
  43.   #CFLAGS= -O -Iinclude -I/usr/src/linux/include -Dhack
  44.   
  45. ! #LDFLAGS= -s
  46.   #LDFLAGS= -static
  47.   
  48.   # BINDIR: if you type "make install" the programs will be copied to this
  49. --- 2,14 ----
  50.   # for Linux version 0.98
  51.   #
  52.   
  53. ! CFLAGS= -O6 -DVERSION_CHECK
  54. ! #CFLAGS= -O6
  55.   
  56.   # uncomment next line if you are using a compiler older than 2.2.2d
  57.   #CFLAGS= -O -Iinclude -I/usr/src/linux/include -Dhack
  58.   
  59. ! LDFLAGS= -s
  60.   #LDFLAGS= -static
  61.   
  62.   # BINDIR: if you type "make install" the programs will be copied to this
  63. diff -c +recursive ps-0.98/fstat.c ps/fstat.c
  64. *** ps-0.98/fstat.c    Tue Oct 20 13:33:17 1992
  65. --- ps/fstat.c    Sat Jan  2 22:16:24 1993
  66. ***************
  67. *** 21,26 ****
  68. --- 21,29 ----
  69.   struct inode *ino_table;
  70.   struct file *fil_table;
  71.   
  72. + int _read_pipe_fops;
  73. + int _write_pipe_fops;
  74.   caddr_t kbase;
  75.   
  76.   #define    KWORD(a)    (*((unsigned long *)(kbase + (a))))
  77. ***************
  78. *** 119,125 ****
  79.       }
  80.   
  81.       mmap_mem();
  82. !     ino_table = KPTR(k_addr("_inode_table"));
  83.       fil_table = KPTR(k_addr("_file_table"));
  84.       p = KPTR(k_addr("_task"));
  85.       for (n = NR_TASKS; n > 0; --n, ++p) {
  86. --- 122,128 ----
  87.       }
  88.   
  89.       mmap_mem();
  90. !     ino_table = KPTR(KWORD(k_addr("_inode_table")));
  91.       fil_table = KPTR(k_addr("_file_table"));
  92.       p = KPTR(k_addr("_task"));
  93.       for (n = NR_TASKS; n > 0; --n, ++p) {
  94. ***************
  95. *** 190,196 ****
  96.       int i;
  97.       static int pid = -1;
  98.   
  99. !     if (!inop)
  100.       return;
  101.   
  102.       inop = KPTR(ino);
  103. --- 193,199 ----
  104.       int i;
  105.       static int pid = -1;
  106.   
  107. !     if (!ino)
  108.       return;
  109.   
  110.       inop = KPTR(ino);
  111. ***************
  112. *** 228,234 ****
  113.       printf("%5d", type);
  114.       
  115.       if (inop->i_mode == 0 && inop->i_pipe) {
  116. !     printf("* (pipe %#x)\n", PIPE_BASE(*inop));
  117.       return;
  118.       }
  119.       if (S_ISSOCK(inop->i_mode)) {
  120. --- 231,248 ----
  121.       printf("%5d", type);
  122.       
  123.       if (inop->i_mode == 0 && inop->i_pipe) {
  124. !     char *rw = "?";
  125. !     if (!_read_pipe_fops) {
  126. !         _read_pipe_fops = k_addr("_read_pipe_fops");
  127. !         _write_pipe_fops = k_addr("_write_pipe_fops");
  128. !     }
  129. !     if ((long)((struct file *)KPTR(task->filp[i]))->f_op == _read_pipe_fops)
  130. !         rw = "<-";
  131. !     else if ((long)((struct file *)KPTR(task->filp[i]))->f_op == _write_pipe_fops)
  132. !         rw = "->";
  133. !     printf("* (pipe %s %#x %d %dr %dw)\n", rw, PIPE_BASE(*inop),
  134. !         PIPE_SIZE(*inop),
  135. !         PIPE_READERS(*inop), PIPE_WRITERS(*inop));
  136.       return;
  137.       }
  138.       if (S_ISSOCK(inop->i_mode)) {
  139. ***************
  140. *** 337,342 ****
  141. --- 351,359 ----
  142.   
  143.   #include <linux/socket.h>
  144.   #include "/usr/src/linux/net/kern_sock.h"
  145. + #include "/usr/src/linux/net/tcp/timer.h"
  146. + #include "/usr/src/linux/net/tcp/tcp.h"
  147. + #include "/usr/src/linux/net/tcp/sock.h"
  148.   
  149.   #define    SOCK_INODE(x)    ((x)->dummy)
  150.   
  151. ***************
  152. *** 345,350 ****
  153. --- 362,373 ----
  154.   int _unix_proto_ops;
  155.   int _inet_proto_ops;
  156.   
  157. + char *af_name[] = {
  158. +     "????",
  159. +     "unix",
  160. +     "inet",
  161. + };
  162.   struct socket *sockets;
  163.   
  164.   print_sock(ino)
  165. ***************
  166. *** 351,356 ****
  167. --- 374,380 ----
  168.   struct inode *ino;
  169.   {
  170.       struct socket *sock;
  171. +     int af = 0;
  172.   
  173.       if (sockets == NULL)
  174.       sock_init();
  175. ***************
  176. *** 359,370 ****
  177.       return;
  178.       }
  179.       if ((long) sock->ops == _unix_proto_ops)
  180. !     printf("* (unix ");
  181.       else if (_inet_proto_ops != -1 && (long) sock->ops == _inet_proto_ops)
  182. !     printf("* (inet ");
  183. !     else
  184. !     printf("* (???? ");
  185.   
  186.       switch (sock->type) {
  187.       case SOCK_STREAM: printf("stream"); break;
  188.       case SOCK_DGRAM: printf("dgram"); break;
  189. --- 383,393 ----
  190.       return;
  191.       }
  192.       if ((long) sock->ops == _unix_proto_ops)
  193. !     af = AF_UNIX;
  194.       else if (_inet_proto_ops != -1 && (long) sock->ops == _inet_proto_ops)
  195. !     af = AF_INET;
  196.   
  197. +     printf("* (%s ", af_name[af]);
  198.       switch (sock->type) {
  199.       case SOCK_STREAM: printf("stream"); break;
  200.       case SOCK_DGRAM: printf("dgram"); break;
  201. ***************
  202. *** 374,380 ****
  203.       case SOCK_PACKET: printf("packet"); break;
  204.       default: printf("???");
  205.       }
  206. !     printf(" %x)\n", sock->flags);
  207.   }
  208.   
  209.   struct socket *
  210. --- 397,413 ----
  211.       case SOCK_PACKET: printf("packet"); break;
  212.       default: printf("???");
  213.       }
  214. !     printf(" %x", sock->flags);
  215. !     if (af == AF_INET) {
  216. !     struct sock sk;
  217. !     if (sock->data) {
  218. !         kmemread(&sk, sock->data, sizeof sk);
  219. !         printf(" %d", sk.num);
  220. !     }
  221. !     }
  222. !     printf(")\n");
  223.   }
  224.   
  225.   struct socket *
  226. ***************
  227. *** 465,471 ****
  228.   #if 0
  229.       end_mem = get_kword(k_addr("_high_memory"));
  230.   #else
  231. !     end_mem = k_addr("_end");
  232.   #endif
  233.       if (kbase == NULL) {
  234.       if ((kbase = (caddr_t) malloc(end_mem)) == NULL || ((long) kbase & 0xfff)) {
  235. --- 498,504 ----
  236.   #if 0
  237.       end_mem = get_kword(k_addr("_high_memory"));
  238.   #else
  239. !     end_mem = get_kword(k_addr("_memory_start"));
  240.   #endif
  241.       if (kbase == NULL) {
  242.       if ((kbase = (caddr_t) malloc(end_mem)) == NULL || ((long) kbase & 0xfff)) {
  243. diff -c +recursive ps-0.98/mmap.c ps/mmap.c
  244. *** ps-0.98/mmap.c    Wed Oct  7 12:10:27 1992
  245. --- ps/mmap.c    Sat Jan  2 22:57:38 1993
  246. ***************
  247. *** 1,11 ****
  248.   #define __LIBRARY__
  249. ! #include <unistd.h>
  250.   #include <sys/types.h>
  251.   #include <sys/mman.h>
  252.   
  253.   #define __NR__mmap __NR_mmap
  254. ! static inline
  255. ! _syscall1(caddr_t,_mmap,unsigned long *,buffer);
  256.   
  257.   caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
  258.   {
  259. --- 1,10 ----
  260.   #define __LIBRARY__
  261. ! #include <linux/unistd.h>
  262.   #include <sys/types.h>
  263.   #include <sys/mman.h>
  264.   
  265.   #define __NR__mmap __NR_mmap
  266. ! static inline _syscall1(caddr_t,_mmap,unsigned long *,buffer);
  267.   
  268.   caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
  269.   {
  270. ***************
  271. *** 21,23 ****
  272. --- 20,24 ----
  273.   }
  274.   
  275.   _syscall2(int,munmap, caddr_t,addr, size_t,len)
  276. diff -c +recursive ps-0.98/top.c ps/top.c
  277. *** ps-0.98/top.c    Sat Jan  2 23:00:48 1993
  278. --- ps/top.c    Sat Jan  2 22:42:58 1993
  279. ***************
  280. *** 50,56 ****
  281.   /* some dummy variables to get cmdline.c to link */
  282.   int kern_comm=0;
  283.   int show_env=0;
  284. ! int idle,freemem;
  285.   char hdr[200];
  286.   char *title="TOP   by Roger Binns    Ps (c) 1992 Branko Lankester";
  287.   
  288. --- 50,56 ----
  289.   /* some dummy variables to get cmdline.c to link */
  290.   int kern_comm=0;
  291.   int show_env=0;
  292. ! int top_idle, freemem;
  293.   char hdr[200];
  294.   char *title="TOP   by Roger Binns    Ps (c) 1992 Branko Lankester";
  295.   
  296. ***************
  297. *** 246,260 ****
  298.           interval = -jiffies;
  299.           jiffies = get_kword(_jiffies);
  300.           interval += jiffies;
  301. !         idle=freemem=1000;
  302.           show_procs();
  303.           outstr[0]=0;
  304.           sort_vals();
  305. !         if(idle<0) idle=0;
  306.           freemem = (get_kword(_nr_free_pages) + get_kword(_nr_buffers)*4)
  307.               * 100 / pages;
  308.           if(freemem<0) freemem=0;
  309. !         printf("%s%2d%% idle, %2d%% free core - sorted by %s", tgoto(cm,0,3), idle/10, freemem/10, corm?"CPU use    ":"Memory use "); /* can't have two tgoto's - they use a static buffer */
  310.           kmemread(av, _aver, sizeof av);
  311.           for (i=0; i<3; ++i) {
  312.           av[i] *= 100;
  313. --- 246,260 ----
  314.           interval = -jiffies;
  315.           jiffies = get_kword(_jiffies);
  316.           interval += jiffies;
  317. !         top_idle=freemem=1000;
  318.           show_procs();
  319.           outstr[0]=0;
  320.           sort_vals();
  321. !         if(top_idle<0) top_idle=0;
  322.           freemem = (get_kword(_nr_free_pages) + get_kword(_nr_buffers)*4)
  323.               * 100 / pages;
  324.           if(freemem<0) freemem=0;
  325. !         printf("%s%2d%% top_idle, %2d%% free core - sorted by %s", tgoto(cm,0,3), top_idle/10, freemem/10, corm?"CPU use    ":"Memory use "); /* can't have two tgoto's - they use a static buffer */
  326.           kmemread(av, _aver, sizeof av);
  327.           for (i=0; i<3; ++i) {
  328.           av[i] *= 100;
  329. ***************
  330. *** 476,482 ****
  331.       else
  332.           pmem = task->rss * 1000 / (main_mem / 4096);
  333.       if(pcpu>999) pcpu=999;
  334. !     idle-=pcpu;
  335.       freemem-=pmem;
  336.       if(corm) vals[num]=(pcpu<<8) + 256 - task->counter;
  337.       else vals[num]=pmem;
  338. --- 476,482 ----
  339.       else
  340.           pmem = task->rss * 1000 / (main_mem / 4096);
  341.       if(pcpu>999) pcpu=999;
  342. !     top_idle-=pcpu;
  343.       freemem-=pmem;
  344.       if(corm) vals[num]=(pcpu<<8) + 256 - task->counter;
  345.       else vals[num]=pmem;
  346. diff -c +recursive ps-0.98/w.c ps/w.c
  347. *** ps-0.98/w.c    Tue Oct 13 00:53:21 1992
  348. --- ps/w.c    Sat Jan  2 22:35:51 1993
  349. ***************
  350. *** 72,82 ****
  351.   
  352.   #define    proc    task_struct
  353.   
  354. ! #ifndef    UT_NAMESIZE
  355.   #define    UT_NAMESIZE    8
  356.   #define    UT_LINESIZE    12
  357.   #define    UT_HOSTSIZE    16
  358. ! #endif
  359.   #ifndef    _PATH_UTMP
  360.   #define    _PATH_UTMP    UTMP_FILE
  361.   #endif
  362. --- 72,82 ----
  363.   
  364.   #define    proc    task_struct
  365.   
  366. ! /*#ifndef    UT_NAMESIZE*/
  367.   #define    UT_NAMESIZE    8
  368.   #define    UT_LINESIZE    12
  369.   #define    UT_HOSTSIZE    16
  370. ! /*#endif*/
  371.   #ifndef    _PATH_UTMP
  372.   #define    _PATH_UTMP    UTMP_FILE
  373.   #endif
  374.  
  375.  
  376. -- 
  377. -------------------------------------------------------------------------------
  378.  * Andrew J. Cosgriff ! *                   #include <std_witty_quote.h>
  379. #define HERE cc.monash.edu.au               #include <std_disclaimer.h>
  380. Hassle me at :      andrewc@aurora.HERE ; andrewc@lindblat.HERE ; cos@yoyo.HERE
  381.