discover: Track both configured and current autoboot settings
[petitboot] / lib / types / types.c
index 059e52a803db88eff5ed81477eba8c228b8d4937..d7f4ead791d2e7e312bdd531f834cbbee65ac67e 100644 (file)
@@ -2,13 +2,35 @@
 #include <types/types.h>
 #include <i18n/i18n.h>
 
+const char *ipmi_bootdev_display_name(enum ipmi_bootdev bootdev)
+{
+       switch (bootdev) {
+       case IPMI_BOOTDEV_NONE:
+               return _("None");
+       case IPMI_BOOTDEV_NETWORK:
+               return _("Network");
+       case IPMI_BOOTDEV_DISK:
+               return _("Disk");
+       case IPMI_BOOTDEV_SAFE:
+               return _("Safe Mode");
+       case IPMI_BOOTDEV_CDROM:
+               return _("Optical");
+       case IPMI_BOOTDEV_SETUP:
+               return _("Setup Mode");
+       default:
+               return _("Unknown");
+       }
+}
+
 const char *device_type_display_name(enum device_type type)
 {
        switch (type) {
        case DEVICE_TYPE_DISK:
                return _("Disk");
+       case DEVICE_TYPE_USB:
+               return _("USB");
        case DEVICE_TYPE_OPTICAL:
-               return _("Optical");
+               return _("CD/DVD");
        case DEVICE_TYPE_NETWORK:
                return _("Network");
        case DEVICE_TYPE_ANY:
@@ -24,6 +46,8 @@ const char *device_type_name(enum device_type type)
        switch (type) {
        case DEVICE_TYPE_DISK:
                return "disk";
+       case DEVICE_TYPE_USB:
+               return "usb";
        case DEVICE_TYPE_OPTICAL:
                return "optical";
        case DEVICE_TYPE_NETWORK:
@@ -40,6 +64,8 @@ enum device_type find_device_type(const char *str)
 {
        if (!strncmp(str, "disk", strlen("disk")))
                return DEVICE_TYPE_DISK;
+       if (!strncmp(str, "usb", strlen("usb")))
+               return DEVICE_TYPE_USB;
        if (!strncmp(str, "optical", strlen("optical")))
                return DEVICE_TYPE_OPTICAL;
        if (!strncmp(str, "network", strlen("network")))
@@ -49,3 +75,15 @@ enum device_type find_device_type(const char *str)
 
        return DEVICE_TYPE_UNKNOWN;
 }
+
+bool config_autoboot_active(const struct config *config)
+{
+       enum ipmi_bootdev bootdev = config->ipmi_bootdev;
+
+       if (!config->autoboot_enabled)
+               return false;
+       if (bootdev == IPMI_BOOTDEV_SETUP || bootdev == IPMI_BOOTDEV_SAFE)
+               return false;
+
+       return true;
+}