home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Utilities / Partition Logic 0.68 / partlogic-0.68.iso / system / headers / sys / fat.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-10  |  3.7 KB  |  100 lines

  1. // 
  2. //  Visopsys
  3. //  Copyright (C) 1998-2007 J. Andrew McLaughlin
  4. //  
  5. //  This library is free software; you can redistribute it and/or modify it
  6. //  under the terms of the GNU Lesser General Public License as published by
  7. //  the Free Software Foundation; either version 2.1 of the License, or (at
  8. //  your option) any later version.
  9. //
  10. //  This library is distributed in the hope that it will be useful, but
  11. //  WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
  13. //  General Public License for more details.
  14. //
  15. //  You should have received a copy of the GNU Lesser General Public License
  16. //  along with this library; if not, write to the Free Software Foundation,
  17. //  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. //
  19. //  fat.h
  20. //
  21.  
  22. // This file contains definitions and structures for using and manipulating
  23. // the Microsoft(R) FAT filesystems in Visopsys.
  24.  
  25. #if !defined(_FAT_H)
  26.  
  27. // FAT-specific Filesystem things
  28. #define FAT_MAX_SECTORSIZE       4096
  29. #define FAT_BYTES_PER_DIR_ENTRY  32
  30. #define FAT_MAX_DIRTY_FATSECTS   32
  31.  
  32. // File attributes
  33. #define FAT_ATTRIB_READONLY      0x01
  34. #define FAT_ATTRIB_HIDDEN        0x02
  35. #define FAT_ATTRIB_SYSTEM        0x04
  36. #define FAT_ATTRIB_VOLUMELABEL   0x08
  37. #define FAT_ATTRIB_SUBDIR        0x10
  38. #define FAT_ATTRIB_ARCHIVE       0x20
  39.  
  40. typedef struct {
  41.   unsigned char jmpBoot[3];
  42.   char oemName[8];                // 03 - 0A OEM Name
  43.   unsigned short bytesPerSect;        // 0B - 0C Bytes per sector
  44.   unsigned char sectsPerClust;        // 0D - 0D Sectors per cluster
  45.   unsigned short rsvdSectCount;        // 0E - 0F Reserved sectors
  46.   unsigned char numFats;        // 10 - 10 Copies of FAT
  47.   unsigned short rootEntCount;        // 11 - 12 Max root directory entries
  48.   unsigned short totalSects16;        // 13 - 14 Number of sectors
  49.   unsigned char media;            // 15 - 15 Media descriptor byte
  50.   unsigned short fatSize16;        // 16 - 17 Sectors per FAT
  51.   unsigned short sectsPerTrack;        // 18 - 19 Sectors per track
  52.   unsigned short numHeads;        // 1A - 1B Number of heads
  53.   unsigned hiddenSects;            // 1C - 1F Hidden sectors
  54.   unsigned totalSects32;        // 20 - 23 Number of sectors (32)
  55.   // From here, the BPB for FAT and VFAT differ
  56.   union {
  57.     struct {
  58.       unsigned char biosDriveNum;    // 24 - 24 BIOS drive number
  59.       unsigned char reserved1;         // 25 - 25 ?
  60.       unsigned char bootSig;              // 26 - 26 Signature
  61.       unsigned volumeId;            // 27 - 2A Volume ID
  62.       char volumeLabel[11];        // 2B - 35 Volume name
  63.       char fileSysType[8];           // 36 - 3D Filesystem type
  64.       unsigned char bootCode[448];
  65.     } __attribute__((packed)) fat;
  66.     struct {
  67.       unsigned fatSize32;        // 24 - 27 Sectors per FAT (32)
  68.       unsigned short extFlags;        // 28 - 29 Flags
  69.       unsigned short fsVersion;        // 2A - 2B FS version number
  70.       unsigned rootClust;        // 2C - 2F Root directory cluster
  71.       unsigned short fsInfo;        // 30 - 31 FSInfo struct sector
  72.       unsigned short backupBootSect;    // 32 - 33 Backup boot sector
  73.       unsigned char reserved[12];    // 34 - 3F ?
  74.       unsigned char biosDriveNum;    // 40 - 40 BIOS drive number
  75.       unsigned char reserved1;         // 41 - 41 ?
  76.       unsigned char bootSig;              // 42 - 42 Signature
  77.       unsigned volumeId;            // 43 - 46 Volume ID
  78.       char volumeLabel[11];        // 47 - 51 Volume name
  79.       char fileSysType[8];        // 52 - 59 Filesystem type
  80.       unsigned char bootCode[414];
  81.     } __attribute__((packed)) fat32;
  82.   };
  83.   unsigned short signature;
  84.  
  85. } __attribute__((packed)) fatBPB;
  86.  
  87. typedef struct {
  88.   unsigned leadSig;
  89.   unsigned char reserved1[480];
  90.   unsigned structSig;
  91.   unsigned freeCount;
  92.   unsigned nextFree;
  93.   unsigned char reserved2[12];
  94.   unsigned trailSig;
  95.  
  96. } __attribute__((packed)) fatFsInfo;
  97.  
  98. #define _FAT_H
  99. #endif
  100.