EMILE/libmap/map_write.c

33 lines
584 B
C
Raw Permalink Normal View History

/*
*
* (c) 2004-2007 Laurent Vivier <Laurent@Vivier.EU>
*
*/
#include <sys/types.h>
#include <unistd.h>
#include "libmap.h"
int map_write(map_t *map, int part)
{
off_t offset;
int ret;
2007-11-01 22:12:38 +00:00
int blocksize = map->device->get_blocksize(map->device->data);
if (part > map->partition.MapBlkCnt)
return -1;
2007-10-09 19:02:42 +00:00
offset = part * sizeof(struct Partition) +
sizeof(struct DriverDescriptor);
ret = map->device->write_sector(map->device->data, offset / blocksize, &map->partition,
2007-10-09 19:02:42 +00:00
sizeof(struct Partition));
if (ret == -1)
return -1;
map->current = part;
return part;
}