Lines Matching refs:config

179                 BootConfig *config,  in boot_config_load_type1()  argument
186 assert(config); in boot_config_load_type1()
192 if (!GREEDY_REALLOC0(config->entries, config->n_entries + 1)) in boot_config_load_type1()
195 r = boot_entry_load_type1(f, root, dir, id, config->entries + config->n_entries); in boot_config_load_type1()
199 config->n_entries++; in boot_config_load_type1()
203 void boot_config_free(BootConfig *config) { in boot_config_free() argument
204 assert(config); in boot_config_free()
206 free(config->default_pattern); in boot_config_free()
207 free(config->timeout); in boot_config_free()
208 free(config->editor); in boot_config_free()
209 free(config->auto_entries); in boot_config_free()
210 free(config->auto_firmware); in boot_config_free()
211 free(config->console_mode); in boot_config_free()
212 free(config->random_seed_mode); in boot_config_free()
213 free(config->beep); in boot_config_free()
215 free(config->entry_oneshot); in boot_config_free()
216 free(config->entry_default); in boot_config_free()
217 free(config->entry_selected); in boot_config_free()
219 for (size_t i = 0; i < config->n_entries; i++) in boot_config_free()
220 boot_entry_free(config->entries + i); in boot_config_free()
221 free(config->entries); in boot_config_free()
223 set_free(config->inodes_seen); in boot_config_free()
226 int boot_loader_read_conf(BootConfig *config, FILE *file, const char *path) { in boot_loader_read_conf() argument
230 assert(config); in boot_loader_read_conf()
263 r = free_and_strdup(&config->default_pattern, p); in boot_loader_read_conf()
265 r = free_and_strdup(&config->timeout, p); in boot_loader_read_conf()
267 r = free_and_strdup(&config->editor, p); in boot_loader_read_conf()
269 r = free_and_strdup(&config->auto_entries, p); in boot_loader_read_conf()
271 r = free_and_strdup(&config->auto_firmware, p); in boot_loader_read_conf()
273 r = free_and_strdup(&config->console_mode, p); in boot_loader_read_conf()
275 r = free_and_strdup(&config->random_seed_mode, p); in boot_loader_read_conf()
277 r = free_and_strdup(&config->beep, p); in boot_loader_read_conf()
289 static int boot_loader_read_conf_path(BootConfig *config, const char *path) { in boot_loader_read_conf_path() argument
292 assert(config); in boot_loader_read_conf_path()
303 return boot_loader_read_conf(config, f, path); in boot_loader_read_conf_path()
350 static int config_check_inode_relevant_and_unseen(BootConfig *config, int fd, const char *fname) { in config_check_inode_relevant_and_unseen() argument
354 assert(config); in config_check_inode_relevant_and_unseen()
371 if (set_contains(config->inodes_seen, &st)) { in config_check_inode_relevant_and_unseen()
378 if (set_ensure_put(&config->inodes_seen, &inode_hash_ops, d) < 0) in config_check_inode_relevant_and_unseen()
386 BootConfig *config, in boot_entries_find_type1() argument
394 assert(config); in boot_entries_find_type1()
426 r = config_check_inode_relevant_and_unseen(config, fileno(f), de->d_name); in boot_entries_find_type1()
432 r = boot_config_load_type1(config, f, root, dir, de->d_name); in boot_entries_find_type1()
644 BootConfig *config, in boot_entries_find_unified() argument
651 assert(config); in boot_entries_find_unified()
672 if (!GREEDY_REALLOC0(config->entries, config->n_entries + 1)) in boot_entries_find_unified()
681 r = config_check_inode_relevant_and_unseen(config, fd, de->d_name); in boot_entries_find_unified()
694 … r = boot_entry_load_unified(root, j, osrelease, cmdline, config->entries + config->n_entries); in boot_entries_find_unified()
698 config->n_entries++; in boot_entries_find_unified()
775 static int boot_config_find(const BootConfig *config, const char *id) { in boot_config_find() argument
776 assert(config); in boot_config_find()
781 for (size_t i = 0; i < config->n_entries; i++) in boot_config_find()
782 if (fnmatch(id, config->entries[i].id, FNM_CASEFOLD) == 0) in boot_config_find()
788 static int boot_entries_select_default(const BootConfig *config) { in boot_entries_select_default() argument
791 assert(config); in boot_entries_select_default()
792 assert(config->entries || config->n_entries == 0); in boot_entries_select_default()
794 if (config->n_entries == 0) { in boot_entries_select_default()
799 if (config->entry_oneshot) { in boot_entries_select_default()
800 i = boot_config_find(config, config->entry_oneshot); in boot_entries_select_default()
803 config->entries[i].id); in boot_entries_select_default()
808 if (config->entry_default) { in boot_entries_select_default()
809 i = boot_config_find(config, config->entry_default); in boot_entries_select_default()
812 config->entries[i].id); in boot_entries_select_default()
817 if (config->default_pattern) { in boot_entries_select_default()
818 i = boot_config_find(config, config->default_pattern); in boot_entries_select_default()
821 config->entries[i].id, config->default_pattern); in boot_entries_select_default()
826 log_debug("Found default: first entry \"%s\"", config->entries[0].id); in boot_entries_select_default()
830 static int boot_entries_select_selected(const BootConfig *config) { in boot_entries_select_selected() argument
831 assert(config); in boot_entries_select_selected()
832 assert(config->entries || config->n_entries == 0); in boot_entries_select_selected()
834 if (!config->entry_selected || config->n_entries == 0) in boot_entries_select_selected()
837 return boot_config_find(config, config->entry_selected); in boot_entries_select_selected()
840 static int boot_load_efi_entry_pointers(BootConfig *config) { in boot_load_efi_entry_pointers() argument
843 assert(config); in boot_load_efi_entry_pointers()
850 … r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderEntryOneShot), &config->entry_oneshot); in boot_load_efi_entry_pointers()
856 … r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderEntryDefault), &config->entry_default); in boot_load_efi_entry_pointers()
862 … r = efi_get_variable_string(EFI_LOADER_VARIABLE(LoaderEntrySelected), &config->entry_selected); in boot_load_efi_entry_pointers()
871 int boot_config_select_special_entries(BootConfig *config) { in boot_config_select_special_entries() argument
874 assert(config); in boot_config_select_special_entries()
876 r = boot_load_efi_entry_pointers(config); in boot_config_select_special_entries()
880 config->default_entry = boot_entries_select_default(config); in boot_config_select_special_entries()
881 config->selected_entry = boot_entries_select_selected(config); in boot_config_select_special_entries()
886 int boot_config_finalize(BootConfig *config) { in boot_config_finalize() argument
889 typesafe_qsort(config->entries, config->n_entries, boot_entry_compare); in boot_config_finalize()
891 r = boot_entries_uniquify(config->entries, config->n_entries); in boot_config_finalize()
899 BootConfig *config, in boot_config_load() argument
906 assert(config); in boot_config_load()
910 r = boot_loader_read_conf_path(config, p); in boot_config_load()
915 r = boot_entries_find_type1(config, esp_path, p); in boot_config_load()
920 r = boot_entries_find_unified(config, esp_path, p); in boot_config_load()
927 r = boot_entries_find_type1(config, xbootldr_path, p); in boot_config_load()
932 r = boot_entries_find_unified(config, xbootldr_path, p); in boot_config_load()
937 return boot_config_finalize(config); in boot_config_load()
941 BootConfig *config, in boot_config_load_auto() argument
949 assert(config); in boot_config_load_auto()
960 return boot_config_load(config, "/run/boot-loader-entries/", NULL); in boot_config_load_auto()
979 return boot_config_load(config, esp_where, xbootldr_where); in boot_config_load_auto()
983 BootConfig *config, in boot_config_augment_from_loader() argument
997 assert(config); in boot_config_augment_from_loader()
1006 existing = boot_config_find_entry(config, *i); in boot_config_augment_from_loader()
1031 if (!GREEDY_REALLOC0(config->entries, config->n_entries + 1)) in boot_config_augment_from_loader()
1034 config->entries[config->n_entries++] = (BootEntry) { in boot_config_augment_from_loader()
1056 BootEntry* boot_config_find_entry(BootConfig *config, const char *id) { in boot_config_find_entry() argument
1057 assert(config); in boot_config_find_entry()
1060 for (size_t j = 0; j < config->n_entries; j++) in boot_config_find_entry()
1061 if (streq_ptr(config->entries[j].id, id) || in boot_config_find_entry()
1062 streq_ptr(config->entries[j].id_old, id)) in boot_config_find_entry()
1063 return config->entries + j; in boot_config_find_entry()
1180 int show_boot_entries(const BootConfig *config, JsonFormatFlags json_format) { in show_boot_entries() argument
1184 for (size_t i = 0; i < config->n_entries; i++) { in show_boot_entries()
1186 const BootEntry *e = config->entries + i; in show_boot_entries()
1220 for (size_t n = 0; n < config->n_entries; n++) { in show_boot_entries()
1222 config->entries + n, in show_boot_entries()
1223 /* show_as_default= */ n == (size_t) config->default_entry, in show_boot_entries()
1224 … /* show_as_selected= */ n == (size_t) config->selected_entry, in show_boot_entries()
1229 if (n+1 < config->n_entries) in show_boot_entries()