2004-12-21 15:17:04 +00:00
|
|
|
static __attribute__((used)) char* rcsid = "$CVSHeader$";
|
2004-12-14 23:49:59 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "partition.h"
|
|
|
|
#include "libemile.h"
|
|
|
|
|
2004-12-16 23:20:15 +00:00
|
|
|
int emile_map_bootblock_write(emile_map_t* map, char* bootblock)
|
2004-12-14 23:49:59 +00:00
|
|
|
{
|
|
|
|
char name[16];
|
|
|
|
int ret;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
if (!emile_map_partition_is_valid(map))
|
|
|
|
return -1;
|
|
|
|
|
2004-12-21 15:17:04 +00:00
|
|
|
sprintf(name, "%s%d", map->name, map->current + 1);
|
2004-12-14 23:49:59 +00:00
|
|
|
|
2004-12-23 23:07:45 +00:00
|
|
|
fd = open(name, O_WRONLY);
|
2004-12-14 23:49:59 +00:00
|
|
|
if (fd == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = write(fd, bootblock, BOOTBLOCK_SIZE);
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|