File: 30_restore_pristine_code.patch

package info (click to toggle)
xsysinfo 1.7-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 264 kB
  • sloc: ansic: 2,152; makefile: 17
file content (55 lines) | stat: -rw-r--r-- 1,526 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From: Sandro Tosi <matrixhasu@gmail.com>
Subject: New patch generated from xsysinfo 1.7-7 diff.gz


--- a/sysinfo.c
+++ b/sysinfo.c
@@ -24,6 +24,7 @@
  
 #include "sysinfo.h"
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
 #include <fcntl.h>
@@ -35,12 +36,22 @@
 
 static char buffer[1024];
 
+/* reread rewritten by Ernst Kloppenburg <kloppen@isr.uni-stuttgart.de> */
+/* Now works with Linux 2.2 */
+
 static void reread( int fd, char *message )
 {
-	if ( lseek( fd, 0L, 0 ) == 0 &&
-	     read( fd, buffer, sizeof(buffer) - 1 ) > 0 )
-		return;
-       
+	int i;
+	int bytesread;
+
+	if ( lseek( fd, 0L, 0 ) == 0 ) {
+	     bytesread = read( fd, buffer, sizeof(buffer) - 1 );
+	     if ( bytesread < (sizeof(buffer) - 1) ) {
+		buffer[bytesread] = 0x0;
+                return;
+             }
+        }
+
 	perror(message);
 	exit(1);
 }
@@ -75,9 +86,12 @@
 
 	/* Try new /proc/meminfo format first */
 	*swapdevs = 1;
+	if ((result[0].shared = getentry("MemShared:", buffer)) < 0) {
+	    /* Linux 2.4 has MemShared (but it's always zero?), 2.6 doesn't */
+	    result[0].shared = 0;
+	}
 	if ((result[0].total   = getentry("MemTotal:", buffer))  < 0 ||
 	    (result[0].free    = getentry("MemFree:", buffer))   < 0 ||
-	    (result[0].shared  = getentry("MemShared:", buffer)) < 0 ||
 	    (result[0].buffers = getentry("Buffers:", buffer))   < 0 ||
 	    (result[0].cache   = getentry("Cached:", buffer))    < 0 ||
 	    (result[1].total   = getentry("SwapTotal:", buffer)) < 0 ||