xref: /haiku/src/system/boot/loader/file_systems/fat/fatfs.cpp (revision e7c8829c5d8e5d34a2a1e111f1c06aceff256013)
1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the OpenBeOS License.
4 */
5 
6 
7 #include "fatfs.h"
8 
9 #include <boot/partitions.h>
10 #include <boot/platform.h>
11 #include <util/kernel_cpp.h>
12 
13 #include <string.h>
14 #include <unistd.h>
15 #include <fcntl.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 
19 
20 using namespace FATFS;
21 
22 #if 0
23 status_t
24 FATFS::get_root_block(int fDevice, char *buffer, int32 blockSize, off_t partitionSize)
25 {
26 	// calculate root block position (it depends on the block size)
27 
28 	// ToDo: get the number of reserved blocks out of the disk_environment structure??
29 	//		(from the amiga_rdb module)
30 	int32 reservedBlocks = 2;
31 	off_t offset = (((partitionSize / blockSize) - 1 - reservedBlocks) / 2) + reservedBlocks;
32 		// ToDo: this calculation might be incorrect for certain cases.
33 
34 	if (read_pos(fDevice, offset * blockSize, buffer, blockSize) < B_OK)
35 		return B_ERROR;
36 
37 	RootBlock root(buffer, blockSize);
38 	if (root.ValidateCheckSum() < B_OK)
39 		return B_BAD_DATA;
40 
41 	//printf("primary = %ld, secondary = %ld\n", root.PrimaryType(), root.SecondaryType());
42 	if (!root.IsRootBlock())
43 		return B_BAD_TYPE;
44 
45 	return B_OK;
46 }
47 
48 #endif
49 
50