fat.h

00001 /*
00002  * Copyright (c) 2008 Jakub Jermar
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00033 #ifndef FAT_FAT_H_
00034 #define FAT_FAT_H_
00035 
00036 #include <sys/types.h>
00037 
00038 #define BS_BLOCK                0
00039 #define BS_SIZE                 512
00040 
00041 #define DIRENT_SIZE             32
00042 
00043 typedef struct fat_bs {
00044         uint8_t         ji[3];          
00045         uint8_t         oem_name[8];
00046         /* BIOS Parameter Block */
00047         uint16_t        bps;            
00048         uint8_t         spc;            
00049         uint16_t        rscnt;          
00050         uint8_t         fatcnt;         
00051         uint16_t        root_ent_max;   
00053         uint16_t        totsec16;       
00054         uint8_t         mdesc;          
00055         uint16_t        sec_per_fat;    
00056         uint16_t        sec_per_track;  
00057         uint16_t        headcnt;        
00058         uint32_t        hidden_sec;     
00059         uint32_t        totsec32;       
00061         union {
00062                 struct {
00063                         /* FAT12/FAT16 only: Extended BIOS Parameter Block */
00065                         uint8_t         pdn;
00066                         uint8_t         reserved;
00068                         uint8_t         ebs;
00070                         uint32_t        id;
00072                         uint8_t         label[11];
00074                         uint8_t         type[8];
00076                         uint8_t         boot_code[448];
00078                         uint16_t        signature;
00079                 } __attribute__ ((packed));
00080                 struct {
00081                         /* FAT32 only */
00083                         uint32_t        sectors_per_fat;
00085                         uint16_t        flags;
00087                         uint16_t        version;
00089                         uint32_t        root_cluster;
00091                         uint16_t        fsinfo_sec;
00093                         uint16_t        bscopy_sec;
00094                         uint8_t         reserved1[12];
00096                         uint8_t         pdn;
00097                         uint8_t         reserved2;
00099                         uint8_t         ebs;
00101                         uint32_t        id;
00103                         uint8_t         label[11];
00105                         uint8_t         type[8];
00107                         uint8_t         boot_code[420];
00109                         uint16_t        signature;
00110                 } fat32 __attribute__ ((packed));
00111         };
00112 } __attribute__ ((packed)) fat_bs_t;
00113 
00114 #endif
00115 

Generated on Thu Jun 2 07:45:42 2011 for HelenOS/USB by  doxygen 1.4.7