diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-09-10 16:10:41 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-09-10 16:10:41 +0000 |
| commit | 8c1b0e80c845e28f2ccd6efafd82f09879e796f8 (patch) | |
| tree | 33945d4d5824736ea2f36d742bb145a24d0d3386 | |
| parent | 5cbb66bf6530d77978a9ce154177ed7e018b73bf (diff) | |
| download | busybox-w32-8c1b0e80c845e28f2ccd6efafd82f09879e796f8.tar.gz busybox-w32-8c1b0e80c845e28f2ccd6efafd82f09879e796f8.tar.bz2 busybox-w32-8c1b0e80c845e28f2ccd6efafd82f09879e796f8.zip | |
Update free for current 2.4.x behavior...
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@1027 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | free.c | 34 | ||||
| -rw-r--r-- | procps/free.c | 34 |
2 files changed, 26 insertions, 42 deletions
| @@ -29,29 +29,21 @@ extern int free_main(int argc, char **argv) | |||
| 29 | { | 29 | { |
| 30 | struct sysinfo info; | 30 | struct sysinfo info; |
| 31 | sysinfo(&info); | 31 | sysinfo(&info); |
| 32 | /* Kernels prior to 2.4.x will return info.mem_unit==0. Kernels after | 32 | |
| 33 | * 2.4.x actually fill this value in */ | 33 | /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */ |
| 34 | if (info.mem_unit==0) { | 34 | if (info.mem_unit==0) { |
| 35 | /* Looks like we have a kernel prior to Linux 2.4.x */ | 35 | info.mem_unit=1; |
| 36 | info.mem_unit=1024; | ||
| 37 | info.totalram/=info.mem_unit; | ||
| 38 | info.freeram/=info.mem_unit; | ||
| 39 | info.totalswap/=info.mem_unit; | ||
| 40 | info.freeswap/=info.mem_unit; | ||
| 41 | info.sharedram/=info.mem_unit; | ||
| 42 | info.bufferram/=info.mem_unit; | ||
| 43 | } else { | ||
| 44 | /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory | ||
| 45 | overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap | ||
| 46 | on an embedded system? */ | ||
| 47 | info.mem_unit/=1024; | ||
| 48 | info.totalram*=info.mem_unit; | ||
| 49 | info.freeram*=info.mem_unit; | ||
| 50 | info.totalswap*=info.mem_unit; | ||
| 51 | info.freeswap*=info.mem_unit; | ||
| 52 | info.sharedram*=info.mem_unit; | ||
| 53 | info.bufferram*=info.mem_unit; | ||
| 54 | } | 36 | } |
| 37 | info.mem_unit*=1024; | ||
| 38 | |||
| 39 | /* TODO: Make all this stuff not overflow when mem >= 4 Gib */ | ||
| 40 | info.totalram/=info.mem_unit; | ||
| 41 | info.freeram/=info.mem_unit; | ||
| 42 | info.totalswap/=info.mem_unit; | ||
| 43 | info.freeswap/=info.mem_unit; | ||
| 44 | info.sharedram/=info.mem_unit; | ||
| 45 | info.bufferram/=info.mem_unit; | ||
| 46 | |||
| 55 | if (argc > 1 && **(argv + 1) == '-') | 47 | if (argc > 1 && **(argv + 1) == '-') |
| 56 | usage(free_usage); | 48 | usage(free_usage); |
| 57 | 49 | ||
diff --git a/procps/free.c b/procps/free.c index 78298cfb6..d8c3f0b91 100644 --- a/procps/free.c +++ b/procps/free.c | |||
| @@ -29,29 +29,21 @@ extern int free_main(int argc, char **argv) | |||
| 29 | { | 29 | { |
| 30 | struct sysinfo info; | 30 | struct sysinfo info; |
| 31 | sysinfo(&info); | 31 | sysinfo(&info); |
| 32 | /* Kernels prior to 2.4.x will return info.mem_unit==0. Kernels after | 32 | |
| 33 | * 2.4.x actually fill this value in */ | 33 | /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */ |
| 34 | if (info.mem_unit==0) { | 34 | if (info.mem_unit==0) { |
| 35 | /* Looks like we have a kernel prior to Linux 2.4.x */ | 35 | info.mem_unit=1; |
| 36 | info.mem_unit=1024; | ||
| 37 | info.totalram/=info.mem_unit; | ||
| 38 | info.freeram/=info.mem_unit; | ||
| 39 | info.totalswap/=info.mem_unit; | ||
| 40 | info.freeswap/=info.mem_unit; | ||
| 41 | info.sharedram/=info.mem_unit; | ||
| 42 | info.bufferram/=info.mem_unit; | ||
| 43 | } else { | ||
| 44 | /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory | ||
| 45 | overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap | ||
| 46 | on an embedded system? */ | ||
| 47 | info.mem_unit/=1024; | ||
| 48 | info.totalram*=info.mem_unit; | ||
| 49 | info.freeram*=info.mem_unit; | ||
| 50 | info.totalswap*=info.mem_unit; | ||
| 51 | info.freeswap*=info.mem_unit; | ||
| 52 | info.sharedram*=info.mem_unit; | ||
| 53 | info.bufferram*=info.mem_unit; | ||
| 54 | } | 36 | } |
| 37 | info.mem_unit*=1024; | ||
| 38 | |||
| 39 | /* TODO: Make all this stuff not overflow when mem >= 4 Gib */ | ||
| 40 | info.totalram/=info.mem_unit; | ||
| 41 | info.freeram/=info.mem_unit; | ||
| 42 | info.totalswap/=info.mem_unit; | ||
| 43 | info.freeswap/=info.mem_unit; | ||
| 44 | info.sharedram/=info.mem_unit; | ||
| 45 | info.bufferram/=info.mem_unit; | ||
| 46 | |||
| 55 | if (argc > 1 && **(argv + 1) == '-') | 47 | if (argc > 1 && **(argv + 1) == '-') |
| 56 | usage(free_usage); | 48 | usage(free_usage); |
| 57 | 49 | ||
