mirror of
https://github.com/vivier/EMILE.git
synced 2025-01-22 00:32:15 +00:00
EM06 header
This commit is contained in:
parent
63c0921975
commit
a216e4a7c5
@ -130,10 +130,11 @@ static int aggregate(int fd, char* first_level, char* second_level, char* kernel
|
||||
|
||||
int emile_floppy_create_image(char* first_level, char* second_level,
|
||||
char* kernel_image, char* ramdisk,
|
||||
unsigned long buffer_size, char* image)
|
||||
char* image)
|
||||
{
|
||||
int ret;
|
||||
int fd;
|
||||
char configuration[1024];
|
||||
|
||||
if (image == NULL)
|
||||
return -1;
|
||||
@ -183,12 +184,14 @@ int emile_floppy_create_image(char* first_level, char* second_level,
|
||||
|
||||
/* set second level info */
|
||||
|
||||
ret = emile_second_set_kernel(fd, kernel_image,
|
||||
FIRST_LEVEL_SIZE +
|
||||
emile_file_get_size(second_level),
|
||||
ramdisk);
|
||||
lseek(fd, FIRST_LEVEL_SIZE, SEEK_SET);
|
||||
ret = emile_second_set_buffer_size(fd, buffer_size);
|
||||
sprintf(configuration, "kernel block:(fd0)0x%lx\n",
|
||||
FIRST_LEVEL_SIZE + emile_file_get_size(second_level));
|
||||
sprintf(configuration + strlen(configuration), "initrd block:(fd0)0x%lx,0x%lx",
|
||||
FIRST_LEVEL_SIZE +
|
||||
emile_file_get_size(second_level) + emile_file_get_size(kernel_image),
|
||||
emile_file_get_size(ramdisk));
|
||||
|
||||
ret = emile_second_set_configuration(fd, configuration);
|
||||
|
||||
close(fd);
|
||||
|
||||
|
35
libemile/emile_second_get_configuration.c
Normal file
35
libemile/emile_second_get_configuration.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libemile.h"
|
||||
#include "emile.h"
|
||||
|
||||
char* emile_second_get_configuration(int fd)
|
||||
{
|
||||
char *conf;
|
||||
emile_l2_header_t header;
|
||||
int ret;
|
||||
int size;
|
||||
|
||||
ret = read(fd, &header, sizeof(header));
|
||||
if (ret != sizeof(header))
|
||||
return NULL;
|
||||
|
||||
size = read_short(&header.conf_size);
|
||||
conf = (char*)malloc(size);
|
||||
if (conf == NULL)
|
||||
return NULL;
|
||||
|
||||
ret = read(fd, conf, size);
|
||||
if (ret != size)
|
||||
return NULL;
|
||||
|
||||
return conf;
|
||||
}
|
42
libemile/emile_second_set_configuration.c
Normal file
42
libemile/emile_second_set_configuration.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libemile.h"
|
||||
#include "emile.h"
|
||||
#include "bootblock.h"
|
||||
|
||||
int emile_second_set_configuration(int fd, char *configuration)
|
||||
{
|
||||
emile_l2_header_t header;
|
||||
int ret;
|
||||
int size;
|
||||
int len;
|
||||
|
||||
if (configuration == NULL)
|
||||
return EEMILE_CANNOT_READ_SECOND;
|
||||
|
||||
len = strlen (configuration) + 1; /* + 1 for ending 0 */
|
||||
|
||||
ret = read(fd, &header, sizeof(header));
|
||||
if (ret != sizeof(header))
|
||||
return EEMILE_CANNOT_READ_SECOND;
|
||||
|
||||
size = read_short(&header.conf_size);
|
||||
if (len > size)
|
||||
return EEMILE_CANNOT_READ_SECOND;
|
||||
|
||||
ret = write(fd, configuration, len);
|
||||
if (ret != len)
|
||||
return EEMILE_CANNOT_WRITE_SECOND;
|
||||
|
||||
return 0;
|
||||
}
|
@ -97,7 +97,7 @@ extern int emile_second_get_buffer_size(int fd, unsigned int *buffer_size);
|
||||
extern int emile_second_set_kernel_scsi(int fd, char *kernel_name);
|
||||
extern int emile_floppy_create_image(char* first_level, char* second_level,
|
||||
char* kernel_image, char* ramdisk,
|
||||
unsigned long buffer_size, char* image);
|
||||
char* image);
|
||||
extern int emile_scsi_create_container(int fd,
|
||||
struct emile_container* container);
|
||||
extern emile_map_t* emile_map_open(char* dev, int flags);
|
||||
@ -144,4 +144,6 @@ extern int emile_map_set_bootinfo(emile_map_t *map, int bootstart, int bootsize,
|
||||
extern int emile_map_set_driver_info(emile_map_t *map, int number, int block, int size, int type);
|
||||
extern int emile_map_set_driver_number(emile_map_t *map, int number);
|
||||
extern int emile_block0_write(emile_map_t *map);
|
||||
extern char* emile_second_get_configuration(int fd);
|
||||
extern int emile_second_set_configuration(int fd, char *configuration);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user