wok-6.x annotate hardinfo/stuff/boots.patch @ rev 16831

Add system-tools-backends, liboobs.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Jul 12 14:33:02 2014 +0300 (2014-07-12)
parents c5069bc9ff25
children
rev   line source
pascal@694 1 --- arch/linux/common/boots.h 2008-04-26 10:38:31.000000000 +0200
pascal@694 2 +++ arch/linux/common/boots.h 2008-04-26 11:15:20.000000000 +0200
pascal@695 3 @@ -16,11 +16,19 @@
pascal@694 4 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
pascal@694 5 */
pascal@694 6
pascal@694 7 +#include <sys/sysinfo.h>
pascal@694 8 +#include <sys/utsname.h>
pascal@694 9 +
pascal@694 10 void
pascal@694 11 scan_boots_real(void)
pascal@694 12 {
pascal@694 13 - FILE *last;
pascal@694 14 - char buffer[256];
pascal@695 15 + FILE *dev;
pascal@695 16 + char buffer[2048];
pascal@694 17 + struct sysinfo info;
pascal@694 18 + struct utsname uname_info;
pascal@694 19 + time_t now;
pascal@694 20 + char date[40];
pascal@694 21 + int i;
pascal@694 22
pascal@694 23 scan_os(FALSE);
pascal@694 24
pascal@695 25 @@ -29,33 +37,20 @@
pascal@694 26 else
pascal@694 27 return;
pascal@694 28
pascal@694 29 - last = popen("last", "r");
pascal@694 30 - if (last) {
pascal@694 31 - while (fgets(buffer, 256, last)) {
pascal@694 32 - if (strstr(buffer, "system boot")) {
pascal@694 33 - gchar **tmp, *buf = buffer;
pascal@694 34 -
pascal@694 35 - strend(buffer, '\n');
pascal@694 36 -
pascal@694 37 - while (*buf) {
pascal@694 38 - if (*buf == ' ' && *(buf + 1) == ' ') {
pascal@694 39 - strcpy(buf, buf + 1);
pascal@694 40 -
pascal@694 41 - buf--;
pascal@694 42 - } else {
pascal@694 43 - buf++;
pascal@694 44 - }
pascal@694 45 - }
pascal@694 46 -
pascal@694 47 - tmp = g_strsplit(buffer, " ", 5);
pascal@694 48 - computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
pascal@694 49 - computer->os->boots,
pascal@694 50 - tmp[4],
pascal@694 51 - tmp[3]);
pascal@694 52 - g_strfreev(tmp);
pascal@694 53 - }
pascal@694 54 - }
pascal@694 55 -
pascal@694 56 - pclose(last);
pascal@694 57 - }
pascal@694 58 + time(&now);
pascal@694 59 + sysinfo(&info);
pascal@694 60 + uname(&uname_info);
pascal@694 61 + now -= info.uptime;
pascal@694 62 + strcpy(date,ctime(&now));
pascal@694 63 + for (i = 0; date[i] >= ' '; i++);
pascal@694 64 + date[i] = 0;
pascal@694 65 + computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
pascal@694 66 + computer->os->boots, date, uname_info.release);
pascal@695 67 + dev = fopen("/proc/cmdline", "r");
pascal@695 68 + if (!dev)
pascal@695 69 + return;
pascal@695 70 + if (fgets(buffer, sizeof(buffer), dev))
pascal@695 71 + computer->os->boots = h_strdup_cprintf("\nBoot options=%s",
pascal@695 72 + computer->os->boots, buffer);
pascal@695 73 + fclose(dev);
pascal@694 74 }