MCPcopy Create free account
hub / github.com/coreboot/coreboot / conf_write

Function conf_write

util/kconfig/confdata.c:942–1056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940}
941
942int conf_write(const char *name)
943{
944 FILE *out;
945 struct symbol *sym;
946 struct menu *menu;
947 const char *str;
948 char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
949 char *env;
950 int i;
951 bool need_newline = false;
952
953 if (!name)
954 name = conf_get_configname();
955
956 if (!*name) {
957 fprintf(stderr, "config name is empty\n");
958 return -1;
959 }
960
961 if (is_dir(name)) {
962 fprintf(stderr, "%s: Is a directory\n", name);
963 return -1;
964 }
965
966 if (make_parent_dir(name))
967 return -1;
968
969 env = getenv("KCONFIG_OVERWRITECONFIG");
970 if (env && *env) {
971 *tmpname = 0;
972 out = fopen(name, "w");
973 } else {
974 snprintf(tmpname, sizeof(tmpname), "%s.%d.tmp",
975 name, (int)getpid());
976 out = fopen(tmpname, "w");
977 }
978 if (!out)
979 return 1;
980
981 conf_write_heading(out, &comment_style_pound);
982
983 if (!conf_get_changed())
984 sym_clear_all_valid();
985
986 menu = rootmenu.list;
987 while (menu) {
988 sym = menu->sym;
989 if (!sym) {
990 if (!menu_is_visible(menu))
991 goto next;
992 str = menu_get_prompt(menu);
993 fprintf(out, "\n"
994 "#\n"
995 "# %s\n"
996 "#\n", str);
997 need_newline = false;
998 } else if (!(sym->flags & SYMBOL_CHOICE) &&
999 !(sym->flags & SYMBOL_WRITTEN)) {

Callers 9

saveConfigMethod · 0.85
saveConfigAsMethod · 0.85
do_exitFunction · 0.85
conf_saveFunction · 0.85
conf_saveFunction · 0.85
handle_exitFunction · 0.85
mainFunction · 0.85
on_save_activateFunction · 0.85
store_filenameFunction · 0.85

Calls 15

conf_get_confignameFunction · 0.85
fprintfFunction · 0.85
is_dirFunction · 0.85
make_parent_dirFunction · 0.85
fopenFunction · 0.85
conf_write_headingFunction · 0.85
conf_get_changedFunction · 0.85
sym_clear_all_validFunction · 0.85
menu_is_visibleFunction · 0.85
menu_get_promptFunction · 0.85
sym_calc_valueFunction · 0.85

Tested by

no test coverage detected