wok-4.x diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/hardinfo/stuff/boots.patch	Sat Apr 26 09:24:27 2008 +0000
     1.3 @@ -0,0 +1,65 @@
     1.4 +--- arch/linux/common/boots.h	2008-04-26 10:38:31.000000000 +0200
     1.5 ++++ arch/linux/common/boots.h	2008-04-26 11:15:20.000000000 +0200
     1.6 +@@ -16,11 +16,17 @@
     1.7 +  *    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
     1.8 +  */
     1.9 + 
    1.10 ++#include <sys/sysinfo.h>
    1.11 ++#include <sys/utsname.h>
    1.12 ++
    1.13 + void
    1.14 + scan_boots_real(void)
    1.15 + {
    1.16 +-    FILE *last;
    1.17 +-    char buffer[256];
    1.18 ++    struct sysinfo info;
    1.19 ++    struct utsname uname_info;
    1.20 ++    time_t now;
    1.21 ++    char date[40];
    1.22 ++    int i;
    1.23 + 
    1.24 +     scan_os(FALSE);
    1.25 + 
    1.26 +@@ -29,33 +35,13 @@
    1.27 +     else
    1.28 +       return;
    1.29 +     
    1.30 +-    last = popen("last", "r");
    1.31 +-    if (last) {
    1.32 +-      while (fgets(buffer, 256, last)) {
    1.33 +-        if (strstr(buffer, "system boot")) {
    1.34 +-          gchar **tmp, *buf = buffer;
    1.35 +-          
    1.36 +-          strend(buffer, '\n');
    1.37 +-          
    1.38 +-          while (*buf) {
    1.39 +-            if (*buf == ' ' && *(buf + 1) == ' ') {
    1.40 +-              strcpy(buf, buf + 1);
    1.41 +-              
    1.42 +-              buf--;
    1.43 +-            } else {
    1.44 +-              buf++;
    1.45 +-            }
    1.46 +-          }
    1.47 +-
    1.48 +-          tmp = g_strsplit(buffer, " ", 5);
    1.49 +-          computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
    1.50 +-                                                computer->os->boots,
    1.51 +-                                                tmp[4],
    1.52 +-                                                tmp[3]);
    1.53 +-          g_strfreev(tmp);
    1.54 +-        }
    1.55 +-      }
    1.56 +-      
    1.57 +-      pclose(last);
    1.58 +-    }
    1.59 ++    time(&now);
    1.60 ++    sysinfo(&info);
    1.61 ++    uname(&uname_info);
    1.62 ++    now -= info.uptime;
    1.63 ++    strcpy(date,ctime(&now));
    1.64 ++    for (i = 0; date[i] >= ' '; i++);
    1.65 ++    date[i] = 0;
    1.66 ++    computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
    1.67 ++		computer->os->boots, date, uname_info.release);
    1.68 + }