Write the directory cluster back to the disk

This commit is contained in:
Baptiste Wicht 2013-12-24 15:00:01 +01:00
parent 970796ed6b
commit 4b1656aa37
3 changed files with 16 additions and 1 deletions

View File

@ -58,6 +58,7 @@ const char* disk_type_to_string(disk_type type);
const char* partition_type_to_string(partition_type type);
bool read_sectors(const disk_descriptor& disk, uint64_t start, uint8_t count, void* destination);
bool write_sectors(const disk_descriptor& disk, uint64_t start, uint8_t count, void* destination);
std::unique_heap_array<partition_descriptor> partitions(const disk_descriptor& disk);
bool partition_exists(const disk_descriptor& disk, uint64_t uuid);

View File

@ -122,6 +122,16 @@ bool disks::read_sectors(const disk_descriptor& disk, uint64_t start, uint8_t co
}
}
bool disks::write_sectors(const disk_descriptor& disk, uint64_t start, uint8_t count, void* destination){
switch(disk.type){
case disk_type::ATA:
return ata::write_sectors(*static_cast<ata::drive_descriptor*>(disk.descriptor), start, count, destination);
default:
return false;
}
}
std::unique_heap_array<disks::partition_descriptor> disks::partitions(const disk_descriptor& disk){
std::unique_ptr<boot_record_t> boot_record(new boot_record_t());

View File

@ -515,7 +515,11 @@ bool fat32::mkdir(dd disk, const disks::partition_descriptor& partition, const s
new_directory_entry.cluster_high = 0;
new_directory_entry.cluster_low = 0;
//TODO Write the sector to the disk
if(!write_sectors(disk, cluster_lba(cluster_number.second), fat_bs->sectors_per_cluster, directory_cluster.get())){
return false;
}
return true;
}
return false;