Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 69 lines (58 sloc) 1.822 kB
e49d5ec Some formatting updates (ran the code through indent)
Erik Andersen authored
1 /* vi: set sw=4 ts=4: */
abc0f4f Latest and greatest
Eric Andersen authored
2 /*
3 * Mini free implementation for busybox
4 *
c7bda1c Remove trailing whitespace. Update copyright to include 2004.
Eric Andersen authored
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
abc0f4f Latest and greatest
Eric Andersen authored
6 *
e9a7a62 @landley Change license statements (and clean up headers) on some of the files…
landley authored
7 * Licensed under the GPL version 2, see the file LICENSE in this tarball.
abc0f4f Latest and greatest
Eric Andersen authored
8 */
9
827e45c Added some more '/* getopt not needed */' lines.
Mark Whitley authored
10 /* getopt not needed */
11
b6adbf1 usage.c: remove reference to busybox.h
Denis Vlasenko authored
12 #include "libbb.h"
10dc9d4 Updates to handle Linux 2.4.0 kernels (kludged around the "none" entr…
Eric Andersen authored
13
9b49a5e add -fvisibility=hidden to CC flags, mark XXX_main functions
Denis Vlasenko authored
14 int free_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
2ec91ae *: remove some uses of argc
Denys Vlasenko authored
15 int free_main(int argc UNUSED_PARAM, char **argv)
abc0f4f Latest and greatest
Eric Andersen authored
16 {
d07ee46 Removed proc dependancies for init and free (which maintaining exactly
Erik Andersen authored
17 struct sysinfo info;
18 sysinfo(&info);
73de656 Update free for current 2.4.x behavior...
Eric Andersen authored
19
20 /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */
219d14d random style fixes (extra spaces deleted)
Denis Vlasenko authored
21 if (info.mem_unit == 0) {
73de656 Update free for current 2.4.x behavior...
Eric Andersen authored
22 info.mem_unit=1;
10dc9d4 Updates to handle Linux 2.4.0 kernels (kludged around the "none" entr…
Eric Andersen authored
23 }
219d14d random style fixes (extra spaces deleted)
Denis Vlasenko authored
24 if (info.mem_unit == 1) {
1dcf218 Patch from Daniel J Walsh at redhat to make free work for systems
Eric Andersen authored
25 info.mem_unit=1024;
26
27 /* TODO: Make all this stuff not overflow when mem >= 4 Gib */
28 info.totalram/=info.mem_unit;
29 info.freeram/=info.mem_unit;
30 #ifndef __uClinux__
31 info.totalswap/=info.mem_unit;
32 info.freeswap/=info.mem_unit;
33 #endif
34 info.sharedram/=info.mem_unit;
35 info.bufferram/=info.mem_unit;
36 } else {
37 info.mem_unit/=1024;
38 /* TODO: Make all this stuff not overflow when mem >= 4 Gib */
39 info.totalram*=info.mem_unit;
40 info.freeram*=info.mem_unit;
41 #ifndef __uClinux__
42 info.totalswap*=info.mem_unit;
43 info.freeswap*=info.mem_unit;
44 #endif
45 info.sharedram*=info.mem_unit;
46 info.bufferram*=info.mem_unit;
47 }
73de656 Update free for current 2.4.x behavior...
Eric Andersen authored
48
2ec91ae *: remove some uses of argc
Denys Vlasenko authored
49 if (argv[1] && argv[1][0] == '-')
cad5364 Major coreutils update.
Manuel Novoa III authored
50 bb_show_usage();
d07ee46 Removed proc dependancies for init and free (which maintaining exactly
Erik Andersen authored
51
c7bda1c Remove trailing whitespace. Update copyright to include 2004.
Eric Andersen authored
52 printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
d07ee46 Removed proc dependancies for init and free (which maintaining exactly
Erik Andersen authored
53 "shared", "buffers");
54
c7bda1c Remove trailing whitespace. Update copyright to include 2004.
Eric Andersen authored
55 printf("%6s%13ld%13ld%13ld%13ld%13ld\n", "Mem:", info.totalram,
56 info.totalram-info.freeram, info.freeram,
d07ee46 Removed proc dependancies for init and free (which maintaining exactly
Erik Andersen authored
57 info.sharedram, info.bufferram);
58
1dcf218 Patch from Daniel J Walsh at redhat to make free work for systems
Eric Andersen authored
59 #ifndef __uClinux__
d07ee46 Removed proc dependancies for init and free (which maintaining exactly
Erik Andersen authored
60 printf("%6s%13ld%13ld%13ld\n", "Swap:", info.totalswap,
61 info.totalswap-info.freeswap, info.freeswap);
e49d5ec Some formatting updates (ran the code through indent)
Erik Andersen authored
62
d07ee46 Removed proc dependancies for init and free (which maintaining exactly
Erik Andersen authored
63 printf("%6s%13ld%13ld%13ld\n", "Total:", info.totalram+info.totalswap,
64 (info.totalram-info.freeram)+(info.totalswap-info.freeswap),
65 info.freeram+info.freeswap);
1dcf218 Patch from Daniel J Walsh at redhat to make free work for systems
Eric Andersen authored
66 #endif
3e856ce Stop using TRUE and FALSE for exit status.
Matt Kraai authored
67 return EXIT_SUCCESS;
abc0f4f Latest and greatest
Eric Andersen authored
68 }
Something went wrong with that request. Please try again.