home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / linux / 10355 < prev    next >
Encoding:
Text File  |  1992-09-09  |  2.8 KB  |  108 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!van-bc!stewart
  3. From: stewart@wimsey.bc.ca (Jim Stewart)
  4. Subject: Re: free on ps097pl4 doesn't know about my swap
  5. Organization: Wimsey 
  6. Date: Thu, 10 Sep 1992 10:46:43 GMT
  7. Message-ID: <BuCz9w.39r@wimsey.bc.ca>
  8. References: <1992Sep8.230047.24913@klaava.Helsinki.FI> <pgr.084107.09Sep1992@prg.ox.ac.uk> <1992Sep9.092025.4018@monu6.cc.monash.edu.au>
  9. Lines: 97
  10.  
  11. In article <1992Sep9.092025.4018@monu6.cc.monash.edu.au> int177c@aurora.cc.monash.edu.au (Jae Won) writes:
  12. >Hi.
  13. >
  14. >    I have been using 0.97 pl4...wonderful stuff. Anyway, I have installed...or
  15. >copied the binaries of ps for the new patch and it seems to be working pretty
  16. >well. The ps recognizes the swap partition but free doesn't seem to.
  17. >    How can I fix this?
  18.  
  19. Here is a midnight patch to free that works with at lease one swapfile :-)
  20. .. sorry, it is normal diff, I don't know how to get RCS to do anything
  21.    fancier...
  22.  
  23. js who_is_NOT_proud_of_this_code_but_needs_to_watch_his_swapspace
  24.  
  25. ------------Cut---------------------------------------------------
  26.  
  27. 9a10,11
  28. > #define MAX_SWAPFILES 8     /* js 1 */
  29. > #define SWP_USED 1
  30. 27c29
  31. < unsigned long swap_bm;
  32. ---
  33. > unsigned long nr_swapfiles; /* js 1 */
  34. 71c73
  35. <     swap_bm = /* get_kword(k_addr("_swap_bitmap"));  */ 0;
  36. ---
  37. >     nr_swapfiles = get_kword(k_addr("_nr_swapfiles"));
  38. 75c77
  39. <     swap = (swap_bm != 0);
  40. ---
  41. >     swap = (nr_swapfiles != 0);
  42. 81c83
  43. <     if (swap && swap_bm)
  44. ---
  45. >     if (swap && nr_swapfiles)
  46. 157a160,172
  47. > struct swap_info_struct {       /* this is stolen ftom the kernel source */
  48. >         unsigned long flags;
  49. >         struct inode * swap_file;
  50. >         unsigned int swap_device;
  51. >         unsigned char * swap_map;
  52. >         char * swap_lockmap;
  53. >         int lowest_bit;
  54. >         int highest_bit;
  55. > }swap_info[MAX_SWAPFILES];
  56. 161c176
  57. <     int i;
  58. ---
  59. >     int i,f;
  60. 164c179
  61. <     printf("swap:   ");
  62. ---
  63. >     kmemread(swap_info,k_addr("_swap_info"),sizeof(swap_info));
  64. 166,174c181,191
  65. <     if (swap_bm == 0)
  66. <     printf("No swap device.\n");
  67. <     else {
  68. <     freepg = 0;
  69. <     kmemread(bitmap, swap_bm, 4096);
  70. <     for (i = 0; i < SWAP_BITS; ++i)
  71. <         freepg += bit(bitmap, i);
  72. <     if (swap_total != 0) {
  73. ---
  74. >     for (f = 0 ; f < MAX_SWAPFILES ; f++)
  75. >       if (swap_info[f].flags & SWP_USED)
  76. >     {
  77. >       printf("swap:%1d  ",f);
  78. >       freepg = 0;
  79. >       kmemread(bitmap, (swap_info[f].swap_map), 4096);
  80. >       for (i = swap_info[f].lowest_bit; i < swap_info[f].highest_bit ; ++i)
  81. >         freepg += (bitmap[i] == 0);
  82. >       
  83. >       if (swap_total != 0) {
  84. 176,178c193,195
  85. <         swap_total << pg_shift,
  86. <         swap_total - freepg << pg_shift);
  87. <     } else
  88. ---
  89. >            swap_total << pg_shift,
  90. >            swap_total - freepg << pg_shift);
  91. >       } else
  92. 181,183c198,201
  93. <     printf("%10d\n", freepg << pg_shift);
  94. <     }
  95. < }
  96. ---
  97. >       printf("%10d\n", freepg << pg_shift);
  98. >     }
  99. >   }
  100.  
  101.