Enabled FAT32 write code.
Various smaller fixes.
Patch by Hartmut Birr (part 2).
svn path=/trunk/; revision=2076
/*
- * $Id: fat.c,v 1.28 2001/07/13 10:31:14 ekohl Exp $
+ * $Id: fat.c,v 1.29 2001/07/20 08:00:20 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
/* FUNCTIONS ****************************************************************/
NTSTATUS
-Fat32GetNextCluster (PDEVICE_EXTENSION DeviceExt,
- ULONG CurrentCluster,
- PULONG NextCluster)
+Fat32GetNextCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG CurrentCluster,
+ PULONG NextCluster)
/*
* FUNCTION: Retrieve the next FAT32 cluster from the FAT table via a physical
* disk read
PCACHE_SEGMENT CacheSeg;
NTSTATUS Status;
ULONG FATOffset;
+ ULONG ChunkSize;
+
+ ChunkSize=CACHEPAGESIZE(DeviceExt);
- FATOffset = (DeviceExt->FATStart * BLOCKSIZE) +
+ FATOffset = (DeviceExt->FATStart * BLOCKSIZE) +
(CurrentCluster * sizeof(ULONG));
Status = CcRosRequestCacheSegment(DeviceExt->StorageBcb,
- PAGE_ROUND_DOWN(FATOffset),
- &BaseAddress,
- &Valid,
- &CacheSeg);
+ ROUND_DOWN(FATOffset, ChunkSize),
+ &BaseAddress,
+ &Valid,
+ &CacheSeg);
if (!NT_SUCCESS(Status))
{
return(Status);
if (!Valid)
{
Status = VfatReadSectors(DeviceExt->StorageDevice,
- PAGE_ROUND_DOWN(FATOffset) / BLOCKSIZE,
- PAGESIZE / BLOCKSIZE,
- BaseAddress);
+ ROUND_DOWN(FATOffset, ChunkSize) / BLOCKSIZE,
+ ChunkSize / BLOCKSIZE,
+ BaseAddress);
if (!NT_SUCCESS(Status))
{
CcRosReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
}
}
- CurrentCluster = *(PULONG)(BaseAddress + (FATOffset % PAGESIZE));
+ CurrentCluster = *(PULONG)(BaseAddress + (FATOffset % ChunkSize));
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
CurrentCluster = 0xffffffff;
CcRosReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
}
NTSTATUS
-Fat16GetNextCluster (PDEVICE_EXTENSION DeviceExt,
- ULONG CurrentCluster,
- PULONG NextCluster)
+Fat16GetNextCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG CurrentCluster,
+ PULONG NextCluster)
/*
* FUNCTION: Retrieve the next FAT16 cluster from the FAT table
*/
}
NTSTATUS
-Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt,
- ULONG CurrentCluster,
- PULONG NextCluster)
+Fat12GetNextCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG CurrentCluster,
+ PULONG NextCluster)
/*
* FUNCTION: Retrieve the next FAT12 cluster from the FAT table
*/
{
- unsigned char* CBlock;
- ULONG FATOffset;
- ULONG Entry;
- BOOLEAN Valid;
- PCACHE_SEGMENT CacheSeg;
- NTSTATUS Status;
- PVOID BaseAddress;
-
- *NextCluster = 0;
-
- Status = CcRosRequestCacheSegment(DeviceExt->Fat12StorageBcb,
- 0,
- &BaseAddress,
- &Valid,
- &CacheSeg);
+ PUCHAR CBlock;
+ ULONG FATOffset;
+ ULONG Entry;
+ BOOLEAN Valid;
+ PCACHE_SEGMENT CacheSeg;
+ NTSTATUS Status;
+ PVOID BaseAddress;
+
+ *NextCluster = 0;
+
+ Status = CcRosRequestCacheSegment(DeviceExt->Fat12StorageBcb,
+ 0,
+ &BaseAddress,
+ &Valid,
+ &CacheSeg);
if (!NT_SUCCESS(Status))
{
return(Status);
}
NTSTATUS
-FAT16FindAvailableCluster (PDEVICE_EXTENSION DeviceExt,
- PULONG Cluster)
+FAT16FindAvailableCluster(PDEVICE_EXTENSION DeviceExt,
+ PULONG Cluster)
/*
* FUNCTION: Finds the first available cluster in a FAT16 table
*/
ChunkSize = CACHEPAGESIZE(DeviceExt);
FatStart = DeviceExt->FATStart * BLOCKSIZE;
- FatLength = DeviceExt->Boot->FATSectors * BLOCKSIZE;
+ FatLength = (((DeviceExt->Boot->Sectors ? DeviceExt->Boot->Sectors : DeviceExt->Boot->SectorsHuge)-DeviceExt->dataStart)/DeviceExt->Boot->SectorsPerCluster+2)*2;
+
CacheSeg = NULL;
*Cluster = 0;
for (i = 2; i < FatLength; i+=2)
- {
+ {
if (((FatStart + i) % ChunkSize) == 0 || CacheSeg == NULL)
{
if (CacheSeg != NULL)
}
NTSTATUS
-FAT12FindAvailableCluster (PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
+FAT12FindAvailableCluster(PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
/*
* FUNCTION: Finds the first available cluster in a FAT12 table
*/
ULONG numberofclusters;
*Cluster = 0;
-
+
Status = CcRosRequestCacheSegment(DeviceExt->Fat12StorageBcb,
0,
&BaseAddress,
* FUNCTION: Finds the first available cluster in a FAT32 table
*/
{
+ ULONG FatLength;
+ ULONG i;
+ NTSTATUS Status;
+ PVOID BaseAddress;
+ PCACHE_SEGMENT CacheSeg;
+ BOOLEAN Valid;
+ ULONG FatStart;
+ ULONG ChunkSize;
+
+ ChunkSize = CACHEPAGESIZE(DeviceExt);
+
+ FatStart = DeviceExt->FATStart * BLOCKSIZE;
+ FatLength = (((DeviceExt->Boot->Sectors ? DeviceExt->Boot->Sectors : DeviceExt->Boot->SectorsHuge)-DeviceExt->dataStart)/DeviceExt->Boot->SectorsPerCluster+2)*4;
+
+ CacheSeg = NULL;
+ *Cluster = 0;
+
+ for (i = 4; i < FatLength; i+=4)
+ {
+ if (((FatStart + i) % ChunkSize) == 0 || CacheSeg == NULL)
+ {
+ if (CacheSeg != NULL)
+ {
+ CcRosReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
+ }
+ Status = CcRosRequestCacheSegment(DeviceExt->StorageBcb,
+ ROUND_DOWN(FatStart + i, ChunkSize),
+ &BaseAddress,
+ &Valid,
+ &CacheSeg);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ if (!Valid)
+ {
+ Status = VfatReadSectors(DeviceExt->StorageDevice,
+ ROUND_DOWN(FatStart + i, ChunkSize) / BLOCKSIZE,
+ ChunkSize / BLOCKSIZE,
+ BaseAddress);
+ if (!NT_SUCCESS(Status))
+ {
+ CcRosReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
+ return(Status);
+ }
+ }
+ }
+ if (*((PULONG)(BaseAddress + ((FatStart + i) % ChunkSize))) == 0)
+ {
+ DPRINT("Found available cluster 0x%x\n", i);
+ *Cluster = i / 4;
+ CcRosReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
+ return(STATUS_SUCCESS);
+ }
+ }
+ CcRosReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
+#if 0
ULONG sector;
PULONG Block;
int i,forto;
}
/* Give an error message (out of disk space) if we reach here) */
ExFreePool (Block);
+#endif
return (STATUS_DISK_FULL);
}
return(STATUS_SUCCESS);
}
-#if 0
+
NTSTATUS
FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt,
PLARGE_INTEGER Clusters)
PUSHORT Block;
ULONG ulCount = 0;
ULONG i;
+ ULONG numberofclusters;
+ ULONG numberofsectors;
+ ULONG sector;
+ ULONG forto;
+ NTSTATUS Status;
ExAcquireResourceSharedLite (&DeviceExt->FatResource, TRUE);
+ Block = ExAllocatePool (NonPagedPool, BLOCKSIZE);
- Block = (PUSHORT) DeviceExt->FAT;
- for (i = 2; i < (DeviceExt->Boot->FATSectors * 256); i++)
+ numberofclusters = ((DeviceExt->Boot->Sectors ? DeviceExt->Boot->Sectors : DeviceExt->Boot->SectorsHuge)-DeviceExt->dataStart)/DeviceExt->Boot->SectorsPerCluster+2;
+ numberofsectors = (numberofclusters + 255) / 256;
+ numberofclusters %= 256;
+
+ for (sector = 0; sector < numberofsectors; sector++)
{
- if (Block[i] == 0)
- ulCount++;
- }
+ Status = VfatReadSectors(DeviceExt->StorageDevice,
+ DeviceExt->FATStart + sector,
+ 1,
+ (PUCHAR)Block);
+ if (!NT_SUCCESS(Status))
+ {
+ ExFreePool(Block);
+ ExReleaseResourceLite(&DeviceExt->FatResource);
+ return(Status);
+ }
+ if (sector == numberofsectors - 1)
+ forto = numberofclusters;
+ else
+ forto = 256;
+
+ for (i = 0; i < forto; i++)
+ {
+ if (Block[i] == 0)
+ ulCount++;
+ }
+ }
ExReleaseResourceLite (&DeviceExt->FatResource);
Clusters->QuadPart = ulCount;
return(STATUS_SUCCESS);
}
-#endif
+
NTSTATUS
FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt,
ULONG ulCount = 0;
ULONG i,forto;
ULONG numberofclusters;
+ ULONG numberofsectors;
NTSTATUS Status;
ExAcquireResourceSharedLite (&DeviceExt->FatResource, TRUE);
Block = ExAllocatePool (NonPagedPool, BLOCKSIZE);
numberofclusters = ((DeviceExt->Boot->Sectors ? DeviceExt->Boot->Sectors : DeviceExt->Boot->SectorsHuge)-DeviceExt->dataStart)/DeviceExt->Boot->SectorsPerCluster+2;
+ numberofsectors = (numberofclusters +127) / 128;
numberofclusters %= 128;
- for (sector = 0;
- sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32;
- sector++)
+ for (sector = 0; sector < numberofsectors; sector++)
{
Status = VfatReadSectors(DeviceExt->StorageDevice,
(ULONG) (DeviceExt->FATStart + sector), 1,
return(Status);
}
- if (sector==((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32-1)
- forto=numberofclusters;
- else
- forto=128;
+ if (sector == numberofsectors - 1)
+ forto=numberofclusters;
+ else
+ forto=128;
for (i = 0; i < forto; i++)
{
if (Block[i] == 0)
FATOffset = FATOffset + DeviceExt->Boot->FATSectors * BLOCKSIZE;
}
- return (STATUS_SUCCESS);
+ return(STATUS_SUCCESS);
}
NTSTATUS
* FUNCTION: Writes a cluster to the FAT32 physical tables
*/
{
-#if 0
- ULONG FATsector;
- ULONG FATeis;
- PUSHORT Block;
+ PVOID BaseAddress;
+ BOOLEAN Valid;
+ PCACHE_SEGMENT CacheSeg;
+ NTSTATUS Status;
+ ULONG FATOffset;
ULONG Start;
- int i;
- struct _BootSector32 *pBoot;
- DbgPrint ("FAT32WriteCluster %u : %u\n", ClusterToWrite, NewValue);
- Block = ExAllocatePool (NonPagedPool, BLOCKSIZE);
- FATsector = ClusterToWrite / 128;
- FATeis = ClusterToWrite - (FATsector * 128);
- /* load sector, change value, then rewrite sector */
- /* FIXME: Check status */
- VfatReadSectors (DeviceExt->StorageDevice,
- DeviceExt->FATStart + FATsector, 1, (UCHAR *) Block);
- Block[FATeis] = NewValue;
- /* Write the changed FAT sector to disk (all FAT's) */
- Start = DeviceExt->FATStart + FATsector;
- pBoot = (struct _BootSector32 *) DeviceExt->Boot;
- for (i = 0; i < pBoot->FATCount; i++)
- {
- /* FIXME: Check status */
- VfatWriteSectors (DeviceExt->StorageDevice, Start, 1, (UCHAR *) Block);
- Start += pBoot->FATSectors;
+ ULONG i;
+ ULONG ChunkSize;
+
+ ChunkSize = CACHEPAGESIZE(DeviceExt);
+
+ Start = DeviceExt->FATStart;
+
+ FATOffset = (Start * BLOCKSIZE) + (ClusterToWrite * 4);
+
+ for (i = 0; i < DeviceExt->Boot->FATCount; i++)
+ {
+ Status = CcRosRequestCacheSegment(DeviceExt->StorageBcb,
+ ROUND_DOWN(FATOffset, ChunkSize),
+ &BaseAddress,
+ &Valid,
+ &CacheSeg);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ if (!Valid)
+ {
+ Status = VfatReadSectors(DeviceExt->StorageDevice,
+ ROUND_DOWN(FATOffset, ChunkSize) / BLOCKSIZE,
+ ChunkSize / BLOCKSIZE,
+ BaseAddress);
+ if (!NT_SUCCESS(Status))
+ {
+ CcRosReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
+ return(Status);
+ }
+ }
+
+ DPRINT("Writing 0x%x for offset 0x%x 0x%x\n", NewValue, FATOffset,
+ ClusterToWrite);
+ *((PULONG)(BaseAddress + (FATOffset % ChunkSize))) = NewValue;
+ Status = VfatWriteSectors(DeviceExt->StorageDevice,
+ ROUND_DOWN(FATOffset, ChunkSize) / BLOCKSIZE,
+ ChunkSize / BLOCKSIZE,
+ BaseAddress);
+ CcRosReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
+
+ DPRINT("DeviceExt->Boot->FATSectors %d\n",
+ ((struct _BootSector32 *)DeviceExt->Boot)->FATSectors32);
+ FATOffset += ((struct _BootSector32 *)DeviceExt->Boot)->FATSectors32 * BLOCKSIZE;
}
- ExFreePool (Block);
-#endif
-// KeBugCheck(0);
return(STATUS_SUCCESS);
}
+
NTSTATUS
WriteCluster(PDEVICE_EXTENSION DeviceExt,
ULONG ClusterToWrite,
if (DeviceExt->FatType == FAT16)
{
- Status = FAT16WriteCluster (DeviceExt, ClusterToWrite, NewValue);
+ Status = FAT16WriteCluster(DeviceExt, ClusterToWrite, NewValue);
}
else if (DeviceExt->FatType == FAT32)
{
- Status = FAT32WriteCluster (DeviceExt, ClusterToWrite, NewValue);
+ Status = FAT32WriteCluster(DeviceExt, ClusterToWrite, NewValue);
}
else
{
- Status = FAT12WriteCluster (DeviceExt, ClusterToWrite, NewValue);
+ Status = FAT12WriteCluster(DeviceExt, ClusterToWrite, NewValue);
}
return(Status);
}
ULONG
-ClusterToSector (PDEVICE_EXTENSION DeviceExt, unsigned long Cluster)
+ClusterToSector(PDEVICE_EXTENSION DeviceExt,
+ ULONG Cluster)
/*
* FUNCTION: Converts the cluster number to a sector number for this physical
* device
if (FirstCluster == 1)
{
- Status = VfatReadSectors (DeviceExt->StorageDevice,
- Cluster,
- DeviceExt->Boot->SectorsPerCluster,
- Buffer);
+ Status = VfatReadSectors(DeviceExt->StorageDevice,
+ Cluster,
+ DeviceExt->Boot->SectorsPerCluster,
+ Buffer);
return(Status);
}
else
{
ULONG Sector;
- Sector = ClusterToSector (DeviceExt, Cluster);
+ Sector = ClusterToSector(DeviceExt, Cluster);
- Status = VfatReadSectors (DeviceExt->StorageDevice,
- Sector, DeviceExt->Boot->SectorsPerCluster,
- Buffer);
+ Status = VfatReadSectors(DeviceExt->StorageDevice,
+ Sector,
+ DeviceExt->Boot->SectorsPerCluster,
+ Buffer);
return(Status);
}
}
ULONG Sector;
NTSTATUS Status;
- DPRINT ("VfatWriteCluster(DeviceExt %x, Buffer %x, Cluster %d)\n",
- DeviceExt, Buffer, Cluster);
+ DPRINT("VfatWriteCluster(DeviceExt %x, Buffer %x, Cluster %d)\n",
+ DeviceExt, Buffer, Cluster);
if (FirstCluster == 1)
{
}
NTSTATUS
-GetNextCluster (PDEVICE_EXTENSION DeviceExt,
- ULONG CurrentCluster,
- PULONG NextCluster,
- BOOLEAN Extend)
+GetNextCluster(PDEVICE_EXTENSION DeviceExt,
+ ULONG CurrentCluster,
+ PULONG NextCluster,
+ BOOLEAN Extend)
/*
* FUNCTION: Retrieve the next cluster depending on the FAT type
*/
{
NTSTATUS Status;
-
-
+
// DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
// DeviceExt, CurrentCluster);
if (Extend)
{
- ExAcquireResourceSharedLite (&DeviceExt->FatResource, TRUE);
+ ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
}
else
{
- ExAcquireResourceExclusiveLite (&DeviceExt->FatResource, TRUE);
+ ExAcquireResourceExclusiveLite(&DeviceExt->FatResource, TRUE);
}
/*
if (DeviceExt->FatType == FAT16)
{
- Status = FAT16FindAvailableCluster (DeviceExt, &NewCluster);
+ Status = FAT16FindAvailableCluster(DeviceExt, &NewCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
}
else if (DeviceExt->FatType == FAT32)
{
- Status = FAT32FindAvailableCluster (DeviceExt, &NewCluster);
+ Status = FAT32FindAvailableCluster(DeviceExt, &NewCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
}
else
{
- Status = FAT12FindAvailableCluster (DeviceExt, &NewCluster);
+ Status = FAT12FindAvailableCluster(DeviceExt, &NewCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
if (DeviceExt->FatType == FAT16)
{
- Status = Fat16GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
+ Status = Fat16GetNextCluster(DeviceExt, CurrentCluster, NextCluster);
}
else if (DeviceExt->FatType == FAT32)
{
- Status = Fat32GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
+ Status = Fat32GetNextCluster(DeviceExt, CurrentCluster, NextCluster);
}
else
{
- Status = Fat12GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
+ Status = Fat12GetNextCluster(DeviceExt, CurrentCluster, NextCluster);
}
if (Extend && (*NextCluster) == 0xFFFFFFFF)
{
/* Firstly, find the next available open allocation unit */
if (DeviceExt->FatType == FAT16)
{
- Status = FAT16FindAvailableCluster (DeviceExt, &NewCluster);
+ Status = FAT16FindAvailableCluster(DeviceExt, &NewCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
}
else if (DeviceExt->FatType == FAT32)
{
- Status = FAT32FindAvailableCluster (DeviceExt, &NewCluster);
+ Status = FAT32FindAvailableCluster(DeviceExt, &NewCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
}
else
{
- Status = FAT12FindAvailableCluster (DeviceExt, &NewCluster);
+ Status = FAT12FindAvailableCluster(DeviceExt, &NewCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
}
}
/* Mark the new AU as the EOF */
- WriteCluster (DeviceExt, NewCluster, 0xFFFFFFFF);
+ WriteCluster(DeviceExt, NewCluster, 0xFFFFFFFF);
/* Now, write the AU of the LastCluster with the value of the newly
found AU */
- WriteCluster (DeviceExt, CurrentCluster, NewCluster);
+ WriteCluster(DeviceExt, CurrentCluster, NewCluster);
*NextCluster = NewCluster;
}
- ExReleaseResourceLite (&DeviceExt->FatResource);
+ ExReleaseResourceLite(&DeviceExt->FatResource);
- return (Status);
+ return(Status);
}
+
NTSTATUS
-GetNextSector (PDEVICE_EXTENSION DeviceExt,
- ULONG CurrentSector,
- PULONG NextSector,
- BOOLEAN Extend)
+GetNextSector(PDEVICE_EXTENSION DeviceExt,
+ ULONG CurrentSector,
+ PULONG NextSector,
+ BOOLEAN Extend)
/* Some functions don't have access to the cluster they're really reading from.
Maybe this is a dirty solution, but it will allow them to handle fragmentation. */
{
NTSTATUS Status;
- DPRINT ("GetNextSector(DeviceExt %x, CurrentSector %x)\n",DeviceExt, CurrentSector);
+ DPRINT("GetNextSector(DeviceExt %x, CurrentSector %x)\n",
+ DeviceExt,
+ CurrentSector);
if (CurrentSector<DeviceExt->dataStart || ((CurrentSector - DeviceExt->dataStart + 1) % DeviceExt -> Boot -> SectorsPerCluster))
/* Basically, if the next sequential sector would be on a cluster border, then we'll need to check in the FAT */
{
- (*NextSector)=CurrentSector+1;
- return (STATUS_SUCCESS);
+ (*NextSector)=CurrentSector+1;
+ return (STATUS_SUCCESS);
}
else
- {
- CurrentSector = (CurrentSector - DeviceExt->dataStart) / DeviceExt -> Boot -> SectorsPerCluster + 2;
+ {
+ CurrentSector = (CurrentSector - DeviceExt->dataStart) / DeviceExt -> Boot -> SectorsPerCluster + 2;
- Status = GetNextCluster(DeviceExt, CurrentSector, NextSector, Extend);
- if (!NT_SUCCESS(Status))
- {
- return(Status);
- }
- if ((*NextSector) == 0 || (*NextSector) == 0xffffffff)
- {
- /* The caller wants to know a sector. These FAT codes don't correspond to any sector. */
- return (STATUS_UNSUCCESSFUL);
- }
-
- (*NextSector)=ClusterToSector(DeviceExt,(*NextSector));
- return (STATUS_SUCCESS);
- }
+ Status = GetNextCluster(DeviceExt, CurrentSector, NextSector, Extend);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+ if ((*NextSector) == 0 || (*NextSector) == 0xffffffff)
+ {
+ /* The caller wants to know a sector. These FAT codes don't correspond to any sector. */
+ return(STATUS_UNSUCCESSFUL);
+ }
+
+ (*NextSector) = ClusterToSector(DeviceExt,(*NextSector));
+ return(STATUS_SUCCESS);
+ }
}
/* EOF */
-/* $Id: fcb.c,v 1.5 2001/07/14 18:21:23 ekohl Exp $
+/* $Id: fcb.c,v 1.6 2001/07/20 08:00:20 ekohl Exp $
*
*
* FILE: fcb.c
/* -------------------------------------------------------- PUBLICS */
-PVFATFCB vfatNewFCB (PWCHAR pFileName)
+PVFATFCB
+vfatNewFCB(PWCHAR pFileName)
{
PVFATFCB rcFCB;
return rcFCB;
}
-void vfatDestroyFCB (PVFATFCB pFCB)
+VOID
+vfatDestroyFCB(PVFATFCB pFCB)
{
ExFreePool (pFCB);
}
BOOL
-vfatFCBIsDirectory (PDEVICE_EXTENSION pVCB, PVFATFCB FCB)
+vfatFCBIsDirectory(PDEVICE_EXTENSION pVCB, PVFATFCB FCB)
{
return FCB->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY;
}
BOOL
-vfatFCBIsRoot (PVFATFCB FCB)
+vfatFCBIsRoot(PVFATFCB FCB)
{
return wcscmp (FCB->PathName, L"\\") == 0;
}
-void vfatGrabFCB (PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
+VOID
+vfatGrabFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
{
KIRQL oldIrql;
KeReleaseSpinLock (&pVCB->FcbListLock, oldIrql);
}
-void vfatReleaseFCB (PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
+VOID
+vfatReleaseFCB(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
{
KIRQL oldIrql;
KeReleaseSpinLock (&pVCB->FcbListLock, oldIrql);
}
-void vfatAddFCBToTable (PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
+VOID
+vfatAddFCBToTable(PDEVICE_EXTENSION pVCB, PVFATFCB pFCB)
{
KIRQL oldIrql;
KeReleaseSpinLock (&pVCB->FcbListLock, oldIrql);
}
-PVFATFCB
-vfatGrabFCBFromTable (PDEVICE_EXTENSION pVCB, PWSTR pFileName)
+PVFATFCB
+vfatGrabFCBFromTable(PDEVICE_EXTENSION pVCB, PWSTR pFileName)
{
KIRQL oldIrql;
PVFATFCB rcFCB;
}
NTSTATUS
-vfatRequestAndValidateRegion (PDEVICE_EXTENSION pDeviceExt,
- PVFATFCB pFCB,
- ULONG pOffset,
- PVOID * pBuffer,
- PCACHE_SEGMENT * pCacheSegment,
- BOOL pExtend)
+vfatRequestAndValidateRegion(PDEVICE_EXTENSION pDeviceExt,
+ PVFATFCB pFCB,
+ ULONG pOffset,
+ PVOID * pBuffer,
+ PCACHE_SEGMENT * pCacheSegment,
+ BOOL pExtend)
{
NTSTATUS status;
BOOLEAN valid;
ULONG currentCluster;
ULONG i;
- status = CcRosRequestCacheSegment(pFCB->RFCB.Bcb,
+ status = CcRosRequestCacheSegment(pFCB->RFCB.Bcb,
pOffset,
pBuffer,
&valid,
return CcRosReleaseCacheSegment (pFCB->RFCB.Bcb, pCacheSegment, TRUE);
}
-PVFATFCB
-vfatMakeRootFCB (PDEVICE_EXTENSION pVCB)
+PVFATFCB
+vfatMakeRootFCB(PDEVICE_EXTENSION pVCB)
{
PVFATFCB FCB;
- FCB = vfatNewFCB (L"\\");
- memset (FCB->entry.Filename, ' ', 11);
+ FCB = vfatNewFCB(L"\\");
+ memset(FCB->entry.Filename, ' ', 11);
FCB->entry.FileSize = pVCB->rootDirectorySectors * BLOCKSIZE;
FCB->entry.Attrib = FILE_ATTRIBUTE_DIRECTORY;
if (pVCB->FatType == FAT32)
- {
- FCB->entry.FirstCluster = 2;
- }
+ {
+ FCB->entry.FirstCluster = ((struct _BootSector32*)(pVCB->Boot))->RootCluster;
+ }
else
- {
- FCB->entry.FirstCluster = 1;
- }
+ {
+ FCB->entry.FirstCluster = 1;
+ }
FCB->RefCount = 1;
- vfatFCBInitializeCache (pVCB, FCB);
- vfatAddFCBToTable (pVCB, FCB);
+ vfatFCBInitializeCache(pVCB, FCB);
+ vfatAddFCBToTable(pVCB, FCB);
vfatGrabFCB(pVCB, FCB);
- return FCB;
+ return(FCB);
}
-PVFATFCB
-vfatOpenRootFCB (PDEVICE_EXTENSION pVCB)
+PVFATFCB
+vfatOpenRootFCB(PDEVICE_EXTENSION pVCB)
{
PVFATFCB FCB;
}
NTSTATUS
-vfatMakeFCBFromDirEntry (PVCB vcb,
- PVFATFCB directoryFCB,
- PWSTR longName,
- PFAT_DIR_ENTRY dirEntry,
- PVFATFCB * fileFCB)
+vfatMakeFCBFromDirEntry(PVCB vcb,
+ PVFATFCB directoryFCB,
+ PWSTR longName,
+ PFAT_DIR_ENTRY dirEntry,
+ PVFATFCB * fileFCB)
{
PVFATFCB rcFCB;
WCHAR pathName [MAX_PATH];
- if (longName [0] != 0 && wcslen (directoryFCB->PathName) +
+ if (longName [0] != 0 && wcslen (directoryFCB->PathName) +
sizeof(WCHAR) + wcslen (longName) > MAX_PATH)
{
return STATUS_OBJECT_NAME_INVALID;
-/* $Id: iface.c,v 1.56 2001/07/17 07:48:06 ekohl Exp $
+/* $Id: iface.c,v 1.57 2001/07/20 08:00:20 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
Status = VfatReadSectors(DeviceToMount, 0, 1, (UCHAR *) Boot);
if (!NT_SUCCESS(Status))
{
- return Status;
+ return(Status);
}
DPRINT("Boot->SysType %.5s\n", Boot->SysType);
ExFreePool(Boot);
- return STATUS_SUCCESS;
+ return(STATUS_SUCCESS);
}
static NTSTATUS
-VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
+VfatMountDevice(PDEVICE_EXTENSION DeviceExt,
+ PDEVICE_OBJECT DeviceToMount)
/*
* FUNCTION: Mounts the device
*/
Status = VfatReadSectors(DeviceToMount, 0, 1, (UCHAR *) DeviceExt->Boot);
if (!NT_SUCCESS(Status))
{
- return Status;
+ return(Status);
}
DeviceExt->FATStart = DeviceExt->Boot->ReservedSectors;
DbgPrint("FAT32\n");
DeviceExt->FatType = FAT32;
DeviceExt->rootDirectorySectors = DeviceExt->Boot->SectorsPerCluster;
- DeviceExt->rootStart =
- DeviceExt->FATStart + DeviceExt->Boot->FATCount
+ DeviceExt->dataStart = DeviceExt->FATStart + DeviceExt->Boot->FATCount
* ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32;
- DeviceExt->dataStart = DeviceExt->rootStart;
+ DeviceExt->rootStart = ClusterToSector (DeviceExt,
+ ((struct _BootSector32 *)(DeviceExt->Boot))->RootCluster);
}
else
{
DeviceExt->FatType = FAT16;
}
- return STATUS_SUCCESS;
+ return(STATUS_SUCCESS);
}
* FUNCTION: Mount the filesystem
*/
{
- PDEVICE_OBJECT DeviceObject;
- PDEVICE_EXTENSION DeviceExt;
- BOOLEAN RecognizedFS;
- NTSTATUS Status;
-
- Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS);
- if (!NT_SUCCESS(Status))
- {
- return Status;
- }
-
- if (RecognizedFS == FALSE)
- {
- DPRINT("VFAT: Unrecognized Volume\n");
- return STATUS_UNRECOGNIZED_VOLUME;
- }
-
- DPRINT("VFAT: Recognized volume\n");
-
- Status = IoCreateDevice(VfatDriverObject,
- sizeof (DEVICE_EXTENSION),
- NULL,
- FILE_DEVICE_FILE_SYSTEM,
- 0,
- FALSE,
- &DeviceObject);
- if (!NT_SUCCESS(Status))
- {
- return Status;
- }
-
- DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
- DeviceExt = (PVOID) DeviceObject->DeviceExtension;
- /* use same vpb as device disk */
- DeviceObject->Vpb = DeviceToMount->Vpb;
- Status = VfatMountDevice (DeviceExt, DeviceToMount);
- if (!NT_SUCCESS(Status))
- {
- /* FIXME: delete device object */
- return Status;
- }
-
- DeviceObject->Vpb->Flags |= VPB_MOUNTED;
- DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
- DeviceToMount);
- DeviceExt->StreamStorageDevice = IoCreateStreamFileObject(NULL,
- DeviceExt->StorageDevice);
- if (DeviceExt->FatType == FAT16)
- Status = CcRosInitializeFileCache(DeviceExt->StreamStorageDevice,
- &DeviceExt->StorageBcb,
- CACHEPAGESIZE(DeviceExt));
- else
- Status = CcRosInitializeFileCache(DeviceExt->StreamStorageDevice,
- &DeviceExt->StorageBcb,
- PAGESIZE);
- if (!NT_SUCCESS(Status))
- {
- /* FIXME: delete device object */
- return Status;
- }
-
- if (DeviceExt->FatType == FAT12)
- {
- DeviceExt->Fat12StorageDevice =
- IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
- Status = CcRosInitializeFileCache(DeviceExt->Fat12StorageDevice,
- &DeviceExt->Fat12StorageBcb,
- PAGESIZE * 3);
- if (!NT_SUCCESS(Status))
- {
- /* FIXME: delete device object */
- return Status;
- }
- }
- ExInitializeResourceLite (&DeviceExt->DirResource);
- ExInitializeResourceLite (&DeviceExt->FatResource);
-
- KeInitializeSpinLock (&DeviceExt->FcbListLock);
- InitializeListHead (&DeviceExt->FcbListHead);
-
- /* read serial number */
- if (DeviceExt->FatType == FAT12 || DeviceExt->FatType == FAT16)
- DeviceObject->Vpb->SerialNumber =
- ((struct _BootSector *) (DeviceExt->Boot))->VolumeID;
- else if (DeviceExt->FatType == FAT32)
- DeviceObject->Vpb->SerialNumber =
- ((struct _BootSector32 *) (DeviceExt->Boot))->VolumeID;
-
- /* read volume label */
- ReadVolumeLabel(DeviceExt, DeviceObject->Vpb);
-
- return STATUS_SUCCESS;
+ PDEVICE_OBJECT DeviceObject;
+ PDEVICE_EXTENSION DeviceExt;
+ BOOLEAN RecognizedFS;
+ NTSTATUS Status;
+
+ Status = VfatHasFileSystem (DeviceToMount, &RecognizedFS);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ if (RecognizedFS == FALSE)
+ {
+ DPRINT("VFAT: Unrecognized Volume\n");
+ return(STATUS_UNRECOGNIZED_VOLUME);
+ }
+
+ DPRINT("VFAT: Recognized volume\n");
+
+ Status = IoCreateDevice(VfatDriverObject,
+ sizeof (DEVICE_EXTENSION),
+ NULL,
+ FILE_DEVICE_FILE_SYSTEM,
+ 0,
+ FALSE,
+ &DeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ return(Status);
+ }
+
+ DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
+ DeviceExt = (PVOID) DeviceObject->DeviceExtension;
+ /* use same vpb as device disk */
+ DeviceObject->Vpb = DeviceToMount->Vpb;
+ Status = VfatMountDevice(DeviceExt,
+ DeviceToMount);
+ if (!NT_SUCCESS(Status))
+ {
+ /* FIXME: delete device object */
+ return(Status);
+ }
+
+#if 1
+ DbgPrint("BytesPerSector: %d\n", DeviceExt->Boot->BytesPerSector);
+ DbgPrint("SectorsPerCluster: %d\n", DeviceExt->Boot->SectorsPerCluster);
+ DbgPrint("ReservedSectors: %d\n", DeviceExt->Boot->ReservedSectors);
+ DbgPrint("FATCount: %d\n", DeviceExt->Boot->FATCount);
+ DbgPrint("RootEntries: %d\n", DeviceExt->Boot->RootEntries);
+ DbgPrint("Sectors: %d\n", DeviceExt->Boot->Sectors);
+ DbgPrint("FATSectors: %d\n", DeviceExt->Boot->FATSectors);
+ DbgPrint("SectorsPerTrack: %d\n", DeviceExt->Boot->SectorsPerTrack);
+ DbgPrint("Heads: %d\n", DeviceExt->Boot->Heads);
+ DbgPrint("HiddenSectors: %d\n", DeviceExt->Boot->HiddenSectors);
+ DbgPrint("SectorsHuge: %d\n", DeviceExt->Boot->SectorsHuge);
+ DbgPrint("RootStart: %d\n", DeviceExt->rootStart);
+ DbgPrint("DataStart: %d\n", DeviceExt->dataStart);
+ if (DeviceExt->FatType == FAT32)
+ {
+ DbgPrint("FATSectors32: %d\n",
+ ((struct _BootSector32*)(DeviceExt->Boot))->FATSectors32);
+ DbgPrint("RootCluster: %d\n",
+ ((struct _BootSector32*)(DeviceExt->Boot))->RootCluster);
+ DbgPrint("FSInfoSector: %d\n",
+ ((struct _BootSector32*)(DeviceExt->Boot))->FSInfoSector);
+ DbgPrint("BootBackup: %d\n",
+ ((struct _BootSector32*)(DeviceExt->Boot))->BootBackup);
+ }
+#endif
+
+ DeviceObject->Vpb->Flags |= VPB_MOUNTED;
+ DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
+ DeviceToMount);
+ DeviceExt->StreamStorageDevice = IoCreateStreamFileObject(NULL,
+ DeviceExt->StorageDevice);
+ Status = CcRosInitializeFileCache(DeviceExt->StreamStorageDevice,
+ &DeviceExt->StorageBcb,
+ CACHEPAGESIZE(DeviceExt));
+ if (!NT_SUCCESS(Status))
+ {
+ /* FIXME: delete device object */
+ return(Status);
+ }
+
+ if (DeviceExt->FatType == FAT12)
+ {
+ DeviceExt->Fat12StorageDevice =
+ IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
+ Status = CcRosInitializeFileCache(DeviceExt->Fat12StorageDevice,
+ &DeviceExt->Fat12StorageBcb,
+ PAGESIZE * 3);
+ if (!NT_SUCCESS(Status))
+ {
+ /* FIXME: delete device object */
+ return(Status);
+ }
+ }
+ ExInitializeResourceLite(&DeviceExt->DirResource);
+ ExInitializeResourceLite(&DeviceExt->FatResource);
+
+ KeInitializeSpinLock(&DeviceExt->FcbListLock);
+ InitializeListHead(&DeviceExt->FcbListHead);
+
+ /* read serial number */
+ if (DeviceExt->FatType == FAT12 || DeviceExt->FatType == FAT16)
+ DeviceObject->Vpb->SerialNumber =
+ ((struct _BootSector *) (DeviceExt->Boot))->VolumeID;
+ else if (DeviceExt->FatType == FAT32)
+ DeviceObject->Vpb->SerialNumber =
+ ((struct _BootSector32 *) (DeviceExt->Boot))->VolumeID;
+
+ /* read volume label */
+ ReadVolumeLabel(DeviceExt,
+ DeviceObject->Vpb);
+
+ return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
-VfatFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
+VfatFileSystemControl(PDEVICE_OBJECT DeviceObject,
+ PIRP Irp)
/*
* FUNCTION: File system control
*/
-/* $Id: rw.c,v 1.24 2001/05/04 01:21:45 rex Exp $
+/* $Id: rw.c,v 1.25 2001/07/20 08:00:20 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
assert (FileObject != NULL);
assert (FileObject->FsContext != NULL);
- DPRINT ("VfatReadFile(DeviceExt %x, FileObject %x, Buffer %x, "
- "Length %d, ReadOffset 0x%x)\n", DeviceExt, FileObject, Buffer,
- Length, ReadOffset);
+ DPRINT("VfatReadFile(DeviceExt %x, FileObject %x, Buffer %x, "
+ "Length %d, ReadOffset 0x%x)\n", DeviceExt, FileObject, Buffer,
+ Length, ReadOffset);
+
+ *LengthRead = 0;
Fcb = ((PVFATCCB)FileObject->FsContext2)->pFcb;
* Find the first cluster
*/
if (DeviceExt->FatType == FAT32)
- CurrentCluster = Fcb->entry.FirstCluster
+ CurrentCluster = Fcb->entry.FirstCluster
+ Fcb->entry.FirstClusterHigh * 65536;
else
CurrentCluster = Fcb->entry.FirstCluster;
ChunkSize = PAGESIZE;
}
- *LengthRead = 0;
-
/*
* Find the cluster to start the read from
* FIXME: Optimize by remembering the last cluster read and using if
* possible.
*/
- Status = OffsetToCluster(DeviceExt,
- FirstCluster,
+ Status = OffsetToCluster(DeviceExt,
+ FirstCluster,
ROUND_DOWN(ReadOffset, ChunkSize),
&CurrentCluster,
FALSE);
-/* $Id: vfat.h,v 1.32 2001/07/05 01:51:53 rex Exp $ */
+/* $Id: vfat.h,v 1.33 2001/07/20 08:00:21 ekohl Exp $ */
#include <ddk/ntifs.h>
-struct _BootSector {
+struct _BootSector
+{
unsigned char magic0, res0, magic1;
unsigned char OEMName[8];
unsigned short BytesPerSector;
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;
-/* $Id: volume.c,v 1.10 2001/06/14 10:02:59 ekohl Exp $
+/* $Id: volume.c,v 1.11 2001/07/20 08:00:21 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
FsSizeInfo->TotalAllocationUnits.QuadPart = ((BootSect->Sectors ? BootSect->Sectors : BootSect->SectorsHuge)-DeviceExt->dataStart)/BootSect->SectorsPerCluster;
if (DeviceExt->FatType == FAT16)
-#if 0
Status = FAT16CountAvailableClusters(DeviceExt,
&FsSizeInfo->AvailableAllocationUnits);
-#else
- {
- FsSizeInfo->AvailableAllocationUnits.QuadPart = 0;
- Status = STATUS_SUCCESS;
- }
-#endif
else
Status = FAT12CountAvailableClusters(DeviceExt,
&FsSizeInfo->AvailableAllocationUnits);
FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
PFILE_FS_LABEL_INFORMATION FsLabelInfo)
{
- DPRINT("FsdSetFsLabelInformation()\n");
-
- return STATUS_NOT_IMPLEMENTED;
+ DPRINT("FsdSetFsLabelInformation()\n");
+
+ return(STATUS_NOT_IMPLEMENTED);
}
* FUNCTION: Set the specified volume information
*/
{
- PIO_STACK_LOCATION Stack;
- FS_INFORMATION_CLASS FsInformationClass;
-// PFILE_OBJECT FileObject = NULL;
-// PVFATFCB FCB = NULL;
- NTSTATUS Status = STATUS_SUCCESS;
- PVOID SystemBuffer;
- ULONG BufferLength;
-
- /* PRECONDITION */
- assert(DeviceObject != NULL);
- assert(Irp != NULL);
-
- DPRINT("FsdSetVolumeInformation(DeviceObject %x, Irp %x)\n",
- DeviceObject,
- Irp);
-
- Stack = IoGetCurrentIrpStackLocation (Irp);
- FsInformationClass = Stack->Parameters.SetVolume.FsInformationClass;
- BufferLength = Stack->Parameters.SetVolume.Length;
- SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
-// FileObject = Stack->FileObject;
-// FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb;
-
- DPRINT("FsInformationClass %d\n", FsInformationClass);
- DPRINT("BufferLength %d\n", BufferLength);
- DPRINT("SystemBuffer %x\n", SystemBuffer);
-
- switch (FsInformationClass)
- {
- case FileFsLabelInformation:
- Status = FsdSetFsLabelInformation(DeviceObject,
- SystemBuffer);
- break;
-
- default:
- Status = STATUS_NOT_SUPPORTED;
- }
-
- Irp->IoStatus.Status = Status;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp,
- IO_NO_INCREMENT);
-
- return(Status);
+ PIO_STACK_LOCATION Stack;
+ FS_INFORMATION_CLASS FsInformationClass;
+// PFILE_OBJECT FileObject = NULL;
+// PVFATFCB FCB = NULL;
+ NTSTATUS Status = STATUS_SUCCESS;
+ PVOID SystemBuffer;
+ ULONG BufferLength;
+
+ /* PRECONDITION */
+ assert(DeviceObject != NULL);
+ assert(Irp != NULL);
+
+ DPRINT("FsdSetVolumeInformation(DeviceObject %x, Irp %x)\n",
+ DeviceObject,
+ Irp);
+
+ Stack = IoGetCurrentIrpStackLocation(Irp);
+ FsInformationClass = Stack->Parameters.SetVolume.FsInformationClass;
+ BufferLength = Stack->Parameters.SetVolume.Length;
+ SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
+// FileObject = Stack->FileObject;
+// FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb;
+
+ DPRINT("FsInformationClass %d\n", FsInformationClass);
+ DPRINT("BufferLength %d\n", BufferLength);
+ DPRINT("SystemBuffer %x\n", SystemBuffer);
+
+ switch(FsInformationClass)
+ {
+ case FileFsLabelInformation:
+ Status = FsdSetFsLabelInformation(DeviceObject,
+ SystemBuffer);
+ break;
+
+ default:
+ Status = STATUS_NOT_SUPPORTED;
+ }
+
+ Irp->IoStatus.Status = Status;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp,
+ IO_NO_INCREMENT);
+
+ return(Status);
}
/* EOF */