mirror of
https://github.com/vivier/EMILE.git
synced 2024-12-21 18:30:20 +00:00
change interface of emile_second_create_mapfile()
This commit is contained in:
parent
ee35f84292
commit
364c09f440
@ -39,7 +39,7 @@ static int get_scsi_path(int fd, unsigned char *host, unsigned char *channel,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int get_device_info(int fd, int *id, unsigned long *first_block,
|
||||
static int get_device_info(int fd, short *id, unsigned long *first_block,
|
||||
int *block_size)
|
||||
{
|
||||
int ret;
|
||||
@ -101,11 +101,11 @@ static int get_device_info(int fd, int *id, unsigned long *first_block,
|
||||
return -1; \
|
||||
}
|
||||
|
||||
int emile_scsi_create_container(int fd, struct emile_container* container, int maxblocks)
|
||||
int emile_scsi_create_container(int fd, short *unit_id,
|
||||
struct emile_container* container, int maxblocks)
|
||||
{
|
||||
int ret;
|
||||
struct stat st;
|
||||
int id;
|
||||
unsigned long first_block;
|
||||
int sector_size;
|
||||
int block_size;
|
||||
@ -123,12 +123,11 @@ int emile_scsi_create_container(int fd, struct emile_container* container, int m
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = get_device_info(fd, &id, &first_block, §or_size);
|
||||
ret = get_device_info(fd, unit_id, &first_block, §or_size);
|
||||
if (ret != 0)
|
||||
return -1;
|
||||
|
||||
container->size = st.st_size;
|
||||
container->unit_id = (u_int16_t)id;
|
||||
|
||||
/* get filesystem block size */
|
||||
|
||||
|
@ -14,11 +14,12 @@
|
||||
|
||||
#define MAPFILE_SIZE 4096
|
||||
|
||||
struct emile_container *emile_second_create_mapfile(char *mapfile, char* kernel)
|
||||
struct emile_container *emile_second_create_mapfile(short *unit_id, char *mapfile, char* kernel)
|
||||
{
|
||||
struct emile_container *container;
|
||||
int fd;
|
||||
int ret;
|
||||
short unit_id_map;
|
||||
|
||||
container = (struct emile_container *)malloc(MAPFILE_SIZE);
|
||||
if (container == NULL)
|
||||
@ -37,7 +38,7 @@ struct emile_container *emile_second_create_mapfile(char *mapfile, char* kernel)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = emile_scsi_create_container(fd, container,
|
||||
ret = emile_scsi_create_container(fd, &unit_id_map, container,
|
||||
(MAPFILE_SIZE - sizeof(struct emile_container)) / sizeof(struct emile_block));
|
||||
close(fd);
|
||||
|
||||
@ -79,7 +80,7 @@ struct emile_container *emile_second_create_mapfile(char *mapfile, char* kernel)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = emile_scsi_create_container(fd, container,
|
||||
ret = emile_scsi_create_container(fd, unit_id, container,
|
||||
(MAPFILE_SIZE - sizeof(struct emile_container)) / sizeof(struct emile_block));
|
||||
close(fd);
|
||||
|
||||
@ -90,6 +91,13 @@ struct emile_container *emile_second_create_mapfile(char *mapfile, char* kernel)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (unit_id_map != *unit_id)
|
||||
{
|
||||
fprintf(stderr, "ERROR: map file must be on the same disk as the file to map\n");
|
||||
free(container);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (container->size != MAPFILE_SIZE)
|
||||
{
|
||||
fprintf(stderr, "ERROR: map file size is bad (%d)\n", container->size);
|
||||
|
@ -71,11 +71,11 @@ extern int emile_first_set_param(int fd, unsigned short tune_mask,
|
||||
extern int emile_first_get_param(int fd, int *drive_num, int *second_offset,
|
||||
int *second_size);
|
||||
extern int emile_first_set_param_scsi(int fd, char *second_name);
|
||||
struct emile_container *emile_second_create_mapfile(char *mapfile, char* kernel);
|
||||
struct emile_container *emile_second_create_mapfile(short *unit_id, char *mapfile, char* kernel);
|
||||
extern int emile_floppy_create_image(char* first_level, char* second_level,
|
||||
char* kernel_image, char* ramdisk,
|
||||
char* image);
|
||||
extern int emile_scsi_create_container(int fd,
|
||||
extern int emile_scsi_create_container(int fd, short *unit_id,
|
||||
struct emile_container* container, int maxbloks);
|
||||
extern emile_map_t* emile_map_open(char* dev, int flags);
|
||||
extern void emile_map_close(emile_map_t *map);
|
||||
|
@ -689,9 +689,10 @@ int main(int argc, char **argv)
|
||||
{
|
||||
char *configuration;
|
||||
struct emile_container *container;
|
||||
short unit_id;
|
||||
char map_info[64];
|
||||
|
||||
container = emile_second_create_mapfile(map_path, kernel_path);
|
||||
container = emile_second_create_mapfile(&unit_id, map_path, kernel_path);
|
||||
if (container == NULL)
|
||||
{
|
||||
fprintf(stderr,
|
||||
@ -707,7 +708,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* set kernel info */
|
||||
|
||||
sprintf(map_info, "container:(sd%d)0x%x,0x%x", container->unit_id,
|
||||
sprintf(map_info, "container:(sd%d)0x%x,0x%x", unit_id,
|
||||
container->blocks[0].offset, container->blocks[0].count);
|
||||
emile_second_set_property(configuration, "kernel", map_info);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user