]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-sysinfo.c
ui/ncurses: Add link status to system info & system config screens
[petitboot] / ui / ncurses / nc-sysinfo.c
index 4cba9a9c393cfaa9ac83b232d1c5ec55ffe72cbb..fb1954f44f0fc7d2ce498764a665e419089c9cf7 100644 (file)
@@ -127,28 +127,10 @@ static __attribute__((format(printf, 2, 3))) void sysinfo_screen_append_line(
        screen->n_lines++;
 }
 
-static void mac_str(struct interface_info *info, char *buf, unsigned int buflen)
+static void if_info_mac_str(struct interface_info *info,
+               char *buf, unsigned int buflen)
 {
-       unsigned int i;
-       char *pos;
-
-       assert(buflen > sizeof("unknown"));
-
-       if (!info->hwaddr_size || info->hwaddr_size * 3 + 1 > buflen) {
-               strcpy(buf, "unknown");
-               return;
-       }
-
-       pos = buf;
-
-       for (i = 0; i < info->hwaddr_size; i++) {
-               snprintf(pos, 4, "%02x:", info->hwaddr[i]);
-               pos += 3;
-       }
-
-       *(pos - 1) = '\0';
-
-       return;
+       return mac_str(info->hwaddr, info->hwaddr_size, buf, buflen);
 }
 
 static void sysinfo_screen_populate(struct sysinfo_screen *screen,
@@ -167,18 +149,34 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
        line("%-12s %s", "System type:", sysinfo->type ?: "");
        line("%-12s %s", "System id:",   sysinfo->identifier ?: "");
 
-       line(NULL);
-       if (sysinfo->n_interfaces)
+       if (sysinfo->n_blockdevs) {
+               line(NULL);
+               line("Storage devices");
+       }
+
+       for (i = 0; i < sysinfo->n_blockdevs; i++) {
+               struct blockdev_info *info = sysinfo->blockdevs[i];
+
+               line("%s:", info->name);
+               line(" UUID:       %s", info->uuid);
+               line(" mounted at: %s", info->mountpoint);
+               line(NULL);
+       }
+
+       if (sysinfo->n_interfaces) {
+               line(NULL);
                line("Network interfaces");
+       }
 
        for (i = 0; i < sysinfo->n_interfaces; i++) {
                struct interface_info *info = sysinfo->interfaces[i];
                char macbuf[32];
 
-               mac_str(info, macbuf, sizeof(macbuf));
+               if_info_mac_str(info, macbuf, sizeof(macbuf));
 
                line("%s:", info->name);
-               line(" MAC: %s", macbuf);
+               line(" MAC:  %s", macbuf);
+               line(" link: %s", info->link ? "up" : "down");
                line(NULL);
        }