EMILE/libemile/emile_second_get_param.c

50 lines
976 B
C
Raw Permalink Normal View History

2006-06-01 23:08:37 +00:00
/*
*
* (c) 2006 Laurent Vivier <Laurent@Vivier.EU>
2006-06-01 23:08:37 +00:00
*
*/
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include "libemile.h"
2007-08-25 21:33:57 +00:00
#include "libconfig.h"
2006-06-01 23:08:37 +00:00
int emile_second_get_param(int fd, char *kernel, char *parameters, char *initrd)
{
int ret;
int drive, second, size;
2007-09-08 23:09:14 +00:00
int8_t *configuration;
2006-06-01 23:08:37 +00:00
/* can work on an image or directly on second level file */
2006-06-05 22:30:03 +00:00
lseek(fd, 0, SEEK_SET);
2006-06-01 23:08:37 +00:00
ret = emile_first_get_param(fd, &drive, &second, &size);
if (ret == EEMILE_UNKNOWN_FIRST)
{
/* should be a second level file */
ret = lseek(fd, 0, SEEK_SET);
if (ret == -1)
return -1;
}
configuration = emile_second_get_configuration(fd);
if (configuration == NULL)
return -1;
if (kernel != NULL)
2007-08-25 21:33:57 +00:00
config_get_property(configuration, "kernel", kernel);
2006-06-01 23:08:37 +00:00
if (parameters != NULL)
2008-07-11 22:15:32 +00:00
config_get_property(configuration, "args", parameters);
2006-06-01 23:08:37 +00:00
if (initrd != NULL)
2007-08-25 21:33:57 +00:00
config_get_property(configuration, "initrd", initrd);
2006-06-01 23:08:37 +00:00
free(configuration);
return 0;
}