Fixed the 'REACTOS' volume label bug.
[reactos.git] / reactos / drivers / fs / vfat / vfat.h
index 2576b44..d1b0a86 100644 (file)
@@ -1,8 +1,9 @@
-/* $Id: vfat.h,v 1.31 2001/06/14 10:02:59 ekohl Exp $ */
+/* $Id: vfat.h,v 1.34 2001/07/28 07:05:56 hbirr Exp $ */
 
 #include <ddk/ntifs.h>
 
-struct _BootSector { 
+struct _BootSector
+{
   unsigned char  magic0, res0, magic1;
   unsigned char  OEMName[8];
   unsigned short BytesPerSector;
@@ -19,22 +20,43 @@ struct _BootSector {
   unsigned char  Res2[450];
 } __attribute__((packed));
 
-struct _BootSector32 {
-  unsigned char  magic0, res0, magic1;
-  unsigned char  OEMName[8];
-  unsigned short BytesPerSector;
-  unsigned char  SectorsPerCluster;
-  unsigned short ReservedSectors;
-  unsigned char  FATCount;
-  unsigned short RootEntries, Sectors;
-  unsigned char  Media;
-  unsigned short FATSectors, SectorsPerTrack, Heads;
-  unsigned long  HiddenSectors, SectorsHuge;
-  unsigned long  FATSectors32;
-  unsigned char  x[27];
-  unsigned long  VolumeID;
-  unsigned char  VolumeLabel[11], SysType[8];
-  unsigned char  Res2[422];
+struct _BootSector32
+{
+  unsigned char  magic0, res0, magic1;                 // 0
+  unsigned char  OEMName[8];                           // 3
+  unsigned short BytesPerSector;                       // 11
+  unsigned char  SectorsPerCluster;                    // 13
+  unsigned short ReservedSectors;                      // 14
+  unsigned char  FATCount;                             // 16
+  unsigned short RootEntries, Sectors;                 // 17
+  unsigned char  Media;                                        // 21
+  unsigned short FATSectors, SectorsPerTrack, Heads;   // 22
+  unsigned long  HiddenSectors, SectorsHuge;           // 28
+  unsigned long  FATSectors32;                         // 36
+  unsigned short ExtFlag;                              // 40
+  unsigned short FSVersion;                            // 42
+  unsigned long  RootCluster;                          // 44
+  unsigned short FSInfoSector;                         // 48
+  unsigned long  BootBackup;                           // 50
+  unsigned char  Res3[10];                             // 54
+  unsigned char  Drive;                                        // 64
+  unsigned char  Res4;                                 // 65
+  unsigned char  ExtBootSignature;                     // 66
+  unsigned long  VolumeID;                             // 67
+  unsigned char  VolumeLabel[11], SysType[8];          // 71
+  unsigned char  Res2[418];                            // 90
+  unsigned long  Signature1;                           // 508
+} __attribute__((packed));
+
+struct _BootBackupSector
+{
+  unsigned long  ExtBootSignature2;                    // 0
+  unsigned char  Res6[480];                            // 4
+  unsigned long  FSINFOSignature;                      // 484
+  unsigned long  FreeCluster;                          // 488
+  unsigned long  NextCluster;                          // 492
+  unsigned char  Res7[12];                             // 496
+  unsigned long  Signatur2;                            // 508
 } __attribute__((packed));
 
 typedef struct _BootSector BootSector;
@@ -49,7 +71,7 @@ struct _FATDirEntry {
   unsigned long  FileSize;
 } __attribute__((packed));
 
-typedef struct _FATDirEntry FATDirEntry;
+typedef struct _FATDirEntry FATDirEntry, FAT_DIR_ENTRY, *PFAT_DIR_ENTRY;
 
 struct _slot
 {
@@ -87,10 +109,11 @@ typedef struct
   PBCB Fat12StorageBcb;
   BootSector *Boot;
   int rootDirectorySectors, FATStart, rootStart, dataStart;
+  int BytesPerSector;
   int FATEntriesPerSector, FATUnit;
   ULONG BytesPerCluster;
   ULONG FatType;
-} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
+} DEVICE_EXTENSION, *PDEVICE_EXTENSION, VCB, *PVCB;
 
 typedef struct _VFATFCB
 {
@@ -105,6 +128,7 @@ typedef struct _VFATFCB
   PDEVICE_EXTENSION pDevExt;
   LIST_ENTRY FcbListEntry;
   struct _VFATFCB* parentFcb;
+  BOOL  isCacheInitialized;
 } VFATFCB, *PVFATFCB;
 
 typedef struct _VFATCCB
@@ -120,6 +144,9 @@ typedef struct _VFATCCB
   //    PSTRING DirectorySearchPattern;// for DirectoryControl ?
 } VFATCCB, *PVFATCCB;
 
+#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
+
+#define TAG_CCB TAG('V', 'C', 'C', 'B')
 
 #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
 
@@ -249,6 +276,12 @@ BOOL  vfatIsFileNameValid (PWCHAR pFileName);
 /*
  * functions from fat.c
  */
+NTSTATUS
+OffsetToCluster(PDEVICE_EXTENSION DeviceExt, 
+               ULONG FirstCluster, 
+               ULONG FileOffset,
+               PULONG Cluster,
+               BOOLEAN Extend);
 ULONG
 ClusterToSector(PDEVICE_EXTENSION DeviceExt,
                ULONG Cluster);
@@ -286,9 +319,9 @@ WriteCluster(PDEVICE_EXTENSION DeviceExt,
             ULONG ClusterToWrite,
             ULONG NewValue);
 
-/*
- * From create.c
- */
+/*  ---------------------------------------------------------  create.c  */
+
+void  vfat8Dot3ToString (PCHAR pBasename, PCHAR pExtension, PWSTR pName);
 NTSTATUS
 ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb);
 NTSTATUS
