else
{
*RecognizedFS = TRUE;
- }
+ }
if (*RecognizedFS)
{
}
Offset.QuadPart = 0;
-
+
/* Try to recognize FAT12/FAT16/FAT32 partitions */
Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE);
if (NT_SUCCESS(Status))
if (*RecognizedFS &&
Boot->BytesPerSector != 512 &&
Boot->BytesPerSector != 1024 &&
- Boot->BytesPerSector != 2048 &&
+ Boot->BytesPerSector != 2048 &&
Boot->BytesPerSector != 4096)
{
DPRINT1("BytesPerSector %d\n", Boot->BytesPerSector);
}
if (*RecognizedFS &&
- Boot->FATCount != 1 &&
+ Boot->FATCount != 1 &&
Boot->FATCount != 2)
{
DPRINT1("FATCount %d\n", Boot->FATCount);
}
if (*RecognizedFS &&
- Boot->Media != 0xf0 &&
+ Boot->Media != 0xf0 &&
Boot->Media != 0xf8 &&
Boot->Media != 0xf9 &&
- Boot->Media != 0xfa &&
+ Boot->Media != 0xfa &&
Boot->Media != 0xfb &&
Boot->Media != 0xfc &&
Boot->Media != 0xfd &&
- Boot->Media != 0xfe &&
+ Boot->Media != 0xfe &&
Boot->Media != 0xff)
{
DPRINT1("Media %02x\n", Boot->Media);
if (*RecognizedFS &&
Boot->SectorsPerCluster != 1 &&
Boot->SectorsPerCluster != 2 &&
- Boot->SectorsPerCluster != 4 &&
+ Boot->SectorsPerCluster != 4 &&
Boot->SectorsPerCluster != 8 &&
Boot->SectorsPerCluster != 16 &&
- Boot->SectorsPerCluster != 32 &&
+ Boot->SectorsPerCluster != 32 &&
Boot->SectorsPerCluster != 64 &&
Boot->SectorsPerCluster != 128)
{
CHECKPOINT1;
*RecognizedFS = FALSE;
}
-
+
if (pFatInfo && *RecognizedFS)
{
*pFatInfo = FatInfo;
}
Offset.QuadPart = 0;
-
+
/* Try to recognize FATX16/FATX32 partitions (Xbox) */
Status = VfatReadDisk(DeviceToMount, &Offset, sizeof(struct _BootSectorFatX), (PUCHAR) BootFatX, FALSE);
if (NT_SUCCESS(Status))
DPRINT1("SysType %c%c%c%c\n", BootFatX->SysType[0], BootFatX->SysType[1], BootFatX->SysType[2], BootFatX->SysType[3]);
*RecognizedFS=FALSE;
}
-
+
if (*RecognizedFS &&
BootFatX->SectorsPerCluster != 1 &&
BootFatX->SectorsPerCluster != 2 &&
- BootFatX->SectorsPerCluster != 4 &&
+ BootFatX->SectorsPerCluster != 4 &&
BootFatX->SectorsPerCluster != 8 &&
BootFatX->SectorsPerCluster != 16 &&
- BootFatX->SectorsPerCluster != 32 &&
+ BootFatX->SectorsPerCluster != 32 &&
BootFatX->SectorsPerCluster != 64 &&
BootFatX->SectorsPerCluster != 128)
{
DPRINT1("SectorsPerCluster %lu\n", BootFatX->SectorsPerCluster);
*RecognizedFS=FALSE;
}
-
+
if (*RecognizedFS)
{
FatInfo.BytesPerSector = DiskGeometry.BytesPerSector;
FatInfo.VolumeID = BootFatX->VolumeID;
FatInfo.FATStart = sizeof(struct _BootSectorFatX) / DiskGeometry.BytesPerSector;
FatInfo.FATCount = BootFatX->FATCount;
- FatInfo.FATSectors =
+ FatInfo.FATSectors =
ROUND_UP(FatInfo.Sectors / FatInfo.SectorsPerCluster * (FatInfo.FatType == FATX16 ? 2 : 4), 4096) /
FatInfo.BytesPerSector;
FatInfo.rootStart = FatInfo.FATStart + FatInfo.FATCount * FatInfo.FATSectors;
FatInfo.dataStart = FatInfo.rootStart + FatInfo.rootDirectorySectors;
FatInfo.NumberOfClusters = (FatInfo.Sectors - FatInfo.dataStart) / FatInfo.SectorsPerCluster;
-
+
if (pFatInfo && *RecognizedFS)
{
*pFatInfo = FatInfo;
}
ExFreePool(BootFatX);
}
-
+
DPRINT("VfatHasFileSystem done\n");
return Status;
}
DeviceExt->CleanShutBitMask = 0x80000000;
break;
}
-
+
if (DeviceExt->FatInfo.FatType == FATX16
|| DeviceExt->FatInfo.FatType == FATX32)
{
/* read volume label */
ReadVolumeLabel(DeviceExt, DeviceObject->Vpb);
-
+
/* read clean shutdown bit status */
Status = GetNextCluster(DeviceExt, 1, &eocMark);
if (NT_SUCCESS(Status))
{
/*
* FIXME:
- * Preformated floppy disks have very often a serial number of 0000:0000.
- * We should calculate a crc sum over the sectors from the root directory as secondary volume number.
+ * Preformated floppy disks have very often a serial number of 0000:0000.
+ * We should calculate a crc sum over the sectors from the root directory as secondary volume number.
* Each write to the root directory must update this crc sum.
*/
-
+
}
else
{
Status = STATUS_WRONG_VOLUME;
}
}
-
+
return Status;
}
}
-static NTSTATUS
+static NTSTATUS
VfatGetRetrievalPointers(PVFAT_IRP_CONTEXT IrpContext)
{
PIO_STACK_LOCATION Stack;
Fcb = FileObject->FsContext;
ExAcquireResourceSharedLite(&Fcb->MainResource, TRUE);
-
+
Vcn = *(PLARGE_INTEGER)Stack->Parameters.DeviceIoControl.Type3InputBuffer;
RetrievalPointers = IrpContext->Irp->UserBuffer;
}
CurrentCluster = FirstCluster = vfatDirEntryGetFirstCluster(DeviceExt, &Fcb->entry);
- Status = OffsetToCluster(DeviceExt, FirstCluster,
- Vcn.u.LowPart * DeviceExt->FatInfo.BytesPerCluster,
+ Status = OffsetToCluster(DeviceExt, FirstCluster,
+ Vcn.u.LowPart * DeviceExt->FatInfo.BytesPerCluster,
&CurrentCluster, FALSE);
if (!NT_SUCCESS(Status))
{
{
goto ByeBye;
}
-
+
if (LastCluster + 1 != CurrentCluster)
{
RetrievalPointers->Extents[RetrievalPointers->ExtentCount].NextVcn = Vcn;
}
}
}
-
+
IrpContext->Irp->IoStatus.Information = sizeof(RETRIEVAL_POINTERS_BUFFER) + (sizeof(RetrievalPointers->Extents[0]) * (RetrievalPointers->ExtentCount - 1));
Status = STATUS_SUCCESS;
VfatIsVolumeDirty(PVFAT_IRP_CONTEXT IrpContext)
{
PULONG Flags;
-
+
DPRINT("VfatIsVolumeDirty(IrpContext %x)\n", IrpContext);
-
+
if (IrpContext->Stack->Parameters.FileSystemControl.OutputBufferLength != sizeof(ULONG))
return STATUS_INVALID_BUFFER_SIZE;
else if (!IrpContext->Irp->AssociatedIrp.SystemBuffer)
return STATUS_INVALID_USER_BUFFER;
-
+
Flags = (PULONG)IrpContext->Irp->AssociatedIrp.SystemBuffer;
*Flags = 0;
-
+
if (IrpContext->DeviceExt->VolumeFcb->Flags & VCB_IS_DIRTY
&& !(IrpContext->DeviceExt->VolumeFcb->Flags & VCB_CLEAR_DIRTY))
{
*Flags |= VOLUME_IS_DIRTY;
}
-
+
return STATUS_SUCCESS;
}
ULONG eocMark;
PDEVICE_EXTENSION DeviceExt;
NTSTATUS Status = STATUS_SUCCESS;
-
+
DPRINT("VfatMarkVolumeDirty(IrpContext %x)\n", IrpContext);
DeviceExt = IrpContext->DeviceExt;
-
+
if (!(DeviceExt->VolumeFcb->Flags & VCB_IS_DIRTY))
{
Status = GetNextCluster(DeviceExt, 1, &eocMark);
Status = WriteCluster(DeviceExt, 1, eocMark);
}
}
-
+
DeviceExt->VolumeFcb->Flags &= ~VCB_CLEAR_DIRTY;
-
+
return Status;
}