2006-06-01 23:00:32 +00:00
|
|
|
/*
|
|
|
|
*
|
2013-09-05 12:39:22 +00:00
|
|
|
* (c) 2006 Laurent Vivier <Laurent@Vivier.EU>
|
2006-06-01 23:00:32 +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:00:32 +00:00
|
|
|
|
|
|
|
int emile_second_set_param(int fd, char *kernel, char *parameters, char *initrd)
|
|
|
|
{
|
|
|
|
int ret;
|
2007-09-08 23:09:14 +00:00
|
|
|
int8_t *configuration;
|
2006-06-01 23:00:32 +00:00
|
|
|
off_t offset;
|
|
|
|
|
|
|
|
offset = lseek(fd, 0, SEEK_CUR);
|
|
|
|
|
|
|
|
configuration = emile_second_get_configuration(fd);
|
|
|
|
if (configuration == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (kernel != NULL)
|
2007-05-22 20:02:28 +00:00
|
|
|
{
|
|
|
|
if (*kernel)
|
2007-08-25 21:33:57 +00:00
|
|
|
config_set_property(configuration, "kernel", kernel);
|
2007-05-22 20:02:28 +00:00
|
|
|
else
|
2007-08-25 21:33:57 +00:00
|
|
|
config_remove_property(configuration, "kernel");
|
2007-05-22 20:02:28 +00:00
|
|
|
}
|
2006-06-01 23:00:32 +00:00
|
|
|
|
|
|
|
if (parameters != NULL)
|
2007-05-22 20:02:28 +00:00
|
|
|
{
|
|
|
|
if (*parameters)
|
2008-07-11 22:15:32 +00:00
|
|
|
config_set_property(configuration, "args", parameters);
|
2007-05-22 20:02:28 +00:00
|
|
|
else
|
2008-07-11 22:15:32 +00:00
|
|
|
config_remove_property(configuration, "args");
|
2007-05-22 20:02:28 +00:00
|
|
|
}
|
2006-06-01 23:00:32 +00:00
|
|
|
|
|
|
|
if (initrd != NULL)
|
2007-05-22 20:02:28 +00:00
|
|
|
{
|
|
|
|
if (*initrd)
|
2007-08-25 21:33:57 +00:00
|
|
|
config_set_property(configuration, "initrd", initrd);
|
2007-05-22 20:02:28 +00:00
|
|
|
else
|
2007-08-25 21:33:57 +00:00
|
|
|
config_remove_property(configuration, "initrd");
|
2007-05-22 20:02:28 +00:00
|
|
|
}
|
2006-06-01 23:00:32 +00:00
|
|
|
|
2007-08-25 21:33:57 +00:00
|
|
|
config_set_property(configuration, "vga", "default");
|
2006-06-01 23:00:32 +00:00
|
|
|
|
|
|
|
ret = lseek(fd, offset, SEEK_SET);
|
|
|
|
if (ret == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = emile_second_set_configuration(fd, configuration);
|
|
|
|
if (ret != 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
free(configuration);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|