2004-12-21 16:11:51 +00:00
|
|
|
static __attribute__((used)) char* rcsid = "$CVSHeader$";
|
|
|
|
/*
|
|
|
|
*
|
2006-09-15 14:55:39 +00:00
|
|
|
* (c) 2004 Laurent Vivier <Laurent@lvivier.info>
|
2004-12-21 16:11:51 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-12-21 17:58:04 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2004-12-21 16:11:51 +00:00
|
|
|
#include "partition.h"
|
|
|
|
#include "libemile.h"
|
|
|
|
|
|
|
|
int emile_map_set_startup(char* dev_name, int partition)
|
|
|
|
{
|
|
|
|
emile_map_t* map;
|
2004-12-21 17:58:04 +00:00
|
|
|
char *part_type;
|
2004-12-21 16:11:51 +00:00
|
|
|
int ret;
|
2004-12-21 17:58:04 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
map = emile_map_open(dev_name, O_RDWR);
|
|
|
|
if (map == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* check partition type */
|
|
|
|
|
|
|
|
ret = emile_map_read(map, partition);
|
|
|
|
if (ret == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
part_type = emile_map_get_partition_type(map);
|
|
|
|
if (strcmp(part_type, APPLE_HFS) != 0) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"ERROR: a startup partition must be of type Apple_HFS\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2004-12-21 16:11:51 +00:00
|
|
|
|
|
|
|
for (i = 0; i < emile_map_get_number(map); i++)
|
|
|
|
{
|
2004-12-21 17:58:04 +00:00
|
|
|
ret = emile_map_read(map, i);
|
|
|
|
if (ret == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
part_type = emile_map_get_partition_type(map);
|
|
|
|
if (strcmp(part_type, APPLE_HFS) == 0)
|
|
|
|
{
|
2004-12-27 21:39:19 +00:00
|
|
|
emile_map_partition_set_bootable(map, i == partition);
|
2004-12-21 17:58:04 +00:00
|
|
|
emile_map_partition_set_startup(map, i == partition);
|
|
|
|
ret = emile_map_write(map, i);
|
|
|
|
if (ret == -1)
|
|
|
|
return -1;
|
|
|
|
}
|
2004-12-21 16:11:51 +00:00
|
|
|
}
|
|
|
|
emile_map_close(map);
|
2004-12-21 17:58:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2004-12-21 16:11:51 +00:00
|
|
|
}
|