/* Copyright (C) 2008 Emmanuel Varoquaux This file is part of XOS. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /* Implementation des macros definis dans le document 'FAT: General Overview of * On-Disk Format' (Microsoft Extensible Firmware Initiative - FAT32 File * System Specification). * * Les conventions de nommage definies dans ce document ont ete conservees. */ #ifndef VFAT_FAT_INFO_H #define VFAT_FAT_INFO_H #define FALSE 0 #define TRUE 1 #include "vfat_fat_info_struct.h" typedef unsigned short WORD; typedef unsigned long DWORD; /* types de FAT */ enum {FAT12, FAT16, FAT32}; int init_fat_info(struct vfat_fat_info_struct *fat_info, const void *buf); static inline unsigned long FirstSectorofCluster(const struct vfat_fat_info_struct *fat_info, unsigned long N) { return ((N - 2) * fat_info->boot_sect.BPB_SecPerClus) + fat_info->FirstDataSector; } static inline unsigned long FATOffset(const struct vfat_fat_info_struct *fat_info, unsigned long N) { if (fat_info->FATType == FAT12) return N + (N / 2); else if (fat_info->FATType == FAT16) return N * 2; else return N * 4; } static inline unsigned long ThisFATSecNum(const struct vfat_fat_info_struct *fat_info, unsigned long N) { return fat_info->boot_sect.BPB_ResvdSecCnt + (FATOffset(fat_info, N) / fat_info->boot_sect.BPB_BytsPerSec); } static inline unsigned long ThisFATEntOffset(const struct vfat_fat_info_struct *fat_info, unsigned long N) { return FATOffset(fat_info, N) % fat_info->boot_sect.BPB_BytsPerSec; } unsigned long get_FATClusEntryVal(const unsigned char SecBuff[], const struct vfat_fat_info_struct *fat_info, unsigned long N); void set_FATClusEntryVal(unsigned char SecBuff[], const struct vfat_fat_info_struct *fat_info, unsigned long N, unsigned long FATClusEntryVal); int IsEOF(const struct vfat_fat_info_struct *fat_info, unsigned long FATContent); #endif