#include #include #include "volumes.h" #include "bloc.h" void read_bloc(unsigned int partition, uint32_t bloc, uintptr_t *buffer) { uint16_t cyl = cylinder_of_block(partition, bloc); uint16_t sec = sector_of_block(partition, bloc); read_sector(cyl, sec, buffer); } void read_block_alloc(unsigned int partition, uint32_t bloc, uintptr_t **buffer) { *buffer = malloc(block_size()); read_bloc(partition, bloc, *buffer); } void read_data_from_block(unsigned int volume, uint32_t block, void *data, size_t size) { void *buffer = malloc(block_size()); read_bloc(volume, block, buffer); memcpy(data, buffer, size); free(buffer); } void write_data_to_block(unsigned int volume, uint32_t block, void *data, size_t size) { void *buffer = malloc(block_size()); memcpy(buffer, data, size); write_bloc(volume, block, buffer); free(buffer); } void write_bloc(unsigned int volume, uint32_t block, uintptr_t *buffer) { uint16_t cyl = cylinder_of_block(volume, block); uint16_t sec = sector_of_block(volume, block); write_sector(cyl, sec, buffer); } void format_bloc(unsigned int partition, uint32_t bloc, int value) { uint16_t cyl = cylinder_of_block(partition, bloc); uint16_t sec = sector_of_block(partition, bloc); format_sector(cyl, sec, 1, value); } size_t block_size() { struct dskinfo_t info = dskinfo(); return info.taille_sec; }