2004-12-21 17:57:19 +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 <unistd.h>
|
|
|
|
|
|
|
|
#include "partition.h"
|
|
|
|
#include "libemile.h"
|
|
|
|
|
2004-12-21 17:57:19 +00:00
|
|
|
int emile_map_write(emile_map_t *map, int part)
|
2004-12-14 23:49:59 +00:00
|
|
|
{
|
|
|
|
off_t offset;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (part > map->partition.MapBlkCnt)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
offset = part * sizeof(struct Partition) + sizeof(struct DriverDescriptor);
|
|
|
|
|
|
|
|
ret = lseek(map->fd, offset, SEEK_SET);
|
|
|
|
if (ret != offset)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = write(map->fd, &map->partition, sizeof(struct Partition));
|
|
|
|
if (ret != sizeof(struct Partition))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
map->current = part;
|
|
|
|
|
|
|
|
return part;
|
|
|
|
}
|