wok-6.x view hardinfo/stuff/boots.patch @ rev 17149
slitaz-configs-base: fix Slim Root Login.(/rootfs/root/.xinitrc)
author | Xander Ziiryanoff <psychomaniak@xakep.ru> |
---|---|
date | Wed Sep 10 16:16:18 2014 +0200 (2014-09-10) |
parents | c5069bc9ff25 |
children |
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,19 @@
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 + FILE *dev;
16 + char buffer[2048];
17 + struct sysinfo info;
18 + struct utsname uname_info;
19 + time_t now;
20 + char date[40];
21 + int i;
23 scan_os(FALSE);
25 @@ -29,33 +37,20 @@
26 else
27 return;
29 - last = popen("last", "r");
30 - if (last) {
31 - while (fgets(buffer, 256, last)) {
32 - if (strstr(buffer, "system boot")) {
33 - gchar **tmp, *buf = buffer;
34 -
35 - strend(buffer, '\n');
36 -
37 - while (*buf) {
38 - if (*buf == ' ' && *(buf + 1) == ' ') {
39 - strcpy(buf, buf + 1);
40 -
41 - buf--;
42 - } else {
43 - buf++;
44 - }
45 - }
46 -
47 - tmp = g_strsplit(buffer, " ", 5);
48 - computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
49 - computer->os->boots,
50 - tmp[4],
51 - tmp[3]);
52 - g_strfreev(tmp);
53 - }
54 - }
55 -
56 - pclose(last);
57 - }
58 + time(&now);
59 + sysinfo(&info);
60 + uname(&uname_info);
61 + now -= info.uptime;
62 + strcpy(date,ctime(&now));
63 + for (i = 0; date[i] >= ' '; i++);
64 + date[i] = 0;
65 + computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
66 + computer->os->boots, date, uname_info.release);
67 + dev = fopen("/proc/cmdline", "r");
68 + if (!dev)
69 + return;
70 + if (fgets(buffer, sizeof(buffer), dev))
71 + computer->os->boots = h_strdup_cprintf("\nBoot options=%s",
72 + computer->os->boots, buffer);
73 + fclose(dev);
74 }