2 * Copyright 2008, François Revol <revol@free.fr>
3 * Distributed under the terms of the MIT License.
9 #include <boot/partitions.h>
10 #include <boot/platform.h>
19 using namespace FATFS
;
23 FATFS::get_root_block(int fDevice
, char *buffer
, int32 blockSize
, off_t partitionSize
)
25 // calculate root block position (it depends on the block size)
27 // ToDo: get the number of reserved blocks out of the disk_environment structure??
28 // (from the amiga_rdb module)
29 int32 reservedBlocks
= 2;
30 off_t offset
= (((partitionSize
/ blockSize
) - 1 - reservedBlocks
) / 2) + reservedBlocks
;
31 // ToDo: this calculation might be incorrect for certain cases.
33 if (read_pos(fDevice
, offset
* blockSize
, buffer
, blockSize
) < B_OK
)
36 RootBlock
root(buffer
, blockSize
);
37 if (root
.ValidateCheckSum() < B_OK
)
40 //printf("primary = %ld, secondary = %ld\n", root.PrimaryType(), root.SecondaryType());
41 if (!root
.IsRootBlock())