12cf4975bSFrançois Revol /* 2*4b723e3fSAxel Dörfler * Copyright 2008, François Revol <revol@free.fr> 3*4b723e3fSAxel Dörfler * Distributed under the terms of the MIT License. 42cf4975bSFrançois Revol */ 52cf4975bSFrançois Revol 62cf4975bSFrançois Revol 72cf4975bSFrançois Revol #include "fatfs.h" 82cf4975bSFrançois Revol 92cf4975bSFrançois Revol #include <boot/partitions.h> 102cf4975bSFrançois Revol #include <boot/platform.h> 112cf4975bSFrançois Revol 122cf4975bSFrançois Revol #include <string.h> 132cf4975bSFrançois Revol #include <unistd.h> 142cf4975bSFrançois Revol #include <fcntl.h> 152cf4975bSFrançois Revol #include <stdio.h> 162cf4975bSFrançois Revol #include <stdlib.h> 172cf4975bSFrançois Revol 182cf4975bSFrançois Revol 192cf4975bSFrançois Revol using namespace FATFS; 202cf4975bSFrançois Revol 212cf4975bSFrançois Revol #if 0 222cf4975bSFrançois Revol status_t 232cf4975bSFrançois Revol FATFS::get_root_block(int fDevice, char *buffer, int32 blockSize, off_t partitionSize) 242cf4975bSFrançois Revol { 252cf4975bSFrançois Revol // calculate root block position (it depends on the block size) 262cf4975bSFrançois Revol 272cf4975bSFrançois Revol // ToDo: get the number of reserved blocks out of the disk_environment structure?? 282cf4975bSFrançois Revol // (from the amiga_rdb module) 292cf4975bSFrançois Revol int32 reservedBlocks = 2; 302cf4975bSFrançois Revol off_t offset = (((partitionSize / blockSize) - 1 - reservedBlocks) / 2) + reservedBlocks; 312cf4975bSFrançois Revol // ToDo: this calculation might be incorrect for certain cases. 322cf4975bSFrançois Revol 332cf4975bSFrançois Revol if (read_pos(fDevice, offset * blockSize, buffer, blockSize) < B_OK) 342cf4975bSFrançois Revol return B_ERROR; 352cf4975bSFrançois Revol 362cf4975bSFrançois Revol RootBlock root(buffer, blockSize); 372cf4975bSFrançois Revol if (root.ValidateCheckSum() < B_OK) 382cf4975bSFrançois Revol return B_BAD_DATA; 392cf4975bSFrançois Revol 402cf4975bSFrançois Revol //printf("primary = %ld, secondary = %ld\n", root.PrimaryType(), root.SecondaryType()); 412cf4975bSFrançois Revol if (!root.IsRootBlock()) 422cf4975bSFrançois Revol return B_BAD_TYPE; 432cf4975bSFrançois Revol 442cf4975bSFrançois Revol return B_OK; 452cf4975bSFrançois Revol } 462cf4975bSFrançois Revol 472cf4975bSFrançois Revol #endif 482cf4975bSFrançois Revol 49