mirror of
https://github.com/vivier/EMILE.git
synced 2024-06-12 19:22:46 +00:00
Manage chainloader attribute in configuration files
This commit is contained in:
parent
a47ae538de
commit
52a797f3eb
|
@ -73,6 +73,7 @@ static int get_info(char *image, int verbose)
|
|||
"kernel",
|
||||
"parameters",
|
||||
"initrd",
|
||||
"chainloader",
|
||||
NULL
|
||||
};
|
||||
int i;
|
||||
|
@ -191,6 +192,7 @@ static int set_config(char *image, int verbose, char *config_path,
|
|||
char *ramdisk_ondisk, *kernel_ondisk;
|
||||
char* kernel_image = NULL;
|
||||
char* ramdisk = NULL;
|
||||
char* chainloader = NULL;
|
||||
emile_config* config;
|
||||
int8_t *configuration;
|
||||
int timeout;
|
||||
|
@ -272,6 +274,18 @@ static int set_config(char *image, int verbose, char *config_path,
|
|||
config_add_property(configuration, "title", title);
|
||||
if (verbose)
|
||||
printf("title %s\n", title);
|
||||
if (!emile_config_get(config, CONFIG_CHAINLOADER, &chainloader))
|
||||
{
|
||||
if (emile_is_url(chainloader))
|
||||
{
|
||||
if (verbose)
|
||||
printf(" chainloader %s\n", chainloader);
|
||||
config_set_indexed_property(configuration,
|
||||
"title", title,
|
||||
"chainloader", chainloader);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!emile_config_get(config, CONFIG_KERNEL, &kernel_image))
|
||||
{
|
||||
if (emile_is_url(kernel_image))
|
||||
|
|
|
@ -423,6 +423,7 @@ static int8_t *set_config(emile_config *config, int drive)
|
|||
char buf[16];
|
||||
int ret;
|
||||
int8_t *configuration;
|
||||
char *chainloader;
|
||||
|
||||
configuration = malloc(65536);
|
||||
if (configuration == NULL)
|
||||
|
@ -469,6 +470,75 @@ static int8_t *set_config(emile_config *config, int drive)
|
|||
if (verbose)
|
||||
printf("title %s\n", title);
|
||||
|
||||
if (!emile_config_get(config,
|
||||
CONFIG_CHAINLOADER, &chainloader))
|
||||
{
|
||||
if (emile_is_url(chainloader))
|
||||
{
|
||||
config_set_indexed_property(configuration,
|
||||
"title", title,
|
||||
"chainloader", chainloader);
|
||||
}
|
||||
else
|
||||
{
|
||||
int fd;
|
||||
unsigned short unit_id;
|
||||
struct emile_container *container;
|
||||
|
||||
fd = open(chainloader, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ERROR: cannot open %s\n",
|
||||
chainloader);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
container = malloc(
|
||||
sizeof(struct emile_container) +
|
||||
sizeof(struct emile_block));
|
||||
if (container == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ERROR: cannot malloc container"
|
||||
"\n");
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = emile_scsi_create_container(fd,
|
||||
&unit_id,
|
||||
container,
|
||||
1);
|
||||
close(fd);
|
||||
if (ret == -1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ERROR: cannot create container"
|
||||
"\n");
|
||||
free(container);
|
||||
return NULL;
|
||||
}
|
||||
chainloader = malloc(32);
|
||||
if (chainloader == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ERROR: cannot malloc chainloader\n");
|
||||
free(container);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(chainloader,
|
||||
"block:(sd%d)0x%x,0x%x", unit_id,
|
||||
container->blocks[0].offset,
|
||||
container->blocks[0].count);
|
||||
free(container);
|
||||
config_set_indexed_property(configuration,
|
||||
"title", title,
|
||||
"chainloader", chainloader);
|
||||
free(chainloader);
|
||||
}
|
||||
}
|
||||
|
||||
if (!emile_config_get(config, CONFIG_KERNEL, &kernel_path))
|
||||
{
|
||||
ret = emile_config_get(config, CONFIG_KERNEL_MAP,
|
||||
|
|
|
@ -276,6 +276,10 @@ static int read_description(FILE* fd, char* desc, int size)
|
|||
{
|
||||
desc = set_tag(desc, CONFIG_INITRD_MAP, strlen(value) + 1, value);
|
||||
}
|
||||
else if (strcmp("chainloader", name) == 0)
|
||||
{
|
||||
desc = set_tag(desc, CONFIG_CHAINLOADER, strlen(value) + 1, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "ERROR: syntax error on word %s\n", name);
|
||||
|
@ -345,6 +349,7 @@ int emile_config_get(emile_config* config, int tag, ...)
|
|||
case CONFIG_KERNEL:
|
||||
case CONFIG_ARGS:
|
||||
case CONFIG_INITRD:
|
||||
case CONFIG_CHAINLOADER:
|
||||
s = va_arg(arg, char**);
|
||||
*s = get_tag(config->current, tag);
|
||||
ret = (*s == NULL) ? -1 : 0;
|
||||
|
|
|
@ -29,6 +29,7 @@ enum {
|
|||
CONFIG_ARGS,
|
||||
CONFIG_INITRD,
|
||||
CONFIG_INITRD_MAP,
|
||||
CONFIG_CHAINLOADER,
|
||||
};
|
||||
|
||||
extern emile_config* emile_config_open(char* name);
|
||||
|
|
Loading…
Reference in New Issue
Block a user