home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!van-bc!stewart
- From: stewart@wimsey.bc.ca (Jim Stewart)
- Subject: Re: free on ps097pl4 doesn't know about my swap
- Organization: Wimsey
- Date: Thu, 10 Sep 1992 10:46:43 GMT
- Message-ID: <BuCz9w.39r@wimsey.bc.ca>
- References: <1992Sep8.230047.24913@klaava.Helsinki.FI> <pgr.084107.09Sep1992@prg.ox.ac.uk> <1992Sep9.092025.4018@monu6.cc.monash.edu.au>
- Lines: 97
-
- In article <1992Sep9.092025.4018@monu6.cc.monash.edu.au> int177c@aurora.cc.monash.edu.au (Jae Won) writes:
- >Hi.
- >
- > I have been using 0.97 pl4...wonderful stuff. Anyway, I have installed...or
- >copied the binaries of ps for the new patch and it seems to be working pretty
- >well. The ps recognizes the swap partition but free doesn't seem to.
- > How can I fix this?
-
- Here is a midnight patch to free that works with at lease one swapfile :-)
- .. sorry, it is normal diff, I don't know how to get RCS to do anything
- fancier...
-
- js who_is_NOT_proud_of_this_code_but_needs_to_watch_his_swapspace
-
- ------------Cut---------------------------------------------------
-
- 9a10,11
- > #define MAX_SWAPFILES 8 /* js 1 */
- > #define SWP_USED 1
- 27c29
- < unsigned long swap_bm;
- ---
- > unsigned long nr_swapfiles; /* js 1 */
- 71c73
- < swap_bm = /* get_kword(k_addr("_swap_bitmap")); */ 0;
- ---
- > nr_swapfiles = get_kword(k_addr("_nr_swapfiles"));
- 75c77
- < swap = (swap_bm != 0);
- ---
- > swap = (nr_swapfiles != 0);
- 81c83
- < if (swap && swap_bm)
- ---
- > if (swap && nr_swapfiles)
- 157a160,172
- >
- > struct swap_info_struct { /* this is stolen ftom the kernel source */
- > unsigned long flags;
- > struct inode * swap_file;
- > unsigned int swap_device;
- > unsigned char * swap_map;
- > char * swap_lockmap;
- > int lowest_bit;
- > int highest_bit;
- > }swap_info[MAX_SWAPFILES];
- >
- >
- >
- 161c176
- < int i;
- ---
- > int i,f;
- 164c179
- < printf("swap: ");
- ---
- > kmemread(swap_info,k_addr("_swap_info"),sizeof(swap_info));
- 166,174c181,191
- < if (swap_bm == 0)
- < printf("No swap device.\n");
- < else {
- < freepg = 0;
- < kmemread(bitmap, swap_bm, 4096);
- < for (i = 0; i < SWAP_BITS; ++i)
- < freepg += bit(bitmap, i);
- <
- < if (swap_total != 0) {
- ---
- > for (f = 0 ; f < MAX_SWAPFILES ; f++)
- > if (swap_info[f].flags & SWP_USED)
- > {
- > printf("swap:%1d ",f);
- >
- > freepg = 0;
- > kmemread(bitmap, (swap_info[f].swap_map), 4096);
- > for (i = swap_info[f].lowest_bit; i < swap_info[f].highest_bit ; ++i)
- > freepg += (bitmap[i] == 0);
- >
- > if (swap_total != 0) {
- 176,178c193,195
- < swap_total << pg_shift,
- < swap_total - freepg << pg_shift);
- < } else
- ---
- > swap_total << pg_shift,
- > swap_total - freepg << pg_shift);
- > } else
- 181,183c198,201
- < printf("%10d\n", freepg << pg_shift);
- < }
- < }
- ---
- > printf("%10d\n", freepg << pg_shift);
- > }
- > }
- >
-
-