2004-12-21 18:00:23 +00:00
|
|
|
static __attribute__((used)) char* rcsid = "$CVSHeader$";
|
2004-12-14 23:49:59 +00:00
|
|
|
/*
|
|
|
|
*
|
2006-09-15 14:55:39 +00:00
|
|
|
* (c) 2004 Laurent Vivier <Laurent@lvivier.info>
|
2004-12-14 23:49:59 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "partition.h"
|
|
|
|
#include "libemile.h"
|
2006-05-29 20:18:19 +00:00
|
|
|
#include "emile.h"
|
2004-12-14 23:49:59 +00:00
|
|
|
|
|
|
|
int emile_map_read(emile_map_t *map, int part)
|
|
|
|
{
|
|
|
|
off_t offset;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (map->current == part)
|
|
|
|
return part;
|
|
|
|
|
2006-05-29 20:18:19 +00:00
|
|
|
if (part > read_long(&map->partition.MapBlkCnt))
|
2004-12-14 23:49:59 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
offset = part * sizeof(struct Partition) + sizeof(struct DriverDescriptor);
|
|
|
|
|
|
|
|
ret = lseek(map->fd, offset, SEEK_SET);
|
|
|
|
if (ret != offset)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = read(map->fd, &map->partition, sizeof(struct Partition));
|
|
|
|
if (ret != sizeof(struct Partition))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
map->current = part;
|
|
|
|
|
|
|
|
return part;
|
|
|
|
}
|