ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

fat.h
Go to the documentation of this file.
00001 /*
00002  *  FreeLoader
00003  *  Copyright (C) 1998-2003  Brian Palmer  <brianp@sginet.com>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License along
00016  *  with this program; if not, write to the Free Software Foundation, Inc.,
00017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #pragma once
00021 
00022 #include <pshpack1.h>
00023 typedef struct _FAT_BOOTSECTOR
00024 {
00025     UCHAR       JumpBoot[3];                // Jump instruction to boot code
00026     CHAR        OemName[8];                 // "MSWIN4.1" for MS formatted volumes
00027     USHORT      BytesPerSector;             // Bytes per sector
00028     UCHAR       SectorsPerCluster;          // Number of sectors in a cluster
00029     USHORT      ReservedSectors;            // Reserved sectors, usually 1 (the bootsector)
00030     UCHAR       NumberOfFats;               // Number of FAT tables
00031     USHORT      RootDirEntries;             // Number of root directory entries (fat12/16)
00032     USHORT      TotalSectors;               // Number of total sectors on the drive, 16-bit
00033     UCHAR       MediaDescriptor;            // Media descriptor byte
00034     USHORT      SectorsPerFat;              // Sectors per FAT table (fat12/16)
00035     USHORT      SectorsPerTrack;            // Number of sectors in a track
00036     USHORT      NumberOfHeads;              // Number of heads on the disk
00037     ULONG       HiddenSectors;              // Hidden sectors (sectors before the partition start like the partition table)
00038     ULONG       TotalSectorsBig;            // This field is the new 32-bit total count of sectors on the volume
00039     UCHAR       DriveNumber;                // Int 0x13 drive number (e.g. 0x80)
00040     UCHAR       Reserved1;                  // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
00041     UCHAR       BootSignature;              // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
00042     ULONG       VolumeSerialNumber;         // Volume serial number
00043     CHAR        VolumeLabel[11];            // Volume label. This field matches the 11-byte volume label recorded in the root directory
00044     CHAR        FileSystemType[8];          // One of the strings "FAT12   ", "FAT16   ", or "FAT     "
00045 
00046     UCHAR       BootCodeAndData[448];       // The remainder of the boot sector
00047 
00048     USHORT      BootSectorMagic;            // 0xAA55
00049 
00050 } FAT_BOOTSECTOR, *PFAT_BOOTSECTOR;
00051 
00052 typedef struct _FAT32_BOOTSECTOR
00053 {
00054     UCHAR       JumpBoot[3];                // Jump instruction to boot code
00055     CHAR        OemName[8];                 // "MSWIN4.1" for MS formatted volumes
00056     USHORT      BytesPerSector;             // Bytes per sector
00057     UCHAR       SectorsPerCluster;          // Number of sectors in a cluster
00058     USHORT      ReservedSectors;            // Reserved sectors, usually 1 (the bootsector)
00059     UCHAR       NumberOfFats;               // Number of FAT tables
00060     USHORT      RootDirEntries;             // Number of root directory entries (fat12/16)
00061     USHORT      TotalSectors;               // Number of total sectors on the drive, 16-bit
00062     UCHAR       MediaDescriptor;            // Media descriptor byte
00063     USHORT      SectorsPerFat;              // Sectors per FAT table (fat12/16)
00064     USHORT      SectorsPerTrack;            // Number of sectors in a track
00065     USHORT      NumberOfHeads;              // Number of heads on the disk
00066     ULONG       HiddenSectors;              // Hidden sectors (sectors before the partition start like the partition table)
00067     ULONG       TotalSectorsBig;            // This field is the new 32-bit total count of sectors on the volume
00068     ULONG       SectorsPerFatBig;           // This field is the FAT32 32-bit count of sectors occupied by ONE FAT. BPB_FATSz16 must be 0
00069     USHORT      ExtendedFlags;              // Extended flags (fat32)
00070     USHORT      FileSystemVersion;          // File system version (fat32)
00071     ULONG       RootDirStartCluster;        // Starting cluster of the root directory (fat32)
00072     USHORT      FsInfo;                     // Sector number of FSINFO structure in the reserved area of the FAT32 volume. Usually 1.
00073     USHORT      BackupBootSector;           // If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6.
00074     UCHAR       Reserved[12];               // Reserved for future expansion
00075     UCHAR       DriveNumber;                // Int 0x13 drive number (e.g. 0x80)
00076     UCHAR       Reserved1;                  // Reserved (used by Windows NT). Code that formats FAT volumes should always set this byte to 0.
00077     UCHAR       BootSignature;              // Extended boot signature (0x29). This is a signature byte that indicates that the following three fields in the boot sector are present.
00078     ULONG       VolumeSerialNumber;         // Volume serial number
00079     CHAR        VolumeLabel[11];            // Volume label. This field matches the 11-byte volume label recorded in the root directory
00080     CHAR        FileSystemType[8];          // Always set to the string "FAT32   "
00081 
00082     UCHAR       BootCodeAndData[420];       // The remainder of the boot sector
00083 
00084     USHORT      BootSectorMagic;            // 0xAA55
00085 
00086 } FAT32_BOOTSECTOR, *PFAT32_BOOTSECTOR;
00087 
00088 typedef struct _FATX_BOOTSECTOR
00089 {
00090     CHAR        FileSystemType[4];          /* String "FATX" */
00091     ULONG       VolumeSerialNumber;         /* Volume serial number */
00092     ULONG       SectorsPerCluster;          /* Number of sectors in a cluster */
00093     USHORT      NumberOfFats;               /* Number of FAT tables */
00094     ULONG       Unknown;                /* Always 0? */
00095     UCHAR       Unused[494];                /* Actually size should be 4078 (boot block is 4096 bytes) */
00096 
00097 } FATX_BOOTSECTOR, *PFATX_BOOTSECTOR;
00098 
00099 /*
00100  * Structure of MSDOS directory entry
00101  */
00102 typedef struct //_DIRENTRY
00103 {
00104     CHAR    FileName[11];   /* Filename + extension */
00105     UCHAR   Attr;       /* File attributes */
00106     UCHAR   ReservedNT; /* Reserved for use by Windows NT */
00107     UCHAR   TimeInTenths;   /* Millisecond stamp at file creation */
00108     USHORT  CreateTime; /* Time file was created */
00109     USHORT  CreateDate; /* Date file was created */
00110     USHORT  LastAccessDate; /* Date file was last accessed */
00111     USHORT  ClusterHigh;    /* High word of this entry's start cluster */
00112     USHORT  Time;       /* Time last modified */
00113     USHORT  Date;       /* Date last modified */
00114     USHORT  ClusterLow; /* First cluster number low word */
00115     ULONG   Size;       /* File size */
00116 } DIRENTRY, * PDIRENTRY;
00117 
00118 typedef struct
00119 {
00120     UCHAR   SequenceNumber;     /* Sequence number for slot */
00121     WCHAR   Name0_4[5];     /* First 5 characters in name */
00122     UCHAR   EntryAttributes;    /* Attribute byte */
00123     UCHAR   Reserved;       /* Always 0 */
00124     UCHAR   AliasChecksum;      /* Checksum for 8.3 alias */
00125     WCHAR   Name5_10[6];        /* 6 more characters in name */
00126     USHORT  StartCluster;       /* Starting cluster number */
00127     WCHAR   Name11_12[2];       /* Last 2 characters in name */
00128 } LFN_DIRENTRY, * PLFN_DIRENTRY;
00129 
00130 typedef struct
00131 {
00132     UCHAR   FileNameSize;   /* Size of filename (max 42) */
00133     UCHAR   Attr;       /* File attributes */
00134     CHAR    FileName[42];   /* Filename in ASCII, padded with 0xff (not zero-terminated) */
00135     ULONG   StartCluster;   /* Starting cluster number */
00136     ULONG   Size;       /* File size */
00137     USHORT  Time;       /* Time last modified */
00138     USHORT  Date;       /* Date last modified */
00139     USHORT  CreateTime; /* Time file was created */
00140     USHORT  CreateDate; /* Date file was created */
00141     USHORT  LastAccessTime; /* Time file was last accessed */
00142     USHORT  LastAccessDate; /* Date file was last accessed */
00143 } FATX_DIRENTRY, * PFATX_DIRENTRY;
00144 #include <poppack.h>
00145 
00146 typedef struct _FAT_VOLUME_INFO *PFAT_VOLUME_INFO;
00147 
00148 typedef struct
00149 {
00150     UCHAR   Attributes;     /* File attributes */
00151     ULONG   FileSize;       /* File size */
00152     ULONG   FilePointer;        /* File pointer */
00153     ULONG*  FileFatChain;       /* File fat chain array */
00154     ULONG   DriveNumber;
00155     PFAT_VOLUME_INFO    Volume;
00156 } FAT_FILE_INFO, * PFAT_FILE_INFO;
00157 
00158 #define ATTR_NORMAL     0x00
00159 #define ATTR_READONLY   0x01
00160 #define ATTR_HIDDEN     0x02
00161 #define ATTR_SYSTEM     0x04
00162 #define ATTR_VOLUMENAME 0x08
00163 #define ATTR_DIRECTORY  0x10
00164 #define ATTR_ARCHIVE    0x20
00165 #define ATTR_LONG_NAME  (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUMENAME)
00166 
00167 #define FAT12           1
00168 #define FAT16           2
00169 #define FAT32           3
00170 #define FATX16          4
00171 #define FATX32          5
00172 
00173 #define ISFATX(FT) ((FT) == FATX16 || (FT) == FATX32)
00174 
00175 const DEVVTBL* FatMount(ULONG DeviceId);

Generated on Sun May 27 2012 04:19:05 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.