EMILE/libemile/emile_second_set_param.c

64 lines
1.1 KiB
C
Raw Normal View History

2006-06-01 23:00:32 +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)
{
if (*kernel)
2007-08-25 21:33:57 +00:00
config_set_property(configuration, "kernel", kernel);
else
2007-08-25 21:33:57 +00:00
config_remove_property(configuration, "kernel");
}
2006-06-01 23:00:32 +00:00
if (parameters != NULL)
{
if (*parameters)
2008-07-11 22:15:32 +00:00
config_set_property(configuration, "args", parameters);
else
2008-07-11 22:15:32 +00:00
config_remove_property(configuration, "args");
}
2006-06-01 23:00:32 +00:00
if (initrd != NULL)
{
if (*initrd)
2007-08-25 21:33:57 +00:00
config_set_property(configuration, "initrd", initrd);
else
2007-08-25 21:33:57 +00:00
config_remove_property(configuration, "initrd");
}
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;
}