wok view hardinfo/stuff/boots.patch @ rev 694

hardinfo: fix boots & languages
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 26 09:24:27 2008 +0000 (2008-04-26)
parents
children 3220c33df33d
line source
1 --- arch/linux/common/boots.h 2008-04-26 10:38:31.000000000 +0200
2 +++ arch/linux/common/boots.h 2008-04-26 11:15:20.000000000 +0200
3 @@ -16,11 +16,17 @@
4 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
5 */
7 +#include <sys/sysinfo.h>
8 +#include <sys/utsname.h>
9 +
10 void
11 scan_boots_real(void)
12 {
13 - FILE *last;
14 - char buffer[256];
15 + struct sysinfo info;
16 + struct utsname uname_info;
17 + time_t now;
18 + char date[40];
19 + int i;
21 scan_os(FALSE);
23 @@ -29,33 +35,13 @@
24 else
25 return;
27 - last = popen("last", "r");
28 - if (last) {
29 - while (fgets(buffer, 256, last)) {
30 - if (strstr(buffer, "system boot")) {
31 - gchar **tmp, *buf = buffer;
32 -
33 - strend(buffer, '\n');
34 -
35 - while (*buf) {
36 - if (*buf == ' ' && *(buf + 1) == ' ') {
37 - strcpy(buf, buf + 1);
38 -
39 - buf--;
40 - } else {
41 - buf++;
42 - }
43 - }
44 -
45 - tmp = g_strsplit(buffer, " ", 5);
46 - computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
47 - computer->os->boots,
48 - tmp[4],
49 - tmp[3]);
50 - g_strfreev(tmp);
51 - }
52 - }
53 -
54 - pclose(last);
55 - }
56 + time(&now);
57 + sysinfo(&info);
58 + uname(&uname_info);
59 + now -= info.uptime;
60 + strcpy(date,ctime(&now));
61 + for (i = 0; date[i] >= ' '; i++);
62 + date[i] = 0;
63 + computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
64 + computer->os->boots, date, uname_info.release);
65 }