xref: /haiku/src/system/boot/loader/file_systems/fat/fatfs.h (revision 011b188df06c6366de2d92033693ff3b9b49133e)
12cf4975bSFrançois Revol /*
22cf4975bSFrançois Revol ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3b6f76ebeSAugustin Cavalier ** Distributed under the terms of the MIT License.
42cf4975bSFrançois Revol */
52cf4975bSFrançois Revol #ifndef FATFS_H
62cf4975bSFrançois Revol #define FATFS_H
72cf4975bSFrançois Revol 
82cf4975bSFrançois Revol 
92cf4975bSFrançois Revol #include <SupportDefs.h>
102cf4975bSFrançois Revol #include <ByteOrder.h>
112cf4975bSFrançois Revol 
122cf4975bSFrançois Revol namespace FATFS {
132cf4975bSFrançois Revol 
142cf4975bSFrançois Revol class Volume;
152cf4975bSFrançois Revol 
162cf4975bSFrançois Revol // mode bits
172cf4975bSFrançois Revol #define FAT_READ_ONLY   1
182cf4975bSFrançois Revol #define FAT_HIDDEN              2
192cf4975bSFrançois Revol #define FAT_SYSTEM              4
202cf4975bSFrançois Revol #define FAT_VOLUME              8
212cf4975bSFrançois Revol #define FAT_SUBDIR              16
222cf4975bSFrançois Revol #define FAT_ARCHIVE             32
232cf4975bSFrançois Revol 
242cf4975bSFrançois Revol #define read32(buffer,off) \
252cf4975bSFrançois Revol         B_LENDIAN_TO_HOST_INT32(*(uint32 *)&buffer[off])
262cf4975bSFrançois Revol 
27*011b188dSPulkoMandy #define read16(buffer,off) (buffer[off] + (buffer[off + 1] << 8))
282cf4975bSFrançois Revol 
29085cf27bSIngo Weinhold #define write32(buffer, off, value) \
30085cf27bSIngo Weinhold         *(uint32*)&buffer[off] = B_HOST_TO_LENDIAN_INT32(value)
31085cf27bSIngo Weinhold 
32085cf27bSIngo Weinhold #define write16(buffer, off, value) \
33085cf27bSIngo Weinhold         *(uint16*)&buffer[off] = B_HOST_TO_LENDIAN_INT16(value)
34085cf27bSIngo Weinhold 
352cf4975bSFrançois Revol enum name_lengths {
362cf4975bSFrançois Revol 	FATFS_BASENAME_LENGTH	= 8,
372cf4975bSFrançois Revol 	FATFS_EXTNAME_LENGTH	= 3,
382cf4975bSFrançois Revol 	FATFS_NAME_LENGTH	= 12,
392cf4975bSFrançois Revol };
402cf4975bSFrançois Revol 
412cf4975bSFrançois Revol status_t get_root_block(int fDevice, char *buffer, int32 blockSize, off_t partitionSize);
422cf4975bSFrançois Revol 
432cf4975bSFrançois Revol 
442cf4975bSFrançois Revol }	// namespace FATFS
452cf4975bSFrançois Revol 
462cf4975bSFrançois Revol #endif	/* FATFS_H */
472cf4975bSFrançois Revol 
48