mirror of
https://github.com/vivier/EMILE.git
synced 2025-02-25 08:28:59 +00:00
Add map_partition_read() and map_partition_write()
This commit is contained in:
parent
f2745a6bbb
commit
ffa835644d
@ -175,6 +175,7 @@ extern int map_set_bootinfo(map_t *map, int bootstart, int bootsize, int bootadd
|
||||
extern int map_set_driver_info(map_t *map, int number, int block, int size, int type);
|
||||
extern int map_set_driver_number(map_t *map, int number);
|
||||
extern unsigned long map_get_driver_signature(map_t* map);
|
||||
extern int emile_block0_write(map_t *map);
|
||||
extern int map_block0_write(map_t *map);
|
||||
extern int map_partition_read(map_t* map, off_t block, size_t nb, har* sector);
|
||||
extern int map_partition_write(map_t* map, off_t block, size_t nb, har* sector);
|
||||
#endif
|
||||
|
31
libmap/map_partition_read.c
Normal file
31
libmap/map_partition_read.c
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004-2007 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libmap.h"
|
||||
|
||||
int map_partition_read(map_t* map, off_t block, size_t nb, char* sector)
|
||||
{
|
||||
off_t offset;
|
||||
int ret;
|
||||
|
||||
if (!map_partition_is_valid(map))
|
||||
return -1;
|
||||
|
||||
offset = read_long((u_int32_t*)&map->partition.PyPartStart + block)
|
||||
* FLOPPY_SECTOR_SIZE;
|
||||
|
||||
ret = map->device->read_sector(map->device,
|
||||
offset, bootblock,
|
||||
nb * FLOPPY_SECTOR_SIZE);
|
||||
|
||||
return ret;
|
||||
}
|
31
libmap/map_partition_write.c
Normal file
31
libmap/map_partition_write.c
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004-2007 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libmap.h"
|
||||
|
||||
int map_bootblock_write(map_t* map, off_t block, size_t nb, char* sector)
|
||||
{
|
||||
off_t offset;
|
||||
int ret;
|
||||
|
||||
if (!map_partition_is_valid(map))
|
||||
return -1;
|
||||
|
||||
offset = read_long((u_int32_t*)&map->partition.PyPartStart + block)
|
||||
* FLOPPY_SECTOR_SIZE;
|
||||
|
||||
ret = map->device->write_sector(map->device,
|
||||
offset, bootblock,
|
||||
nb * FLOPPY_SECTOR_SIZE);
|
||||
|
||||
return ret;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user