2007-10-02 14:21:34 +00:00
|
|
|
/*
|
|
|
|
*
|
2013-09-05 12:39:22 +00:00
|
|
|
* (c) 2004-2007 Laurent Vivier <Laurent@Vivier.EU>
|
2007-10-02 14:21:34 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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);
|
2007-10-02 14:21:34 +00:00
|
|
|
|
|
|
|
if (part > map->partition.MapBlkCnt)
|
|
|
|
return -1;
|
|
|
|
|
2007-10-09 19:02:42 +00:00
|
|
|
offset = part * sizeof(struct Partition) +
|
|
|
|
sizeof(struct DriverDescriptor);
|
2007-10-02 14:21:34 +00:00
|
|
|
|
2007-10-10 16:41:31 +00:00
|
|
|
ret = map->device->write_sector(map->device->data, offset / blocksize, &map->partition,
|
2007-10-09 19:02:42 +00:00
|
|
|
sizeof(struct Partition));
|
2014-05-31 09:18:51 +00:00
|
|
|
if (ret == -1)
|
2007-10-02 14:21:34 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
map->current = part;
|
|
|
|
|
|
|
|
return part;
|
|
|
|
}
|