@@ -296,6 +329,19 @@ VfatOpenFile(PDEVICE_EXTENSION DeviceExt,
             PFILE_OBJECT FileObject,
             PWSTR FileName);
 
+/*  -----------------------------------------------  DirEntry Functions  */
+
+ULONG  vfatDirEntryGetFirstCluster (PDEVICE_EXTENSION  pDeviceExt,
+                                    PFAT_DIR_ENTRY  pDirEntry);
+BOOL  vfatIsDirEntryDeleted (FATDirEntry * pFatDirEntry);
+BOOL  vfatIsDirEntryVolume (FATDirEntry * pFatDirEntry);
+void  vfatGetDirEntryName (PFAT_DIR_ENTRY pDirEntry,  PWSTR  pEntryName);
+NTSTATUS  vfatGetNextDirEntry (PDEVICE_EXTENSION  pDeviceExt,
+                               PVFATFCB  pDirectoryFCB,
+                               ULONG * pDirectoryIndex,
+                               PWSTR pLongFileName,
+                               PFAT_DIR_ENTRY pDirEntry);
+
 /*  -----------------------------------------------------  FCB Functions */
 
 PVFATFCB  vfatNewFCB (PWCHAR pFileName);
@@ -306,12 +352,25 @@ void  vfatAddFCBToTable (PDEVICE_EXTENSION  pVCB,
                          PVFATFCB  pFCB);
 PVFATFCB  vfatGrabFCBFromTable (PDEVICE_EXTENSION  pDeviceExt, 
                                 PWSTR  pFileName);
+NTSTATUS  vfatRequestAndValidateRegion (PDEVICE_EXTENSION  pDeviceExt, 
+                                        PVFATFCB  pFCB, 
+                                        ULONG  pOffset,
+                                        PVOID * pBuffer,
+                                        PCACHE_SEGMENT * pCacheSegment,
+                                        BOOL  pExtend);
+NTSTATUS  vfatReleaseRegion (PDEVICE_EXTENSION  pDeviceExt,
+                             PVFATFCB  pFCB,
+                             PCACHE_SEGMENT  pCacheSegment);
 PVFATFCB  vfatMakeRootFCB (PDEVICE_EXTENSION  pVCB);
 PVFATFCB  vfatOpenRootFCB (PDEVICE_EXTENSION  pVCB);
 BOOL  vfatFCBIsDirectory (PDEVICE_EXTENSION pVCB, PVFATFCB FCB);
-PVFATFCB  vfatDirFindFile (PDEVICE_EXTENSION pVCB, 
-                           PVFATFCB parentFCB, 
-                           const PWSTR elementName);
+NTSTATUS  vfatAttachFCBToFileObject (PDEVICE_EXTENSION  vcb, 
+                                     PVFATFCB  fcb,
+                                     PFILE_OBJECT  fileObject);
+NTSTATUS  vfatDirFindFile (PDEVICE_EXTENSION  pVCB, 
+                           PVFATFCB  parentFCB, 
+                           PWSTR  elementName,
+                           PVFATFCB * fileFCB);
 NTSTATUS  vfatGetFCBForFile (PDEVICE_EXTENSION  pVCB, 
                              PVFATFCB  *pParentFCB, 
                              PVFATFCB  *pFCB,