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