aboutsummaryrefslogtreecommitdiffstats
path: root/packages/gpe-conf/gpe-conf-0.1.20/meminfo26.patch
blob: b78a48d38a601f74d7cb383269d5eb5a093dc993 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Index: sysinfo.c
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/sysinfo.c,v
retrieving revision 1.19
diff -u -r1.19 sysinfo.c
--- sysinfo.c	8 Sep 2004 22:14:12 -0000	1.19
+++ sysinfo.c	25 Oct 2004 12:01:01 -0000
@@ -160,6 +160,7 @@
 get_device_info()
 {
 	t_deviceinfo result;
+	struct utsname uinfo;
 #ifdef __arm__	
 	char **strv;
 	int len = 0;
@@ -173,6 +174,8 @@
 	result.ram = 0;
 	result.flash = 0;
 
+	uname(&uinfo);
+	
 #ifdef __arm__
 	/* check mach type and model */
 	if (!access(P_IPAQ,F_OK))
@@ -235,6 +238,7 @@
 #endif
 #ifdef __i386__
 	result.cpu = g_strdup(_("Intel x86 or compatible"));
+	result.model = g_strdup_printf("%s, %s", _("IBM type PC"), uinfo.machine);
 #endif
 #ifdef __mips__
 	result.cpu = g_strdup(_("Mips"));
@@ -246,12 +250,13 @@
 	result.cpu = g_strdup(_("IBM Power or PowerPC"));
 #endif
 	if (!result.model)
-		result.model = g_strdup(MACHINE);
+		result.model = g_strdup_printf("%s (%s)", uinfo.machine, MACHINE);
 #endif
 	
 	/* memory and flash size */
+	
 	system_memory();
-	result.ram = meminfo.total / 1024 + 1;
+	result.ram = meminfo.total;
 	result.flash = get_flash_size();
 	return result;
 }
Index: storage.c
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/storage.c,v
retrieving revision 1.17
diff -u -r1.17 storage.c
--- storage.c	13 Sep 2004 12:00:01 -0000	1.17
+++ storage.c	25 Oct 2004 12:01:01 -0000
@@ -54,41 +54,32 @@
 	return FS_T_UNKNOWN;
 }
 
-/* from minisys */
 int
 system_memory (void)
 {
-	u_int64_t my_mem_used, my_mem_max;
-	u_int64_t my_swap_max;
+	unsigned long mem_free, mem_total;
 
-	static int mem_delay = 0;
 	FILE *mem;
-	static u_int64_t aa, ab, ac, ad, ae, af, ag, ah;
-	/* put this in permanent storage instead of stack */
-	static char not_needed[2048];
-	if (mem_delay-- <= 0)
+	static char line[255];
+	mem = fopen ("/proc/meminfo", "r");
+	if (mem)
 	{
-		mem = fopen ("/proc/meminfo", "r");
-		fgets (not_needed, 2048, mem);
-
-		fscanf (mem, "%*s %Ld %Ld %Ld %Ld %Ld %Ld", &aa, &ab, &ac,
-			&ad, &ae, &af);
-		fscanf (mem, "%*s %Ld %Ld", &ag, &ah);
+		while (fgets (line, 255, mem))
+		{	
+			if (g_str_has_prefix(line, "MemTotal"))
+				sscanf(line, "%*s %lu %*s", &mem_total);
+			else if (g_str_has_prefix(line, "MemFree"))
+			{
+				sscanf(line, "%*s %lu %*s", &mem_free);
+				break;
+			}
+		}
 		fclose (mem);
-		mem_delay = 25;
-
-		/* calculate it */
-		my_mem_max = aa;	/* memory.total; */
-		my_swap_max = ag;	/* swap.total; */
-
-		my_mem_used = ah + ab - af - ae;
-
-		meminfo.total = my_mem_max / 1024;
-		meminfo.used = my_mem_used / 1024;
-		meminfo.avail = (my_mem_max - my_mem_used) / 1024;
-		return 0;
+		meminfo.total = mem_total / 1024;
+		meminfo.used = (mem_total - mem_free) / 1024;
+		meminfo.avail = mem_free / 1024;
 	}
-	return 1;
+	return 0;
 }
 
 
@@ -183,13 +174,13 @@
     /* TRANSLATORS: MB == Mega Bytes*/
 		sprintf (cnew2, "%s: <i>%4.1f</i> %s", _("Free memory"),
 			 ((float) meminfo.total -
-			  (float) meminfo.used) / 1024.0, _("MB"));
+			  (float) meminfo.used), _("MB"));
 		gtk_label_set_markup (GTK_LABEL (meminfo.label3), cnew2);
 
 		fstr = g_strdup_printf ("%s%s %4.1f %s %s",
 					"<span foreground=\"black\">",
 					_("Total:"),
-					(float) meminfo.total / 1024.0,
+					(float) meminfo.total,
 					_("MB"), "</span>");
 		gtk_label_set_markup (GTK_LABEL (meminfo.label2), fstr);
 		g_free (fstr);
@@ -452,7 +443,7 @@
 					       (float) meminfo.total);
 		sprintf (cnew2, "%s: <i>%4.1f</i> %s", _("Free memory"),
 			 ((float) meminfo.total -
-			  (float) meminfo.used) / 1024.0, _("MB"));
+			  (float) meminfo.used), _("MB"));
 		label1 = gtk_label_new (NULL);
 		gtk_misc_set_alignment (GTK_MISC (label1), 0.0, 0.5);
 		meminfo.label3 = label1;
@@ -464,7 +455,7 @@
 		fstr = g_strdup_printf ("%s%s %4.1f %s %s",
 					"<span foreground=\"black\">",
 					_("Total:"),
-					(float) meminfo.total / 1024.0,
+					(float) meminfo.total,
 					_("MB"), "</span>");
 		gtk_label_set_markup (GTK_LABEL (label1), fstr);
 		g_free (fstr);