[BusyBox-cvs] busybox/procps free.c,1.18,1.19

Erik Andersen andersen at codepoet.org
Sat Jan 11 20:40:23 UTC 2003


Update of /var/cvs/busybox/procps
In directory winder:/tmp/cvs-serv8815

Modified Files:
	free.c 
Log Message:
Patch from Daniel J Walsh at redhat to make free work for systems 
with more than 1 GB of memory...


Index: free.c
===================================================================
RCS file: /var/cvs/busybox/procps/free.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- free.c	24 Oct 2001 05:00:00 -0000	1.18
+++ free.c	11 Jan 2003 20:40:20 -0000	1.19
@@ -37,15 +37,30 @@
 	if (info.mem_unit==0) {
 		info.mem_unit=1;
 	}
-	info.mem_unit*=1024;
-	
-	/* TODO:  Make all this stuff not overflow when mem >= 4 Gib */
-	info.totalram/=info.mem_unit;
-	info.freeram/=info.mem_unit;
-	info.totalswap/=info.mem_unit;
-	info.freeswap/=info.mem_unit;
-	info.sharedram/=info.mem_unit;
-	info.bufferram/=info.mem_unit;
+	if ( info.mem_unit == 1 ) {
+		info.mem_unit=1024;
+
+		/* TODO:  Make all this stuff not overflow when mem >= 4 Gib */
+		info.totalram/=info.mem_unit;
+		info.freeram/=info.mem_unit;
+#ifndef __uClinux__
+		info.totalswap/=info.mem_unit;
+		info.freeswap/=info.mem_unit;
+#endif
+		info.sharedram/=info.mem_unit;
+		info.bufferram/=info.mem_unit;
+	} else {
+		info.mem_unit/=1024;
+		/* TODO:  Make all this stuff not overflow when mem >= 4 Gib */
+		info.totalram*=info.mem_unit;
+		info.freeram*=info.mem_unit;
+#ifndef __uClinux__
+		info.totalswap*=info.mem_unit;
+		info.freeswap*=info.mem_unit;
+#endif
+		info.sharedram*=info.mem_unit;
+		info.bufferram*=info.mem_unit;
+	}
 
 	if (argc > 1 && **(argv + 1) == '-')
 		show_usage();
@@ -57,13 +72,14 @@
 			info.totalram-info.freeram, info.freeram, 
 			info.sharedram, info.bufferram);
 
+#ifndef __uClinux__
 	printf("%6s%13ld%13ld%13ld\n", "Swap:", info.totalswap,
 			info.totalswap-info.freeswap, info.freeswap);
 
 	printf("%6s%13ld%13ld%13ld\n", "Total:", info.totalram+info.totalswap,
 			(info.totalram-info.freeram)+(info.totalswap-info.freeswap),
 			info.freeram+info.freeswap);
+#endif
 	return EXIT_SUCCESS;
 }
-
 




More information about the busybox-cvs mailing list