xref: /haiku/src/system/boot/loader/file_systems/fat/fatfs.cpp (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
1 /*
2  * Copyright 2008, François Revol <revol@free.fr>
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "fatfs.h"
8 
9 #include <boot/partitions.h>
10 #include <boot/platform.h>
11 
12 #include <string.h>
13 #include <unistd.h>
14 #include <fcntl.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 
18 
19 using namespace FATFS;
20 
21 #if 0
22 status_t
23 FATFS::get_root_block(int fDevice, char *buffer, int32 blockSize, off_t partitionSize)
24 {
25 	// calculate root block position (it depends on the block size)
26 
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.
32 
33 	if (read_pos(fDevice, offset * blockSize, buffer, blockSize) < B_OK)
34 		return B_ERROR;
35 
36 	RootBlock root(buffer, blockSize);
37 	if (root.ValidateCheckSum() < B_OK)
38 		return B_BAD_DATA;
39 
40 	//printf("primary = %ld, secondary = %ld\n", root.PrimaryType(), root.SecondaryType());
41 	if (!root.IsRootBlock())
42 		return B_BAD_TYPE;
43 
44 	return B_OK;
45 }
46 
47 #endif
48 
49