Add some error messages

This commit is contained in:
Laurent Vivier 2007-09-05 12:54:01 +00:00
parent 6f5ab12ba7
commit 4e1468ddff

View File

@ -424,7 +424,12 @@ static char *set_config(emile_config *config, int drive)
configuration = malloc(65536); configuration = malloc(65536);
if (configuration == NULL) if (configuration == NULL)
{
fprintf(stderr,
"ERROR: cannot allocate memory for configuration\n");
return NULL; return NULL;
}
configuration[0] = 0; configuration[0] = 0;
config_set_property(configuration, "vga", "default"); config_set_property(configuration, "vga", "default");
@ -449,13 +454,6 @@ static char *set_config(emile_config *config, int drive)
emile_config_read_first_entry(config); emile_config_read_first_entry(config);
ret = emile_config_get(config, CONFIG_KERNEL, &kernel_path);
if (ret == -1)
{
free(configuration);
return NULL;
}
do { do {
if (!emile_config_get(config, CONFIG_TITLE, &title)) if (!emile_config_get(config, CONFIG_TITLE, &title))
config_add_property(configuration, "title", title); config_add_property(configuration, "title", title);
@ -464,16 +462,24 @@ static char *set_config(emile_config *config, int drive)
if (!emile_config_get(config, CONFIG_KERNEL, &kernel_path)) if (!emile_config_get(config, CONFIG_KERNEL, &kernel_path))
{ {
ret = emile_config_get(config, CONFIG_KERNEL_MAP, &kernel_map_path); ret = emile_config_get(config, CONFIG_KERNEL_MAP,
&kernel_map_path);
ret = add_file(configuration, title, "kernel", kernel_path, ret = add_file(configuration, title,
"kernel", kernel_path,
ret == -1 ? NULL : kernel_map_path); ret == -1 ? NULL : kernel_map_path);
if (ret == -1) if (ret == -1)
{ {
fprintf(stderr,
"ERROR: cannot add kernel %s\n",
kernel_path);
free(configuration); free(configuration);
return NULL; return NULL;
} }
} }
else
fprintf(stderr,
"WARNING: missing kernel entry for %s\n", title);
if (!emile_config_get(config, CONFIG_INITRD, &initrd_path)) if (!emile_config_get(config, CONFIG_INITRD, &initrd_path))
{ {
@ -484,6 +490,11 @@ static char *set_config(emile_config *config, int drive)
if (ret == -1) if (ret == -1)
{ {
free(configuration); free(configuration);
fprintf(stderr,
"ERROR: cannot add initrd %s\n",
initrd_path);
fprintf(stderr,
"ERROR: missing kernel entry for %s\n", title);
return NULL; return NULL;
} }
} }
@ -506,12 +517,35 @@ static char *set_config(emile_config *config, int drive)
/* do not fit in second paramstring */ /* do not fit in second paramstring */
fd = creat(bootconfig, S_IWUSR); fd = creat(bootconfig, S_IWUSR);
if (fd == -1)
{
free(configuration);
fprintf(stderr,
"ERROR: cannot create /boot/emile/.bootconfig\n");
return NULL;
}
write(fd, configuration, strlen(configuration) + 1); write(fd, configuration, strlen(configuration) + 1);
close(fd); close(fd);
free(configuration); free(configuration);
configuration = malloc(1024); configuration = malloc(1024);
add_file(configuration, NULL, "configuration", bootconfig, NULL); if (configuration == NULL)
{
fprintf(stderr,
"ERROR: cannot allocate memory for configuration\n");
return NULL;
}
ret = add_file(configuration, NULL,
"configuration", bootconfig, NULL);
if (ret == -1)
{
free(configuration);
fprintf(stderr,
"ERROR: cannot add %s to configuration\n", bootconfig);
return NULL;
}
} }
return configuration; return configuration;
} }