Make init handle current 2.4.x sysinfo behavior
authorEric Andersen <andersen@codepoet.org>
Sun, 10 Sep 2000 16:13:41 +0000 (16:13 -0000)
committerEric Andersen <andersen@codepoet.org>
Sun, 10 Sep 2000 16:13:41 +0000 (16:13 -0000)
 -Erik

init.c
init/init.c

diff --git a/init.c b/init.c
index 91a72550bc0d4590b41d3e649ef1a638d5e00a73..b532ea88ff7edcffe0174d17d565ad53c7b07643 100644 (file)
--- a/init.c
+++ b/init.c
@@ -296,20 +296,17 @@ static int check_free_memory()
                printf("Error checking free memory: %s\n", strerror(errno));
                return -1;
        }
+       /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */
        if (info.mem_unit==0) {
-               /* Looks like we have a kernel prior to Linux 2.4.x */
-               info.mem_unit=1024;
-               info.totalram/=info.mem_unit;
-               info.totalswap/=info.mem_unit;
-       } else {
-               /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory
-               overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap
-               on an embedded system? */
-               info.mem_unit/=1024;
-               info.totalram*=info.mem_unit;
-               info.totalswap*=info.mem_unit;
+               info.mem_unit=1;
        }
-
+       info.mem_unit*=1024;
+       
+       /* Note:  These values can in theory overflow a 32 bit unsigned long (i.e.
+        * mem >=  Gib), but who puts more then 4GiB ram+swap on an embedded
+        * system? */
+       info.totalram/=info.mem_unit; 
+       info.totalswap/=info.mem_unit;
        return(info.totalram+info.totalswap);
 }
 
index 91a72550bc0d4590b41d3e649ef1a638d5e00a73..b532ea88ff7edcffe0174d17d565ad53c7b07643 100644 (file)
@@ -296,20 +296,17 @@ static int check_free_memory()
                printf("Error checking free memory: %s\n", strerror(errno));
                return -1;
        }
+       /* Kernels prior to 2.4.x will return info.mem_unit==0, so cope... */
        if (info.mem_unit==0) {
-               /* Looks like we have a kernel prior to Linux 2.4.x */
-               info.mem_unit=1024;
-               info.totalram/=info.mem_unit;
-               info.totalswap/=info.mem_unit;
-       } else {
-               /* Bah. Linux 2.4.x completely changed sysinfo. This can in theory
-               overflow a 32 bit unsigned long, but who puts more then 4GiB ram+swap
-               on an embedded system? */
-               info.mem_unit/=1024;
-               info.totalram*=info.mem_unit;
-               info.totalswap*=info.mem_unit;
+               info.mem_unit=1;
        }
-
+       info.mem_unit*=1024;
+       
+       /* Note:  These values can in theory overflow a 32 bit unsigned long (i.e.
+        * mem >=  Gib), but who puts more then 4GiB ram+swap on an embedded
+        * system? */
+       info.totalram/=info.mem_unit; 
+       info.totalswap/=info.mem_unit;
        return(info.totalram+info.totalswap);
 }