2004-12-21 15:17:04 +00:00
|
|
|
static __attribute__((used)) char* rcsid = "$CVSHeader$";
|
2004-12-14 23:49:59 +00:00
|
|
|
/*
|
|
|
|
*
|
2006-09-20 21:48:44 +00:00
|
|
|
* (c) 2004-2006 Laurent Vivier <Laurent@lvivier.info>
|
2004-12-14 23:49:59 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "partition.h"
|
|
|
|
#include "libemile.h"
|
2006-09-20 21:48:44 +00:00
|
|
|
#include "emile.h"
|
2004-12-14 23:49:59 +00:00
|
|
|
|
2004-12-16 23:20:15 +00:00
|
|
|
int emile_map_bootblock_read(emile_map_t* map, char* bootblock)
|
2004-12-14 23:49:59 +00:00
|
|
|
{
|
2006-09-20 21:48:44 +00:00
|
|
|
off_t offset;
|
2004-12-14 23:49:59 +00:00
|
|
|
int ret;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
if (!emile_map_partition_is_valid(map))
|
|
|
|
return -1;
|
|
|
|
|
2006-09-20 21:48:44 +00:00
|
|
|
fd = open(map->name, O_RDONLY);
|
2004-12-14 23:49:59 +00:00
|
|
|
if (fd == -1)
|
|
|
|
return -1;
|
2007-02-24 13:35:32 +00:00
|
|
|
offset = read_long((u_int32_t*)&map->partition.PyPartStart) * 512;
|
2006-09-20 21:48:44 +00:00
|
|
|
lseek(fd, offset, SEEK_SET);
|
2004-12-14 23:49:59 +00:00
|
|
|
|
|
|
|
ret = read(fd, bootblock, BOOTBLOCK_SIZE);
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|