LCOV - code coverage report
Current view: top level - shared - bootspec.h (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 0 11 0.0 %
Date: 2019-08-22 15:41:25 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : 
       3             : #pragma once
       4             : 
       5             : #include <inttypes.h>
       6             : #include <stdbool.h>
       7             : #include <sys/types.h>
       8             : 
       9             : #include "sd-id128.h"
      10             : 
      11             : #include "string-util.h"
      12             : 
      13             : typedef enum BootEntryType {
      14             :         BOOT_ENTRY_CONF,     /* Type #1 entries: *.conf files */
      15             :         BOOT_ENTRY_UNIFIED,  /* Type #2 entries: *.efi files */
      16             :         BOOT_ENTRY_LOADER,   /* Additional entries augmented from LoaderEntries EFI var */
      17             :         _BOOT_ENTRY_MAX,
      18             :         _BOOT_ENTRY_INVALID = -1,
      19             : } BootEntryType;
      20             : 
      21             : typedef struct BootEntry {
      22             :         BootEntryType type;
      23             :         char *id;       /* This is the file basename without extension */
      24             :         char *path;     /* This is the full path to the drop-in file */
      25             :         char *root;     /* The root path in which the drop-in was found, i.e. to which 'kernel', 'efi' and 'initrd' are relative */
      26             :         char *title;
      27             :         char *show_title;
      28             :         char *version;
      29             :         char *machine_id;
      30             :         char *architecture;
      31             :         char **options;
      32             :         char *kernel;        /* linux is #defined to 1, yikes! */
      33             :         char *efi;
      34             :         char **initrd;
      35             :         char *device_tree;
      36             : } BootEntry;
      37             : 
      38             : typedef struct BootConfig {
      39             :         char *default_pattern;
      40             :         char *timeout;
      41             :         char *editor;
      42             :         char *auto_entries;
      43             :         char *auto_firmware;
      44             :         char *console_mode;
      45             : 
      46             :         char *entry_oneshot;
      47             :         char *entry_default;
      48             : 
      49             :         BootEntry *entries;
      50             :         size_t n_entries;
      51             :         ssize_t default_entry;
      52             : } BootConfig;
      53             : 
      54           0 : static inline bool boot_config_has_entry(BootConfig *config, const char *id) {
      55             :         size_t j;
      56             : 
      57           0 :         for (j = 0; j < config->n_entries; j++)
      58           0 :                 if (streq(config->entries[j].id, id))
      59           0 :                         return true;
      60             : 
      61           0 :         return false;
      62             : }
      63             : 
      64           0 : static inline BootEntry* boot_config_default_entry(BootConfig *config) {
      65           0 :         if (config->default_entry < 0)
      66           0 :                 return NULL;
      67             : 
      68           0 :         return config->entries + config->default_entry;
      69             : }
      70             : 
      71             : void boot_config_free(BootConfig *config);
      72             : int boot_entries_load_config(const char *esp_path, const char *xbootldr_path, BootConfig *config);
      73             : int boot_entries_load_config_auto(const char *override_esp_path, const char *override_xbootldr_path, BootConfig *config);
      74             : #if ENABLE_EFI
      75             : int boot_entries_augment_from_loader(BootConfig *config, bool only_auto);
      76             : #else
      77             : static inline int boot_entries_augment_from_loader(BootConfig *config, bool only_auto) {
      78             :         return -EOPNOTSUPP;
      79             : }
      80             : #endif
      81             : 
      82           0 : static inline const char* boot_entry_title(const BootEntry *entry) {
      83           0 :         return entry->show_title ?: entry->title ?: entry->id;
      84             : }
      85             : 
      86             : int find_esp_and_warn(const char *path, bool unprivileged_mode, char **ret_path, uint32_t *ret_part, uint64_t *ret_pstart, uint64_t *ret_psize, sd_id128_t *ret_uuid);
      87             : int find_xbootldr_and_warn(const char *path, bool unprivileged_mode, char **ret_path,sd_id128_t *ret_uuid);

Generated by: LCOV version 1.14