wok annotate 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
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@694 3 @@ -16,11 +16,17 @@
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@694 15 + struct sysinfo info;
pascal@694 16 + struct utsname uname_info;
pascal@694 17 + time_t now;
pascal@694 18 + char date[40];
pascal@694 19 + int i;
pascal@694 20
pascal@694 21 scan_os(FALSE);
pascal@694 22
pascal@694 23 @@ -29,33 +35,13 @@
pascal@694 24 else
pascal@694 25 return;
pascal@694 26
pascal@694 27 - last = popen("last", "r");
pascal@694 28 - if (last) {
pascal@694 29 - while (fgets(buffer, 256, last)) {
pascal@694 30 - if (strstr(buffer, "system boot")) {
pascal@694 31 - gchar **tmp, *buf = buffer;
pascal@694 32 -
pascal@694 33 - strend(buffer, '\n');
pascal@694 34 -
pascal@694 35 - while (*buf) {
pascal@694 36 - if (*buf == ' ' && *(buf + 1) == ' ') {
pascal@694 37 - strcpy(buf, buf + 1);
pascal@694 38 -
pascal@694 39 - buf--;
pascal@694 40 - } else {
pascal@694 41 - buf++;
pascal@694 42 - }
pascal@694 43 - }
pascal@694 44 -
pascal@694 45 - tmp = g_strsplit(buffer, " ", 5);
pascal@694 46 - computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
pascal@694 47 - computer->os->boots,
pascal@694 48 - tmp[4],
pascal@694 49 - tmp[3]);
pascal@694 50 - g_strfreev(tmp);
pascal@694 51 - }
pascal@694 52 - }
pascal@694 53 -
pascal@694 54 - pclose(last);
pascal@694 55 - }
pascal@694 56 + time(&now);
pascal@694 57 + sysinfo(&info);
pascal@694 58 + uname(&uname_info);
pascal@694 59 + now -= info.uptime;
pascal@694 60 + strcpy(date,ctime(&now));
pascal@694 61 + for (i = 0; date[i] >= ' '; i++);
pascal@694 62 + date[i] = 0;
pascal@694 63 + computer->os->boots = h_strdup_cprintf("\n%s=Kernel %s",
pascal@694 64 + computer->os->boots, date, uname_info.release);
pascal@694 65 }