mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 04:35:53 +00:00
Implemented MmAllocateContinuousMemory
VFAT driver cleanups svn path=/trunk/; revision=1487
This commit is contained in:
parent
1f1ae27105
commit
ed20b9b6ba
18 changed files with 2841 additions and 2685 deletions
|
@ -18,10 +18,9 @@
|
|||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector,
|
||||
IN ULONG SectorCount,
|
||||
IN UCHAR* Buffer)
|
||||
BOOLEAN
|
||||
VFATReadSectors (IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector, IN ULONG SectorCount, IN UCHAR * Buffer)
|
||||
{
|
||||
LARGE_INTEGER sectorNumber;
|
||||
PIRP irp;
|
||||
|
@ -38,13 +37,10 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
|||
|
||||
|
||||
DPRINT ("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
|
||||
pDeviceObject,
|
||||
DiskSector,
|
||||
Buffer);
|
||||
pDeviceObject, DiskSector, Buffer);
|
||||
DPRINT ("sectorNumber %08lx:%08lx sectorSize %ld\n",
|
||||
(unsigned long int) sectorNumber.u.LowPart,
|
||||
(unsigned long int)sectorNumber.u.HighPart,
|
||||
sectorSize);
|
||||
(unsigned long int) sectorNumber.u.HighPart, sectorSize);
|
||||
|
||||
|
||||
DPRINT ("Building synchronous FSD Request...\n");
|
||||
|
@ -52,39 +48,32 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
|||
pDeviceObject,
|
||||
Buffer,
|
||||
sectorSize,
|
||||
§orNumber,
|
||||
&event,
|
||||
&ioStatus );
|
||||
§orNumber, &event, &ioStatus);
|
||||
|
||||
if (!irp) {
|
||||
if (!irp)
|
||||
{
|
||||
DbgPrint ("READ failed!!!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DPRINT ("Calling IO Driver... with irp %x\n", irp);
|
||||
status = IoCallDriver(pDeviceObject,
|
||||
irp);
|
||||
status = IoCallDriver (pDeviceObject, irp);
|
||||
|
||||
DPRINT ("Waiting for IO Operation for %x\n", irp);
|
||||
if (status == STATUS_PENDING)
|
||||
{
|
||||
DPRINT ("Operation pending\n");
|
||||
KeWaitForSingleObject(&event,
|
||||
Suspended,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL);
|
||||
DPRINT ("Getting IO Status... for %x\n", irp);
|
||||
status = ioStatus.Status;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
if (!NT_SUCCESS (status))
|
||||
{
|
||||
DbgPrint ("IO failed!!! VFATREadSectors : Error code: %x\n", status);
|
||||
DbgPrint("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n",
|
||||
pDeviceObject,
|
||||
DiskSector,
|
||||
Buffer,
|
||||
sectorNumber.u.HighPart,
|
||||
DbgPrint
|
||||
("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n",
|
||||
pDeviceObject, DiskSector, Buffer, sectorNumber.u.HighPart,
|
||||
sectorNumber.u.LowPart);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -92,10 +81,10 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
BOOLEAN
|
||||
VFATWriteSectors (IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector,
|
||||
IN ULONG SectorCount,
|
||||
IN UCHAR* Buffer)
|
||||
IN ULONG SectorCount, IN UCHAR * Buffer)
|
||||
{
|
||||
LARGE_INTEGER sectorNumber;
|
||||
PIRP irp;
|
||||
|
@ -119,31 +108,27 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
|
|||
pDeviceObject,
|
||||
Buffer,
|
||||
sectorSize,
|
||||
§orNumber,
|
||||
&event,
|
||||
&ioStatus );
|
||||
§orNumber, &event, &ioStatus);
|
||||
|
||||
if (!irp) {
|
||||
if (!irp)
|
||||
{
|
||||
DbgPrint ("WRITE failed!!!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DPRINT ("Calling IO Driver...\n");
|
||||
status = IoCallDriver(pDeviceObject,
|
||||
irp);
|
||||
status = IoCallDriver (pDeviceObject, irp);
|
||||
|
||||
DPRINT ("Waiting for IO Operation...\n");
|
||||
if (status == STATUS_PENDING) {
|
||||
KeWaitForSingleObject(&event,
|
||||
Suspended,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
if (status == STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL);
|
||||
DPRINT ("Getting IO Status...\n");
|
||||
status = ioStatus.Status;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
if (!NT_SUCCESS (status))
|
||||
{
|
||||
DbgPrint ("IO failed!!! VFATWriteSectors : Error code: %x\n", status);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -151,4 +136,3 @@ BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
|
|||
DPRINT ("Block request succeeded\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: close.c,v 1.2 2000/09/12 10:12:13 jean Exp $
|
||||
/* $Id: close.c,v 1.3 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -18,7 +18,8 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
||||
NTSTATUS
|
||||
VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
||||
/*
|
||||
* FUNCTION: Closes a file
|
||||
*/
|
||||
|
@ -53,7 +54,8 @@ NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Closes a file
|
||||
*/
|
||||
|
@ -65,7 +67,7 @@ NTSTATUS STDCALL FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
DPRINT ("FsdClose(DeviceObject %x, Irp %x)\n", DeviceObject, Irp);
|
||||
|
||||
Status = FsdCloseFile(DeviceExtension,FileObject);
|
||||
Status = VfatCloseFile (DeviceExtension, FileObject);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.9 2000/12/08 17:12:43 jean Exp $
|
||||
/* $Id: create.c,v 1.10 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -11,7 +11,6 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <ddk/cctypes.h>
|
||||
#include <wchar.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
@ -22,7 +21,8 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
BOOLEAN IsLastEntry(PVOID Block, ULONG Offset)
|
||||
BOOLEAN
|
||||
IsLastEntry (PVOID Block, ULONG Offset)
|
||||
/*
|
||||
* FUNCTION: Determine if the given directory entry is the last
|
||||
*/
|
||||
|
@ -30,26 +30,32 @@ BOOLEAN IsLastEntry(PVOID Block, ULONG Offset)
|
|||
return (((FATDirEntry *) Block)[Offset].Filename[0] == 0);
|
||||
}
|
||||
|
||||
BOOLEAN IsVolEntry(PVOID Block, ULONG Offset)
|
||||
BOOLEAN
|
||||
IsVolEntry (PVOID Block, ULONG Offset)
|
||||
/*
|
||||
* FUNCTION: Determine if the given directory entry is a vol entry
|
||||
*/
|
||||
{
|
||||
if( (((FATDirEntry *)Block)[Offset].Attrib)==0x28 ) return TRUE;
|
||||
else return FALSE;
|
||||
if ((((FATDirEntry *) Block)[Offset].Attrib) == 0x28)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN IsDeletedEntry(PVOID Block, ULONG Offset)
|
||||
BOOLEAN
|
||||
IsDeletedEntry (PVOID Block, ULONG Offset)
|
||||
/*
|
||||
* FUNCTION: Determines if the given entry is a deleted one
|
||||
*/
|
||||
{
|
||||
/* Checks special character */
|
||||
|
||||
return ((((FATDirEntry *)Block)[Offset].Filename[0] == 0xe5) || (((FATDirEntry *)Block)[Offset].Filename[0] == 0));
|
||||
return ((((FATDirEntry *) Block)[Offset].Filename[0] == 0xe5) ||
|
||||
(((FATDirEntry *) Block)[Offset].Filename[0] == 0));
|
||||
}
|
||||
|
||||
BOOLEAN GetEntryName(PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop,
|
||||
BOOLEAN
|
||||
GetEntryName (PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop,
|
||||
PDEVICE_EXTENSION DeviceExt, ULONG * _StartingSector)
|
||||
/*
|
||||
* FUNCTION: Retrieves the file name, be it in short or long file name format
|
||||
|
@ -84,11 +90,13 @@ BOOLEAN GetEntryName(PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop,
|
|||
(test2[Offset].attr > 0))
|
||||
{
|
||||
Offset++;
|
||||
if(Offset==ENTRIES_PER_SECTOR) {
|
||||
if (Offset == ENTRIES_PER_SECTOR)
|
||||
{
|
||||
Offset = 0;
|
||||
StartingSector++; //FIXME : nor always the next sector
|
||||
jloop++;
|
||||
VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,Block);
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
StartingSector, 1, Block);
|
||||
test2 = (slot *) Block;
|
||||
}
|
||||
cpos++;
|
||||
|
@ -127,7 +135,8 @@ BOOLEAN GetEntryName(PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop,
|
|||
return (TRUE);
|
||||
}
|
||||
|
||||
NTSTATUS ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
|
||||
NTSTATUS
|
||||
ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
|
||||
/*
|
||||
* FUNCTION: Read the volume label
|
||||
*/
|
||||
|
@ -199,8 +208,10 @@ NTSTATUS ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||
PVFATFCB Parent, PWSTR FileToFind,ULONG *StartSector,ULONG *Entry)
|
||||
NTSTATUS
|
||||
FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||
PVFATFCB Parent, PWSTR FileToFind, ULONG * StartSector,
|
||||
ULONG * Entry)
|
||||
/*
|
||||
* FUNCTION: Find a file
|
||||
*/
|
||||
|
@ -234,8 +245,8 @@ NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
|||
Size = DeviceExt->rootDirectorySectors; /* FIXME : in fat32, no limit */
|
||||
StartingSector = DeviceExt->rootStart;
|
||||
NextCluster = 0;
|
||||
if(FileToFind[0]==0 ||(FileToFind[0]=='\\' && FileToFind[1]==0) ||
|
||||
(FileToFind[0]=='.' && FileToFind[1]==0))
|
||||
if (FileToFind[0] == 0 || (FileToFind[0] == '\\' && FileToFind[1] == 0)
|
||||
|| (FileToFind[0] == '.' && FileToFind[1] == 0))
|
||||
{
|
||||
/* it's root : complete essentials fields then return ok */
|
||||
CHECKPOINT;
|
||||
|
@ -274,7 +285,8 @@ NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
|||
CHECKPOINT;
|
||||
block = ExAllocatePool (NonPagedPool, BLOCKSIZE);
|
||||
CHECKPOINT;
|
||||
if (StartSector && (*StartSector)) StartingSector=*StartSector;
|
||||
if (StartSector && (*StartSector))
|
||||
StartingSector = *StartSector;
|
||||
i = (Entry) ? (*Entry) : 0;
|
||||
DPRINT ("FindFile : start at sector %lx, entry %ld\n", StartingSector, i);
|
||||
for (j = 0; j < Size; j++)
|
||||
|
@ -287,31 +299,38 @@ NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
|||
continue;
|
||||
if (IsLastEntry ((PVOID) block, i))
|
||||
{
|
||||
if(StartSector) *StartSector=StartingSector;
|
||||
if(Entry) *Entry=i;
|
||||
if (StartSector)
|
||||
*StartSector = StartingSector;
|
||||
if (Entry)
|
||||
*Entry = i;
|
||||
ExFreePool (block);
|
||||
return (STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if (GetEntryName((PVOID)block,&i,name,&j,DeviceExt,&StartingSector))
|
||||
if (GetEntryName
|
||||
((PVOID) block, &i, name, &j, DeviceExt, &StartingSector))
|
||||
{
|
||||
if (wstrcmpjoki (name, FileToFind))
|
||||
{
|
||||
/* In the case of a long filename, the firstcluster is stored in
|
||||
the next record -- where it's short name is */
|
||||
if(((FATDirEntry *)block)[i].Attrib==0x0f) i++;
|
||||
if (((FATDirEntry *) block)[i].Attrib == 0x0f)
|
||||
i++;
|
||||
if (i == (ENTRIES_PER_SECTOR))
|
||||
{
|
||||
/* entry is in next sector */
|
||||
StartingSector++;
|
||||
/* FIXME : treat case of next sector fragmented */
|
||||
VFATReadSectors(DeviceExt->StorageDevice,StartingSector,1,block);
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
StartingSector, 1, block);
|
||||
i = 0;
|
||||
}
|
||||
memcpy (&Fcb->entry, &((FATDirEntry *) block)[i],
|
||||
sizeof (FATDirEntry));
|
||||
vfat_wcsncpy (Fcb->ObjectName, name, MAX_PATH);
|
||||
if(StartSector) *StartSector=StartingSector;
|
||||
if(Entry) *Entry=i;
|
||||
if (StartSector)
|
||||
*StartSector = StartingSector;
|
||||
if (Entry)
|
||||
*Entry = i;
|
||||
ExFreePool (block);
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -321,7 +340,8 @@ NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
|||
|
||||
/* directory can be fragmented although it is best to keep them
|
||||
unfragmented */
|
||||
if(Entry) *Entry=0;
|
||||
if (Entry)
|
||||
*Entry = 0;
|
||||
StartingSector++;
|
||||
if ((Parent != NULL && Parent->entry.FirstCluster != 1)
|
||||
|| DeviceExt->FatType == FAT32)
|
||||
|
@ -331,8 +351,10 @@ NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
|||
NextCluster = GetNextCluster (DeviceExt, NextCluster);
|
||||
if (NextCluster == 0 || NextCluster == 0xffffffff)
|
||||
{
|
||||
if(StartSector) *StartSector=StartingSector;
|
||||
if(Entry) *Entry=i;
|
||||
if (StartSector)
|
||||
*StartSector = StartingSector;
|
||||
if (Entry)
|
||||
*Entry = i;
|
||||
ExFreePool (block);
|
||||
return (STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
@ -340,15 +362,18 @@ NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
|||
}
|
||||
}
|
||||
}
|
||||
if(StartSector) *StartSector=StartingSector;
|
||||
if(Entry) *Entry=i;
|
||||
if (StartSector)
|
||||
*StartSector = StartingSector;
|
||||
if (Entry)
|
||||
*Entry = i;
|
||||
ExFreePool (block);
|
||||
return (STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
FsdOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PWSTR FileName)
|
||||
/*
|
||||
* FUNCTION: Opens a file
|
||||
|
@ -368,10 +393,7 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
PLIST_ENTRY current_entry;
|
||||
KIRQL oldIrql;
|
||||
|
||||
DPRINT("FsdOpenFile(%08lx, %08lx, %S)\n",
|
||||
DeviceExt,
|
||||
FileObject,
|
||||
FileName);
|
||||
DPRINT ("FsdOpenFile(%08lx, %08lx, %S)\n", DeviceExt, FileObject, FileName);
|
||||
|
||||
/* FIXME : treat relative name */
|
||||
if (FileObject->RelatedFileObject)
|
||||
|
@ -383,7 +405,8 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
pRelFcb = pRelCcb->pFcb;
|
||||
assert (pRelFcb);
|
||||
/*
|
||||
* verify related object is a directory and target name don't start with \.
|
||||
* verify related object is a directory and target name don't start with
|
||||
* \.
|
||||
*/
|
||||
if (!(pRelFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
|| (FileName[0] != '\\'))
|
||||
|
@ -417,18 +440,18 @@ NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
DPRINT ("Scanning %x\n", Fcb);
|
||||
DPRINT ("Scanning %S\n", Fcb->PathName);
|
||||
|
||||
if (DeviceExt==Fcb->pDevExt
|
||||
&& wstrcmpi(FileName,Fcb->PathName))
|
||||
if (DeviceExt == Fcb->pDevExt && wstrcmpi (FileName, Fcb->PathName))
|
||||
{
|
||||
Fcb->RefCount++;
|
||||
KeReleaseSpinLock (&DeviceExt->FcbListLock, oldIrql);
|
||||
FileObject->FsContext =(PVOID) &Fcb->NTRequiredFCB;
|
||||
FileObject->FsContext = (PVOID)&Fcb->RFCB;
|
||||
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
||||
memset (newCCB, 0, sizeof (VFATCCB));
|
||||
FileObject->FsContext2 = newCCB;
|
||||
newCCB->pFcb = Fcb;
|
||||
newCCB->PtrFileObject = FileObject;
|
||||
if(AbsFileName)ExFreePool(AbsFileName);
|
||||
if (AbsFileName)
|
||||
ExFreePool (AbsFileName);
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -452,9 +475,11 @@ DPRINT("FileName %S\n", FileName);
|
|||
memset (Fcb->entry.Filename, ' ', 11);
|
||||
Fcb->entry.FileSize = DeviceExt->rootDirectorySectors * BLOCKSIZE;
|
||||
Fcb->entry.Attrib = FILE_ATTRIBUTE_DIRECTORY;
|
||||
if (DeviceExt->FatType == FAT32)Fcb->entry.FirstCluster=2;
|
||||
else Fcb->entry.FirstCluster=1;
|
||||
//FIXME : is 1 the good value for mark root?
|
||||
if (DeviceExt->FatType == FAT32)
|
||||
Fcb->entry.FirstCluster = 2;
|
||||
else
|
||||
Fcb->entry.FirstCluster = 1;
|
||||
/* FIXME : is 1 the good value for mark root? */
|
||||
ParentFcb = Fcb;
|
||||
Fcb = NULL;
|
||||
}
|
||||
|
@ -538,14 +563,14 @@ CHECKPOINT;
|
|||
}
|
||||
|
||||
|
||||
FileObject->FsContext =(PVOID) &ParentFcb->NTRequiredFCB;
|
||||
FileObject->FsContext = (PVOID)&ParentFcb->RFCB;
|
||||
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
||||
memset (newCCB, 0, sizeof (VFATCCB));
|
||||
FileObject->FsContext2 = newCCB;
|
||||
newCCB->pFcb = ParentFcb;
|
||||
newCCB->PtrFileObject = FileObject;
|
||||
ParentFcb->RefCount++;
|
||||
//FIXME : initialize all fields in FCB and CCB
|
||||
/* FIXME : initialize all fields in FCB and CCB */
|
||||
|
||||
KeAcquireSpinLock (&DeviceExt->FcbListLock, &oldIrql);
|
||||
InsertTailList (&DeviceExt->FcbListHead, &ParentFcb->FcbListEntry);
|
||||
|
@ -554,6 +579,12 @@ CHECKPOINT;
|
|||
vfat_wcsncpy (ParentFcb->PathName, FileName, MAX_PATH);
|
||||
ParentFcb->ObjectName = ParentFcb->PathName + (current - FileName);
|
||||
ParentFcb->pDevExt = DeviceExt;
|
||||
Status = CcInitializeFileCache(FileObject, &ParentFcb->RFCB.Bcb);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("CcInitializeFileCache failed\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
DPRINT ("file open, fcb=%x\n", ParentFcb);
|
||||
DPRINT ("FileSize %d\n", ParentFcb->entry.FileSize);
|
||||
if (Fcb)
|
||||
|
@ -566,7 +597,8 @@ CHECKPOINT;
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS FsdCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS
|
||||
VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Create or open a file
|
||||
*/
|
||||
|
@ -582,7 +614,8 @@ NTSTATUS FsdCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
Stack = IoGetCurrentIrpStackLocation (Irp);
|
||||
assert (Stack);
|
||||
RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) & 0xff);
|
||||
RequestedOptions=Stack->Parameters.Create.Options&FILE_VALID_OPTION_FLAGS;
|
||||
RequestedOptions =
|
||||
Stack->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS;
|
||||
if ((RequestedOptions & FILE_DIRECTORY_FILE)
|
||||
&& RequestedDisposition == FILE_SUPERSEDE)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -609,15 +642,18 @@ NTSTATUS FsdCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|| RequestedDisposition == FILE_SUPERSEDE)
|
||||
{
|
||||
CHECKPOINT;
|
||||
Status=addEntry(DeviceExt,FileObject,RequestedOptions
|
||||
,(Stack->Parameters.Create.FileAttributes & FILE_ATTRIBUTE_VALID_FLAGS));
|
||||
Status =
|
||||
addEntry (DeviceExt, FileObject, RequestedOptions,
|
||||
(Stack->Parameters.
|
||||
Create.FileAttributes & FILE_ATTRIBUTE_VALID_FLAGS));
|
||||
if (NT_SUCCESS (Status))
|
||||
Irp->IoStatus.Information = FILE_CREATED;
|
||||
// FIXME set size if AllocationSize requested
|
||||
// FIXME set extended attributes ?
|
||||
// FIXME set share access
|
||||
// IoSetShareAccess(DesiredAccess,ShareAccess,FileObject
|
||||
// ,((PVfatCCB)(FileObject->FsContext2))->pFcb->FCBShareAccess);
|
||||
/* FIXME set size if AllocationSize requested */
|
||||
/* FIXME set extended attributes? */
|
||||
/* FIXME set share access */
|
||||
/* IoSetShareAccess(DesiredAccess,ShareAccess,FileObject,
|
||||
* ((PVfatCCB)(FileObject->FsContext2))->pFcb->FCBShareAccess);
|
||||
*/
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -659,22 +695,23 @@ CHECKPOINT;
|
|||
{
|
||||
Status = STATUS_NOT_A_DIRECTORY;
|
||||
}
|
||||
// FIXME : test share access
|
||||
// FIXME : test write access if requested
|
||||
/* FIXME : test share access */
|
||||
/* FIXME : test write access if requested */
|
||||
if (!NT_SUCCESS (Status))
|
||||
FsdCloseFile(DeviceExt,FileObject);
|
||||
else Irp->IoStatus.Information = FILE_OPENED;
|
||||
// FIXME : make supersed or overwrite if requested
|
||||
VfatCloseFile (DeviceExt, FileObject);
|
||||
else
|
||||
Irp->IoStatus.Information = FILE_OPENED;
|
||||
/* FIXME : make supersed or overwrite if requested */
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatCreate (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Create or open a file
|
||||
*/
|
||||
|
@ -687,7 +724,7 @@ NTSTATUS STDCALL FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
if (DeviceObject->Size == sizeof (DEVICE_OBJECT))
|
||||
{
|
||||
/* DeviceObject represent FileSystem instead of logical volume */
|
||||
/* DeviceObject represents FileSystem instead of logical volume */
|
||||
DbgPrint ("FsdCreate called with file system\n");
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = FILE_OPENED;
|
||||
|
@ -699,7 +736,7 @@ NTSTATUS STDCALL FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
assert (DeviceExt);
|
||||
ExAcquireResourceExclusiveLite (&DeviceExt->DirResource, TRUE);
|
||||
|
||||
Status = FsdCreateFile (DeviceObject, Irp);
|
||||
Status = VfatCreateFile (DeviceObject, Irp);
|
||||
|
||||
ExReleaseResourceLite (&DeviceExt->DirResource);
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ BOOL FsdDosDateTimeToFileTime(WORD wDosDate,WORD wDosTime, TIME *FileTime)
|
|||
|
||||
|
||||
// function like FileTimeToDosDateTime
|
||||
BOOL FsdFileTimeToDosDateTime(TIME *FileTime,WORD *pwDosDate,WORD *pwDosTime)
|
||||
BOOL
|
||||
FsdFileTimeToDosDateTime (TIME * FileTime, WORD * pwDosDate, WORD * pwDosTime)
|
||||
{
|
||||
PDOSTIME pdtime = (PDOSTIME) pwDosTime;
|
||||
PDOSDATE pddate = (PDOSDATE) pwDosDate;
|
||||
|
@ -73,12 +74,14 @@ BOOL FsdFileTimeToDosDateTime(TIME *FileTime,WORD *pwDosDate,WORD *pwDosTime)
|
|||
|
||||
|
||||
|
||||
unsigned long vfat_wstrlen(PWSTR s)
|
||||
unsigned long
|
||||
vfat_wstrlen (PWSTR s)
|
||||
{
|
||||
WCHAR c = ' ';
|
||||
unsigned int len = 0;
|
||||
|
||||
while(c!=0) {
|
||||
while (c != 0)
|
||||
{
|
||||
c = *s;
|
||||
s++;
|
||||
len++;
|
||||
|
@ -87,9 +90,11 @@ unsigned long vfat_wstrlen(PWSTR s)
|
|||
|
||||
return len - 1;
|
||||
}
|
||||
|
||||
#define DWORD_ROUND_UP(x) ( (((ULONG)(x))%32) ? ((((ULONG)x)&(~0x1f))+0x20) : ((ULONG)x) )
|
||||
|
||||
NTSTATUS FsdGetFileNameInformation(PVFATFCB pFcb,
|
||||
NTSTATUS
|
||||
VfatGetFileNameInformation (PVFATFCB pFcb,
|
||||
PFILE_NAMES_INFORMATION pInfo, ULONG BufferLength)
|
||||
{
|
||||
ULONG Length;
|
||||
|
@ -97,15 +102,18 @@ NTSTATUS FsdGetFileNameInformation(PVFATFCB pFcb,
|
|||
if ((sizeof (FILE_DIRECTORY_INFORMATION) + Length) > BufferLength)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
pInfo->FileNameLength = Length;
|
||||
pInfo->NextEntryOffset=DWORD_ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION)+Length);
|
||||
memcpy(pInfo->FileName,pFcb->ObjectName
|
||||
,sizeof(WCHAR)*(pInfo->FileNameLength));
|
||||
pInfo->NextEntryOffset =
|
||||
DWORD_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + Length);
|
||||
memcpy (pInfo->FileName, pFcb->ObjectName,
|
||||
sizeof (WCHAR) * (pInfo->FileNameLength));
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS FsdGetFileDirectoryInformation(PVFATFCB pFcb,
|
||||
NTSTATUS
|
||||
VfatGetFileDirectoryInformation (PVFATFCB pFcb,
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_DIRECTORY_INFORMATION pInfo,ULONG BufferLength)
|
||||
PFILE_DIRECTORY_INFORMATION pInfo,
|
||||
ULONG BufferLength)
|
||||
{
|
||||
unsigned long long AllocSize;
|
||||
ULONG Length;
|
||||
|
@ -113,32 +121,34 @@ NTSTATUS FsdGetFileDirectoryInformation(PVFATFCB pFcb,
|
|||
if ((sizeof (FILE_DIRECTORY_INFORMATION) + Length) > BufferLength)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
pInfo->FileNameLength = Length;
|
||||
pInfo->NextEntryOffset=DWORD_ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION)+Length);
|
||||
memcpy(pInfo->FileName,pFcb->ObjectName
|
||||
,sizeof(WCHAR)*(pInfo->FileNameLength));
|
||||
pInfo->NextEntryOffset =
|
||||
DWORD_ROUND_UP (sizeof (FILE_DIRECTORY_INFORMATION) + Length);
|
||||
memcpy (pInfo->FileName, pFcb->ObjectName,
|
||||
sizeof (WCHAR) * (pInfo->FileNameLength));
|
||||
// pInfo->FileIndex=;
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.CreationDate,pFcb->entry.CreationTime
|
||||
,&pInfo->CreationTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.AccessDate,0
|
||||
,&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.UpdateDate,pFcb->entry.UpdateTime
|
||||
,&pInfo->LastWriteTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.UpdateDate,pFcb->entry.UpdateTime
|
||||
,&pInfo->ChangeTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.CreationDate,
|
||||
pFcb->entry.CreationTime, &pInfo->CreationTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.AccessDate, 0,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.UpdateDate, pFcb->entry.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.UpdateDate, pFcb->entry.UpdateTime,
|
||||
&pInfo->ChangeTime);
|
||||
pInfo->EndOfFile = RtlConvertUlongToLargeInteger (pFcb->entry.FileSize);
|
||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
||||
DeviceExt->BytesPerCluster) *
|
||||
DeviceExt->BytesPerCluster;
|
||||
DeviceExt->BytesPerCluster) * DeviceExt->BytesPerCluster;
|
||||
pInfo->AllocationSize.QuadPart = AllocSize;
|
||||
pInfo->FileAttributes = pFcb->entry.Attrib;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS FsdGetFileFullDirectoryInformation(PVFATFCB pFcb,
|
||||
NTSTATUS
|
||||
VfatGetFileFullDirectoryInformation (PVFATFCB pFcb,
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_FULL_DIRECTORY_INFORMATION pInfo,ULONG BufferLength)
|
||||
PFILE_FULL_DIRECTORY_INFORMATION pInfo,
|
||||
ULONG BufferLength)
|
||||
{
|
||||
unsigned long long AllocSize;
|
||||
ULONG Length;
|
||||
|
@ -146,32 +156,34 @@ NTSTATUS FsdGetFileFullDirectoryInformation(PVFATFCB pFcb,
|
|||
if ((sizeof (FILE_FULL_DIRECTORY_INFORMATION) + Length) > BufferLength)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
pInfo->FileNameLength = Length;
|
||||
pInfo->NextEntryOffset=DWORD_ROUND_UP(sizeof(FILE_FULL_DIRECTORY_INFORMATION)+Length);
|
||||
memcpy(pInfo->FileName,pFcb->ObjectName
|
||||
,sizeof(WCHAR)*(pInfo->FileNameLength));
|
||||
pInfo->NextEntryOffset =
|
||||
DWORD_ROUND_UP (sizeof (FILE_FULL_DIRECTORY_INFORMATION) + Length);
|
||||
memcpy (pInfo->FileName, pFcb->ObjectName,
|
||||
sizeof (WCHAR) * (pInfo->FileNameLength));
|
||||
// pInfo->FileIndex=;
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.CreationDate,pFcb->entry.CreationTime
|
||||
,&pInfo->CreationTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.AccessDate,0
|
||||
,&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.UpdateDate,pFcb->entry.UpdateTime
|
||||
,&pInfo->LastWriteTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.UpdateDate,pFcb->entry.UpdateTime
|
||||
,&pInfo->ChangeTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.CreationDate,
|
||||
pFcb->entry.CreationTime, &pInfo->CreationTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.AccessDate, 0,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.UpdateDate, pFcb->entry.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.UpdateDate, pFcb->entry.UpdateTime,
|
||||
&pInfo->ChangeTime);
|
||||
pInfo->EndOfFile = RtlConvertUlongToLargeInteger (pFcb->entry.FileSize);
|
||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
||||
DeviceExt->BytesPerCluster) *
|
||||
DeviceExt->BytesPerCluster;
|
||||
DeviceExt->BytesPerCluster) * DeviceExt->BytesPerCluster;
|
||||
pInfo->AllocationSize.QuadPart = AllocSize;
|
||||
pInfo->FileAttributes = pFcb->entry.Attrib;
|
||||
// pInfo->EaSize=;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS FsdGetFileBothInformation(PVFATFCB pFcb,
|
||||
NTSTATUS
|
||||
VfatGetFileBothInformation (PVFATFCB pFcb,
|
||||
PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_BOTH_DIRECTORY_INFORMATION pInfo,ULONG BufferLength)
|
||||
PFILE_BOTH_DIRECTORY_INFORMATION pInfo,
|
||||
ULONG BufferLength)
|
||||
{
|
||||
short i;
|
||||
unsigned long long AllocSize;
|
||||
|
@ -180,23 +192,23 @@ NTSTATUS FsdGetFileBothInformation(PVFATFCB pFcb,
|
|||
if ((sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + Length) > BufferLength)
|
||||
return STATUS_BUFFER_OVERFLOW;
|
||||
pInfo->FileNameLength = Length;
|
||||
pInfo->NextEntryOffset=DWORD_ROUND_UP(sizeof(FILE_BOTH_DIRECTORY_INFORMATION)+Length);
|
||||
memcpy(pInfo->FileName,pFcb->ObjectName
|
||||
,sizeof(WCHAR)*(pInfo->FileNameLength));
|
||||
pInfo->NextEntryOffset =
|
||||
DWORD_ROUND_UP (sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + Length);
|
||||
memcpy (pInfo->FileName, pFcb->ObjectName,
|
||||
sizeof (WCHAR) * (pInfo->FileNameLength));
|
||||
// pInfo->FileIndex=;
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.CreationDate,pFcb->entry.CreationTime
|
||||
,&pInfo->CreationTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.AccessDate,0
|
||||
,&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.UpdateDate,pFcb->entry.UpdateTime
|
||||
,&pInfo->LastWriteTime);
|
||||
FsdDosDateTimeToFileTime(pFcb->entry.UpdateDate,pFcb->entry.UpdateTime
|
||||
,&pInfo->ChangeTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.CreationDate,
|
||||
pFcb->entry.CreationTime, &pInfo->CreationTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.AccessDate, 0,
|
||||
&pInfo->LastAccessTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.UpdateDate, pFcb->entry.UpdateTime,
|
||||
&pInfo->LastWriteTime);
|
||||
FsdDosDateTimeToFileTime (pFcb->entry.UpdateDate, pFcb->entry.UpdateTime,
|
||||
&pInfo->ChangeTime);
|
||||
pInfo->EndOfFile = RtlConvertUlongToLargeInteger (pFcb->entry.FileSize);
|
||||
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
||||
AllocSize = ((pFcb->entry.FileSize + DeviceExt->BytesPerCluster - 1) /
|
||||
DeviceExt->BytesPerCluster) *
|
||||
DeviceExt->BytesPerCluster;
|
||||
DeviceExt->BytesPerCluster) * DeviceExt->BytesPerCluster;
|
||||
pInfo->AllocationSize.QuadPart = AllocSize;
|
||||
pInfo->FileAttributes = pFcb->entry.Attrib;
|
||||
// pInfo->EaSize=;
|
||||
|
@ -206,11 +218,13 @@ NTSTATUS FsdGetFileBothInformation(PVFATFCB pFcb,
|
|||
pInfo->ShortName[i] = '.';
|
||||
for (i = 0; i < 3 && (pFcb->entry.Ext[i] != ' '); i++)
|
||||
pInfo->ShortName[i + 1 + pInfo->ShortNameLength] = pFcb->entry.Ext[i];
|
||||
if(i) pInfo->ShortNameLength += (i+1);
|
||||
if (i)
|
||||
pInfo->ShortNameLength += (i + 1);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS DoQuery(PDEVICE_OBJECT DeviceObject, PIRP Irp,PIO_STACK_LOCATION Stack)
|
||||
NTSTATUS
|
||||
DoQuery (PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION Stack)
|
||||
{
|
||||
NTSTATUS RC = STATUS_SUCCESS;
|
||||
long BufferLength = 0;
|
||||
|
@ -230,7 +244,8 @@ NTSTATUS DoQuery(PDEVICE_OBJECT DeviceObject, PIRP Irp,PIO_STACK_LOCATION Stack)
|
|||
// Obtain the callers parameters
|
||||
BufferLength = Stack->Parameters.QueryDirectory.Length;
|
||||
pSearchPattern = Stack->Parameters.QueryDirectory.FileName;
|
||||
FileInformationClass = Stack->Parameters.QueryDirectory.FileInformationClass;
|
||||
FileInformationClass =
|
||||
Stack->Parameters.QueryDirectory.FileInformationClass;
|
||||
FileIndex = Stack->Parameters.QueryDirectory.FileIndex;
|
||||
pFileObject = Stack->FileObject;
|
||||
pCcb = (PVFATCCB) pFileObject->FsContext2;
|
||||
|
@ -251,35 +266,47 @@ NTSTATUS DoQuery(PDEVICE_OBJECT DeviceObject, PIRP Irp,PIO_STACK_LOCATION Stack)
|
|||
star[1] = 0;
|
||||
pCharPattern = star;
|
||||
}
|
||||
else pCharPattern=pSearchPattern->Buffer;
|
||||
else
|
||||
pCharPattern = pSearchPattern->Buffer;
|
||||
tmpFcb.ObjectName = tmpFcb.PathName;
|
||||
while (RC == STATUS_SUCCESS && BufferLength > 0)
|
||||
{
|
||||
OldSector = pCcb->StartSector;
|
||||
OldEntry = pCcb->StartEntry;
|
||||
if(OldSector)pCcb->StartEntry++;
|
||||
RC=FindFile(DeviceExt,&tmpFcb,pFcb,pCharPattern,&pCcb->StartSector,&pCcb->StartEntry);
|
||||
DPRINT("Found %S,RC=%x, sector %x entry %x\n",tmpFcb.ObjectName,RC
|
||||
,pCcb->StartSector,pCcb->StartEntry);
|
||||
if (OldSector)
|
||||
pCcb->StartEntry++;
|
||||
RC =
|
||||
FindFile (DeviceExt, &tmpFcb, pFcb, pCharPattern, &pCcb->StartSector,
|
||||
&pCcb->StartEntry);
|
||||
DPRINT ("Found %S,RC=%x, sector %x entry %x\n", tmpFcb.ObjectName, RC,
|
||||
pCcb->StartSector, pCcb->StartEntry);
|
||||
if (NT_SUCCESS (RC))
|
||||
{
|
||||
switch (FileInformationClass)
|
||||
{
|
||||
case FileNameInformation:
|
||||
RC=FsdGetFileNameInformation(&tmpFcb
|
||||
,(PFILE_NAMES_INFORMATION)Buffer,BufferLength);
|
||||
RC =
|
||||
VfatGetFileNameInformation (&tmpFcb,
|
||||
(PFILE_NAMES_INFORMATION) Buffer,
|
||||
BufferLength);
|
||||
break;
|
||||
case FileDirectoryInformation:
|
||||
RC= FsdGetFileDirectoryInformation(&tmpFcb
|
||||
,DeviceExt,(PFILE_DIRECTORY_INFORMATION)Buffer,BufferLength);
|
||||
RC =
|
||||
VfatGetFileDirectoryInformation (&tmpFcb, DeviceExt,
|
||||
(PFILE_DIRECTORY_INFORMATION)
|
||||
Buffer, BufferLength);
|
||||
break;
|
||||
case FileFullDirectoryInformation:
|
||||
RC= FsdGetFileFullDirectoryInformation(&tmpFcb
|
||||
,DeviceExt,(PFILE_FULL_DIRECTORY_INFORMATION)Buffer,BufferLength);
|
||||
RC =
|
||||
VfatGetFileFullDirectoryInformation (&tmpFcb, DeviceExt,
|
||||
(PFILE_FULL_DIRECTORY_INFORMATION)
|
||||
Buffer, BufferLength);
|
||||
break;
|
||||
case FileBothDirectoryInformation:
|
||||
RC=FsdGetFileBothInformation(&tmpFcb
|
||||
,DeviceExt,(PFILE_BOTH_DIRECTORY_INFORMATION)Buffer,BufferLength);
|
||||
RC =
|
||||
VfatGetFileBothInformation (&tmpFcb, DeviceExt,
|
||||
(PFILE_BOTH_DIRECTORY_INFORMATION)
|
||||
Buffer, BufferLength);
|
||||
break;
|
||||
default:
|
||||
RC = STATUS_INVALID_INFO_CLASS;
|
||||
|
@ -287,29 +314,35 @@ DPRINT("Found %S,RC=%x, sector %x entry %x\n",tmpFcb.ObjectName,RC
|
|||
}
|
||||
else
|
||||
{
|
||||
if(Buffer0) Buffer0->NextEntryOffset=0;
|
||||
if (Buffer0)
|
||||
Buffer0->NextEntryOffset = 0;
|
||||
break;
|
||||
}
|
||||
if (RC == STATUS_BUFFER_OVERFLOW)
|
||||
{
|
||||
if(Buffer0) Buffer0->NextEntryOffset=0;
|
||||
if (Buffer0)
|
||||
Buffer0->NextEntryOffset = 0;
|
||||
pCcb->StartSector = OldSector;
|
||||
pCcb->StartEntry = OldEntry;
|
||||
break;
|
||||
}
|
||||
Buffer0 = (PFILE_NAMES_INFORMATION) Buffer;
|
||||
Buffer0->FileIndex = FileIndex++;
|
||||
if(Stack->Flags & SL_RETURN_SINGLE_ENTRY) break;
|
||||
if (Stack->Flags & SL_RETURN_SINGLE_ENTRY)
|
||||
break;
|
||||
BufferLength -= Buffer0->NextEntryOffset;
|
||||
Buffer += Buffer0->NextEntryOffset;
|
||||
}
|
||||
if(Buffer0) Buffer0->NextEntryOffset=0;
|
||||
if(FileIndex>0) return STATUS_SUCCESS;
|
||||
if (Buffer0)
|
||||
Buffer0->NextEntryOffset = 0;
|
||||
if (FileIndex > 0)
|
||||
return STATUS_SUCCESS;
|
||||
return RC;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL FsdDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatDirectoryControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: directory control : read/write directory informations
|
||||
*/
|
||||
|
@ -331,7 +364,8 @@ NTSTATUS STDCALL FsdDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
break;
|
||||
default:
|
||||
// error
|
||||
DbgPrint("unexpected minor function %x in VFAT driver\n",Stack->MinorFunction);
|
||||
DbgPrint ("unexpected minor function %x in VFAT driver\n",
|
||||
Stack->MinorFunction);
|
||||
RC = STATUS_INVALID_DEVICE_REQUEST;
|
||||
break;
|
||||
}
|
||||
|
@ -341,4 +375,3 @@ NTSTATUS STDCALL FsdDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
||||
return RC;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: dirwr.c,v 1.13 2000/06/29 23:35:50 dwelch Exp $
|
||||
/* $Id: dirwr.c,v 1.14 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -103,7 +103,8 @@ NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject)
|
|||
//find last \ in PathFileName
|
||||
posCar = -1;
|
||||
for (i = 0; PathFileName[i]; i++)
|
||||
if(PathFileName[i]=='\\')posCar=i;
|
||||
if (PathFileName[i] == '\\')
|
||||
posCar = i;
|
||||
if (posCar == -1)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
FileName = &PathFileName[posCar + 1];
|
||||
|
@ -116,14 +117,16 @@ NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject)
|
|||
DirName[0] = L'\\';
|
||||
DirName[1] = 0;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
memcpy (DirName, PathFileName, posCar * sizeof (WCHAR));
|
||||
DirName[posCar] = 0;
|
||||
}
|
||||
if (FileName[0] == 0 && DirName[0] == 0)
|
||||
return STATUS_SUCCESS; //root : nothing to do ?
|
||||
memset (&FileObject, 0, sizeof (FILE_OBJECT));
|
||||
DPRINT("open directory \'%S\' for update of entry \'%S\'\n",DirName,FileName);
|
||||
DPRINT ("open directory \'%S\' for update of entry \'%S\'\n", DirName,
|
||||
FileName);
|
||||
status = FsdOpenFile (DeviceExt, &FileObject, DirName);
|
||||
if (!NT_SUCCESS (status))
|
||||
{
|
||||
|
@ -146,15 +149,14 @@ NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject)
|
|||
VFATWriteSectors (DeviceExt->StorageDevice, Sector, 1, Buffer);
|
||||
ExFreePool (Buffer);
|
||||
}
|
||||
FsdCloseFile(DeviceExt,&FileObject);
|
||||
VfatCloseFile (DeviceExt, &FileObject);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject,
|
||||
ULONG RequestedOptions,
|
||||
UCHAR ReqAttr)
|
||||
NTSTATUS
|
||||
addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject, ULONG RequestedOptions, UCHAR ReqAttr)
|
||||
/*
|
||||
create a new FAT entry
|
||||
*/
|
||||
|
@ -181,7 +183,8 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt,
|
|||
//find last \ in PathFileName
|
||||
posCar = -1;
|
||||
for (i = 0; PathFileName[i]; i++)
|
||||
if(PathFileName[i]=='\\')posCar=i;
|
||||
if (PathFileName[i] == '\\')
|
||||
posCar = i;
|
||||
if (posCar == -1)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
FileName = &PathFileName[posCar + 1];
|
||||
|
@ -194,7 +197,8 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt,
|
|||
status = FsdOpenFile (DeviceExt, &FileObject, DirName);
|
||||
nbSlots = (NameLen + 12) / 13 + 1; //nb of entry needed for long name+normal entry
|
||||
DPRINT ("NameLen= %d, nbSlots =%d\n", NameLen, nbSlots);
|
||||
Buffer=ExAllocatePool(NonPagedPool,(nbSlots+1)*sizeof(FATDirEntry));
|
||||
Buffer =
|
||||
ExAllocatePool (NonPagedPool, (nbSlots + 1) * sizeof (FATDirEntry));
|
||||
memset (Buffer, 0, (nbSlots + 1) * sizeof (FATDirEntry));
|
||||
pEntry = (FATDirEntry *) (Buffer + (nbSlots - 1) * sizeof (FATDirEntry));
|
||||
pSlots = (slot *) Buffer;
|
||||
|
@ -203,9 +207,12 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt,
|
|||
// find last point in name
|
||||
posCar = 0;
|
||||
for (i = 0; FileName[i]; i++)
|
||||
if(FileName[i]=='.')posCar=i;
|
||||
if(!posCar) posCar=i;
|
||||
if(posCar>8) needTilde=TRUE;
|
||||
if (FileName[i] == '.')
|
||||
posCar = i;
|
||||
if (!posCar)
|
||||
posCar = i;
|
||||
if (posCar > 8)
|
||||
needTilde = TRUE;
|
||||
//copy 8 characters max
|
||||
memset (pEntry, ' ', 11);
|
||||
for (i = 0, j = 0; j < 8 && i < posCar; i++)
|
||||
|
@ -216,10 +223,7 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt,
|
|||
&& FileName[i] != '+'
|
||||
&& FileName[i] != ','
|
||||
&& FileName[i] != ';'
|
||||
&& FileName[i]!='='
|
||||
&& FileName[i]!='['
|
||||
&& FileName[i]!=']'
|
||||
)
|
||||
&& FileName[i] != '=' && FileName[i] != '[' && FileName[i] != ']')
|
||||
pEntry->Filename[j++] = toupper ((char) FileName[i]);
|
||||
else
|
||||
needTilde = TRUE;
|
||||
|
@ -250,9 +254,10 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
DirName[7] = '0' + i;
|
||||
pEntry->Filename[7] = '0' + i;
|
||||
status=FindFile(DeviceExt,&FileFcb
|
||||
,&DirFcb,DirName,NULL,NULL);
|
||||
if(status!=STATUS_SUCCESS)break;
|
||||
status =
|
||||
FindFile (DeviceExt, &FileFcb, &DirFcb, DirName, NULL, NULL);
|
||||
if (status != STATUS_SUCCESS)
|
||||
break;
|
||||
}
|
||||
//try second with xxxxx~yy.zzz
|
||||
if (i == 10)
|
||||
|
@ -262,14 +267,15 @@ NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
DirName[7] = '0' + i;
|
||||
pEntry->Filename[7] = '0' + i;
|
||||
status=FindFile(DeviceExt,&FileFcb
|
||||
,&DirFcb,DirName,NULL,NULL);
|
||||
if(status!=STATUS_SUCCESS)break;
|
||||
status =
|
||||
FindFile (DeviceExt, &FileFcb, &DirFcb, DirName, NULL, NULL);
|
||||
if (status != STATUS_SUCCESS)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 100) //FIXME : what to do after 99 tilde ?
|
||||
{
|
||||
FsdCloseFile(DeviceExt,&FileObject);
|
||||
VfatCloseFile (DeviceExt, &FileObject);
|
||||
ExFreePool (Buffer);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
@ -289,7 +295,8 @@ DPRINT("i=%d,%d,%d\n",i,pEntry->Filename[i],FileName[i]);
|
|||
for (j = 0, i = posCar + 1; FileName[i] && i < posCar + 4; i++)
|
||||
if ((USHORT) pEntry->Ext[j++] != FileName[i])
|
||||
{
|
||||
DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]);
|
||||
DPRINT ("i=%d,j=%d,%d,%d\n", i, j, pEntry->Filename[i],
|
||||
FileName[i]);
|
||||
needLong = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -316,11 +323,9 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]);
|
|||
|
||||
/* set dates and times */
|
||||
KeQuerySystemTime (&SystemTime);
|
||||
ExSystemTimeToLocalTime (&SystemTime,
|
||||
&LocalTime);
|
||||
ExSystemTimeToLocalTime (&SystemTime, &LocalTime);
|
||||
FsdFileTimeToDosDateTime ((TIME *) & LocalTime,
|
||||
&pEntry->CreationDate,
|
||||
&pEntry->CreationTime);
|
||||
&pEntry->CreationDate, &pEntry->CreationTime);
|
||||
pEntry->UpdateDate = pEntry->CreationDate;
|
||||
pEntry->UpdateTime = pEntry->CreationTime;
|
||||
pEntry->AccessDate = pEntry->CreationDate;
|
||||
|
@ -349,18 +354,19 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]);
|
|||
//try to find nbSlots contiguous entries frees in directory
|
||||
for (i = 0, status = STATUS_SUCCESS; status == STATUS_SUCCESS; i++)
|
||||
{
|
||||
status=FsdReadFile(DeviceExt,&FileObject,&FatEntry
|
||||
,sizeof(FATDirEntry),i*sizeof(FATDirEntry),&LengthRead);
|
||||
status =
|
||||
VfatReadFile (DeviceExt, &FileObject, &FatEntry, sizeof (FATDirEntry),
|
||||
i * sizeof (FATDirEntry), &LengthRead);
|
||||
if (status == STATUS_END_OF_FILE)
|
||||
break;
|
||||
if (!NT_SUCCESS (status))
|
||||
{
|
||||
DPRINT1( "FsdReadFile failed to read the directory entry\n" );
|
||||
DPRINT1 ("VfatReadFile failed to read the directory entry\n");
|
||||
break;
|
||||
}
|
||||
if (LengthRead != sizeof (FATDirEntry))
|
||||
{
|
||||
DPRINT1( "FsdReadFile did not read a complete directory entry\n" );
|
||||
DPRINT1 ("VfatReadFile did not read a complete directory entry\n");
|
||||
break;
|
||||
}
|
||||
if (IsDeletedEntry (&FatEntry, 0))
|
||||
|
@ -392,15 +398,17 @@ DPRINT("i=%d,j=%d,%d,%d\n",i,j,pEntry->Filename[i],FileName[i]);
|
|||
if (nbFree == nbSlots)
|
||||
{ //use old slots
|
||||
Offset = (i - nbSlots + 1) * sizeof (FATDirEntry);
|
||||
status=FsdWriteFile(DeviceExt,&FileObject,Buffer
|
||||
,sizeof(FATDirEntry)*nbSlots,Offset);
|
||||
DPRINT( "FsdWriteFile() returned: %x\n", status );
|
||||
status =
|
||||
VfatWriteFile (DeviceExt, &FileObject, Buffer,
|
||||
sizeof (FATDirEntry) * nbSlots, Offset);
|
||||
DPRINT ("VfatWriteFile() returned: %x\n", status);
|
||||
}
|
||||
else
|
||||
{ //write at end of directory
|
||||
Offset = (i - nbFree) * sizeof (FATDirEntry);
|
||||
status=FsdWriteFile(DeviceExt,&FileObject,Buffer
|
||||
,sizeof(FATDirEntry)*(nbSlots+1),Offset);
|
||||
status =
|
||||
VfatWriteFile (DeviceExt, &FileObject, Buffer,
|
||||
sizeof (FATDirEntry) * (nbSlots + 1), Offset);
|
||||
}
|
||||
DPRINT ("write entry offset %d status=%x\n", Offset, status);
|
||||
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
||||
|
@ -425,25 +433,27 @@ DPRINT("new : entry=%11.11s\n",pEntry->Filename);
|
|||
vfat_wcsncpy (newFCB->PathName, PathFileName, MAX_PATH);
|
||||
newFCB->ObjectName = newFCB->PathName + (PathFileName - FileName);
|
||||
newFCB->pDevExt = DeviceExt;
|
||||
pFileObject->FsContext =(PVOID) &newFCB->NTRequiredFCB;
|
||||
pFileObject->FsContext = (PVOID)&newFCB->RFCB;
|
||||
pFileObject->FsContext2 = newCCB;
|
||||
if (RequestedOptions & FILE_DIRECTORY_FILE)
|
||||
{
|
||||
// create . and ..
|
||||
memcpy (pEntry->Filename, ". ", 11);
|
||||
status=FsdWriteFile(DeviceExt,pFileObject,pEntry
|
||||
,sizeof(FATDirEntry),0L);
|
||||
pEntry->FirstCluster
|
||||
=((VFATCCB *)(FileObject.FsContext2))->pFcb->entry.FirstCluster;
|
||||
pEntry->FirstClusterHigh
|
||||
=((VFATCCB *)(FileObject.FsContext2))->pFcb->entry.FirstClusterHigh;
|
||||
status =
|
||||
VfatWriteFile (DeviceExt, pFileObject, pEntry, sizeof (FATDirEntry),
|
||||
0L);
|
||||
pEntry->FirstCluster =
|
||||
((VFATCCB *) (FileObject.FsContext2))->pFcb->entry.FirstCluster;
|
||||
pEntry->FirstClusterHigh =
|
||||
((VFATCCB *) (FileObject.FsContext2))->pFcb->entry.FirstClusterHigh;
|
||||
memcpy (pEntry->Filename, ".. ", 11);
|
||||
if (pEntry->FirstCluster == 1 && DeviceExt->FatType != FAT32)
|
||||
pEntry->FirstCluster = 0;
|
||||
status=FsdWriteFile(DeviceExt,pFileObject,pEntry
|
||||
,sizeof(FATDirEntry),sizeof(FATDirEntry));
|
||||
status =
|
||||
VfatWriteFile (DeviceExt, pFileObject, pEntry, sizeof (FATDirEntry),
|
||||
sizeof (FATDirEntry));
|
||||
}
|
||||
FsdCloseFile(DeviceExt,&FileObject);
|
||||
VfatCloseFile (DeviceExt, &FileObject);
|
||||
ExFreePool (Buffer);
|
||||
DPRINT ("addentry ok\n");
|
||||
return STATUS_SUCCESS;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: fat.c,v 1.8 2000/12/28 03:38:08 dwelch Exp $
|
||||
* $Id: fat.c,v 1.9 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <ddk/cctypes.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -36,8 +35,9 @@ Fat32GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
|
|||
Block = ExAllocatePool (NonPagedPool, 1024);
|
||||
FATsector = CurrentCluster / (512 / sizeof (ULONG));
|
||||
FATeis = CurrentCluster - (FATsector * (512 / sizeof (ULONG)));
|
||||
VFATReadSectors(DeviceExt->StorageDevice
|
||||
,(ULONG)(DeviceExt->FATStart+FATsector), 1,(UCHAR*) Block);
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
(ULONG) (DeviceExt->FATStart + FATsector), 1,
|
||||
(UCHAR *) Block);
|
||||
CurrentCluster = Block[FATeis];
|
||||
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
|
||||
CurrentCluster = 0xffffffff;
|
||||
|
@ -178,12 +178,13 @@ FAT32FindAvailableCluster(PDEVICE_EXTENSION DeviceExt)
|
|||
PULONG Block;
|
||||
int i;
|
||||
Block = ExAllocatePool (NonPagedPool, BLOCKSIZE);
|
||||
for(sector=0
|
||||
;sector< ((struct _BootSector32*)(DeviceExt->Boot))->FATSectors32
|
||||
;sector++)
|
||||
for (sector = 0;
|
||||
sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32;
|
||||
sector++)
|
||||
{
|
||||
VFATReadSectors(DeviceExt->StorageDevice
|
||||
,(ULONG)(DeviceExt->FATStart+sector), 1,(UCHAR*) Block);
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
(ULONG) (DeviceExt->FATStart + sector), 1,
|
||||
(UCHAR *) Block);
|
||||
|
||||
for (i = 0; i < 512; i++)
|
||||
{
|
||||
|
@ -273,12 +274,13 @@ FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt)
|
|||
ExAcquireResourceSharedLite (&DeviceExt->FatResource, TRUE);
|
||||
|
||||
Block = ExAllocatePool (NonPagedPool, BLOCKSIZE);
|
||||
for(sector=0
|
||||
;sector< ((struct _BootSector32*)(DeviceExt->Boot))->FATSectors32
|
||||
;sector++)
|
||||
for (sector = 0;
|
||||
sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32;
|
||||
sector++)
|
||||
{
|
||||
VFATReadSectors(DeviceExt->StorageDevice
|
||||
,(ULONG)(DeviceExt->FATStart+sector), 1,(UCHAR*) Block);
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
(ULONG) (DeviceExt->FATStart + sector), 1,
|
||||
(UCHAR *) Block);
|
||||
|
||||
for (i = 0; i < 512; i++)
|
||||
{
|
||||
|
@ -308,14 +310,12 @@ FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
|||
{
|
||||
CBlock[FATOffset] = NewValue;
|
||||
CBlock[FATOffset + 1] &= 0xf0;
|
||||
CBlock[FATOffset + 1]
|
||||
|= (NewValue&0xf00)>>8;
|
||||
CBlock[FATOffset + 1] |= (NewValue & 0xf00) >> 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
CBlock[FATOffset] &= 0x0f;
|
||||
CBlock[FATOffset]
|
||||
|= (NewValue&0xf)<<4;
|
||||
CBlock[FATOffset] |= (NewValue & 0xf) << 4;
|
||||
CBlock[FATOffset + 1] = NewValue >> 4;
|
||||
}
|
||||
/* Write the changed FAT sector(s) to disk */
|
||||
|
@ -327,16 +327,14 @@ FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
|||
VFATWriteSectors (DeviceExt->StorageDevice,
|
||||
DeviceExt->FATStart + FATsector
|
||||
+ i * DeviceExt->Boot->FATSectors,
|
||||
2,
|
||||
CBlock+FATsector*512);
|
||||
2, CBlock + FATsector * 512);
|
||||
}
|
||||
else
|
||||
{
|
||||
VFATWriteSectors (DeviceExt->StorageDevice,
|
||||
DeviceExt->FATStart + FATsector
|
||||
+ i * DeviceExt->Boot->FATSectors,
|
||||
1,
|
||||
CBlock+FATsector*512);
|
||||
1, CBlock + FATsector * 512);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -366,9 +364,7 @@ FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
|||
for (i = 0; i < DeviceExt->Boot->FATCount; i++)
|
||||
{
|
||||
VFATWriteSectors (DeviceExt->StorageDevice,
|
||||
Start,
|
||||
1,
|
||||
((UCHAR *)Block)+FATsector*512);
|
||||
Start, 1, ((UCHAR *) Block) + FATsector * 512);
|
||||
Start += DeviceExt->Boot->FATSectors;
|
||||
}
|
||||
}
|
||||
|
@ -392,19 +388,14 @@ DbgPrint("FAT32WriteCluster %u : %u\n",ClusterToWrite,NewValue);
|
|||
FATeis = ClusterToWrite - (FATsector * 128);
|
||||
/* load sector, change value, then rewrite sector */
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
DeviceExt->FATStart+FATsector,
|
||||
1,
|
||||
(UCHAR *)Block);
|
||||
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++)
|
||||
{
|
||||
VFATWriteSectors(DeviceExt->StorageDevice,
|
||||
Start,
|
||||
1,
|
||||
(UCHAR *)Block);
|
||||
VFATWriteSectors (DeviceExt->StorageDevice, Start, 1, (UCHAR *) Block);
|
||||
Start += pBoot->FATSectors;
|
||||
}
|
||||
ExFreePool (Block);
|
||||
|
@ -444,8 +435,7 @@ GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
|
|||
DeviceExt, CurrentCluster);
|
||||
|
||||
/* Find out what was happening in the last cluster's AU */
|
||||
LastCluster=GetNextCluster(DeviceExt,
|
||||
CurrentCluster);
|
||||
LastCluster = GetNextCluster (DeviceExt, CurrentCluster);
|
||||
/* Check to see if we must append or overwrite */
|
||||
if (LastCluster == 0xffffffff)
|
||||
{
|
||||
|
@ -490,14 +480,14 @@ GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
|
|||
}
|
||||
|
||||
ULONG
|
||||
ClusterToSector(PDEVICE_EXTENSION DeviceExt,
|
||||
unsigned long Cluster)
|
||||
ClusterToSector (PDEVICE_EXTENSION DeviceExt, unsigned long Cluster)
|
||||
/*
|
||||
* FUNCTION: Converts the cluster number to a sector number for this physical
|
||||
* device
|
||||
*/
|
||||
{
|
||||
return DeviceExt->dataStart+((Cluster-2)*DeviceExt->Boot->SectorsPerCluster);
|
||||
return DeviceExt->dataStart +
|
||||
((Cluster - 2) * DeviceExt->Boot->SectorsPerCluster);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -514,9 +504,7 @@ VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
|
|||
Sector = ClusterToSector (DeviceExt, Cluster);
|
||||
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
Sector,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Buffer);
|
||||
Sector, DeviceExt->Boot->SectorsPerCluster, Buffer);
|
||||
DPRINT ("Finished VFATReadSectors\n");
|
||||
}
|
||||
|
||||
|
@ -533,8 +521,5 @@ VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
|
|||
Sector = ClusterToSector (DeviceExt, Cluster);
|
||||
|
||||
VFATWriteSectors (DeviceExt->StorageDevice,
|
||||
Sector,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Buffer);
|
||||
Sector, DeviceExt->Boot->SectorsPerCluster, Buffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: finfo.c,v 1.4 2000/09/12 10:12:13 jean Exp $
|
||||
/* $Id: finfo.c,v 1.5 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <ddk/cctypes.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -21,7 +20,8 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS FsdGetStandardInformation(PVFATFCB FCB, PDEVICE_OBJECT DeviceObject,
|
||||
NTSTATUS
|
||||
VfatGetStandardInformation (PVFATFCB FCB, PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_STANDARD_INFORMATION StandardInfo)
|
||||
/*
|
||||
* FUNCTION: Retrieve the standard file information
|
||||
|
@ -45,19 +45,24 @@ NTSTATUS FsdGetStandardInformation(PVFATFCB FCB, PDEVICE_OBJECT DeviceObject,
|
|||
DeviceExtension->BytesPerCluster;
|
||||
|
||||
StandardInfo->AllocationSize = RtlConvertUlongToLargeInteger (AllocSize);
|
||||
StandardInfo->EndOfFile = RtlConvertUlongToLargeInteger(FCB->entry.FileSize);
|
||||
StandardInfo->EndOfFile =
|
||||
RtlConvertUlongToLargeInteger (FCB->entry.FileSize);
|
||||
StandardInfo->NumberOfLinks = 0;
|
||||
StandardInfo->DeletePending = FALSE;
|
||||
if((FCB->entry.Attrib & 0x10)>0) {
|
||||
if ((FCB->entry.Attrib & 0x10) > 0)
|
||||
{
|
||||
StandardInfo->Directory = TRUE;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
StandardInfo->Directory = FALSE;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS FsdSetPositionInformation(PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
VfatSetPositionInformation (PFILE_OBJECT FileObject,
|
||||
PVFATFCB FCB,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_POSITION_INFORMATION PositionInfo)
|
||||
|
@ -72,12 +77,13 @@ NTSTATUS FsdSetPositionInformation(PFILE_OBJECT FileObject,
|
|||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS FsdGetPositionInformation(PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
VfatGetPositionInformation (PFILE_OBJECT FileObject,
|
||||
PVFATFCB FCB,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_POSITION_INFORMATION PositionInfo)
|
||||
{
|
||||
DPRINT("FsdGetPositionInformation()\n");
|
||||
DPRINT ("VfatGetPositionInformation()\n");
|
||||
|
||||
memcpy (&PositionInfo->CurrentByteOffset, &FileObject->CurrentByteOffset,
|
||||
sizeof (LARGE_INTEGER));
|
||||
|
@ -85,12 +91,13 @@ NTSTATUS FsdGetPositionInformation(PFILE_OBJECT FileObject,
|
|||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS FsdGetBasicInformation(PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
VfatGetBasicInformation (PFILE_OBJECT FileObject,
|
||||
PVFATFCB FCB,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_BASIC_INFORMATION BasicInfo)
|
||||
{
|
||||
DPRINT("FsdGetBasicInformation()\n");
|
||||
DPRINT ("VfatGetBasicInformation()\n");
|
||||
|
||||
FsdDosDateTimeToFileTime (FCB->entry.CreationDate, FCB->entry.CreationTime,
|
||||
&BasicInfo->CreationTime);
|
||||
|
@ -109,7 +116,8 @@ NTSTATUS FsdGetBasicInformation(PFILE_OBJECT FileObject,
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS FsdSetDispositionInformation(PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
VfatSetDispositionInformation (PFILE_OBJECT FileObject,
|
||||
PVFATFCB FCB,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_DISPOSITION_INFORMATION DispositionInfo)
|
||||
|
@ -122,7 +130,8 @@ NTSTATUS FsdSetDispositionInformation(PFILE_OBJECT FileObject,
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatQueryInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Retrieve the specified file information
|
||||
*/
|
||||
|
@ -156,21 +165,18 @@ NTSTATUS STDCALL FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
SystemBuffer = Irp->UserBuffer;
|
||||
// SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
switch(FileInformationClass) {
|
||||
switch (FileInformationClass)
|
||||
{
|
||||
case FileStandardInformation:
|
||||
RC = FsdGetStandardInformation(FCB, DeviceObject, SystemBuffer);
|
||||
RC = VfatGetStandardInformation (FCB, DeviceObject, SystemBuffer);
|
||||
break;
|
||||
case FilePositionInformation:
|
||||
RC = FsdGetPositionInformation(FileObject,
|
||||
FCB,
|
||||
DeviceObject,
|
||||
SystemBuffer);
|
||||
RC = VfatGetPositionInformation (FileObject,
|
||||
FCB, DeviceObject, SystemBuffer);
|
||||
break;
|
||||
case FileBasicInformation:
|
||||
RC = FsdGetBasicInformation(FileObject,
|
||||
FCB,
|
||||
DeviceObject,
|
||||
SystemBuffer);
|
||||
RC = VfatGetBasicInformation (FileObject,
|
||||
FCB, DeviceObject, SystemBuffer);
|
||||
break;
|
||||
default:
|
||||
RC = STATUS_NOT_IMPLEMENTED;
|
||||
|
@ -183,7 +189,8 @@ NTSTATUS STDCALL FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
return RC;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL VfatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatSetInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Retrieve the specified file information
|
||||
*/
|
||||
|
@ -200,8 +207,7 @@ NTSTATUS STDCALL VfatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
assert (DeviceObject != NULL);
|
||||
assert (Irp != NULL);
|
||||
|
||||
DPRINT("FsdSetInformation(DeviceObject %x, Irp %x)\n",
|
||||
DeviceObject,Irp);
|
||||
DPRINT ("VfatSetInformation(DeviceObject %x, Irp %x)\n", DeviceObject, Irp);
|
||||
|
||||
/* INITIALIZATION */
|
||||
Stack = IoGetCurrentIrpStackLocation (Irp);
|
||||
|
@ -222,16 +228,12 @@ NTSTATUS STDCALL VfatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
switch (FileInformationClass)
|
||||
{
|
||||
case FilePositionInformation:
|
||||
RC = FsdSetPositionInformation(FileObject,
|
||||
FCB,
|
||||
DeviceObject,
|
||||
SystemBuffer);
|
||||
RC = VfatSetPositionInformation (FileObject,
|
||||
FCB, DeviceObject, SystemBuffer);
|
||||
break;
|
||||
case FileDispositionInformation:
|
||||
RC = FsdSetDispositionInformation(FileObject,
|
||||
FCB,
|
||||
DeviceObject,
|
||||
SystemBuffer);
|
||||
RC = VfatSetDispositionInformation (FileObject,
|
||||
FCB, DeviceObject, SystemBuffer);
|
||||
break;
|
||||
default:
|
||||
RC = STATUS_NOT_IMPLEMENTED;
|
||||
|
@ -243,6 +245,3 @@ NTSTATUS STDCALL VfatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
return RC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: iface.c,v 1.44 2000/12/29 13:45:01 ekohl Exp $
|
||||
/* $Id: iface.c,v 1.45 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -8,11 +8,15 @@
|
|||
* UPDATE HISTORY:
|
||||
* ?? Created
|
||||
* 24-10-1998 Fixed bugs in long filename support
|
||||
* Fixed a bug that prevented unsuccessful file open requests being reported
|
||||
* Now works with long filenames that span over a sector boundary
|
||||
* Fixed a bug that prevented unsuccessful file open requests
|
||||
* being reported
|
||||
* Now works with long filenames that span over a sector
|
||||
* boundary
|
||||
* 28-10-1998 Reads entire FAT into memory
|
||||
* VFatReadSector modified to read in more than one sector at a time
|
||||
* 7-11-1998 Fixed bug that assumed that directory data could be fragmented
|
||||
* VFatReadSector modified to read in more than one sector at a
|
||||
* time
|
||||
* 7-11-1998 Fixed bug that assumed that directory data could be
|
||||
* fragmented
|
||||
* 8-12-1998 Added FAT32 support
|
||||
* Added initial writability functions
|
||||
* WARNING: DO NOT ATTEMPT TO TEST WRITABILITY FUNCTIONS!!!
|
||||
|
@ -36,7 +40,8 @@ static PDRIVER_OBJECT VfatDriverObject;
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount)
|
||||
BOOLEAN
|
||||
VfatHasFileSystem (PDEVICE_OBJECT DeviceToMount)
|
||||
/*
|
||||
* FUNCTION: Tests if the device contains a filesystem that can be mounted
|
||||
* by this fsd
|
||||
|
@ -60,8 +65,8 @@ BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount)
|
|||
return (FALSE);
|
||||
}
|
||||
|
||||
NTSTATUS FsdMountDevice(PDEVICE_EXTENSION DeviceExt,
|
||||
PDEVICE_OBJECT DeviceToMount)
|
||||
NTSTATUS
|
||||
VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
|
||||
/*
|
||||
* FUNCTION: Mounts the device
|
||||
*/
|
||||
|
@ -79,8 +84,10 @@ NTSTATUS FsdMountDevice(PDEVICE_EXTENSION DeviceExt,
|
|||
DeviceExt->rootDirectorySectors =
|
||||
(DeviceExt->Boot->RootEntries * 32) / DeviceExt->Boot->BytesPerSector;
|
||||
DeviceExt->rootStart =
|
||||
DeviceExt->FATStart+DeviceExt->Boot->FATCount*DeviceExt->Boot->FATSectors;
|
||||
DeviceExt->dataStart=DeviceExt->rootStart+DeviceExt->rootDirectorySectors;
|
||||
DeviceExt->FATStart +
|
||||
DeviceExt->Boot->FATCount * DeviceExt->Boot->FATSectors;
|
||||
DeviceExt->dataStart =
|
||||
DeviceExt->rootStart + DeviceExt->rootDirectorySectors;
|
||||
DeviceExt->FATEntriesPerSector = DeviceExt->Boot->BytesPerSector / 32;
|
||||
DeviceExt->BytesPerCluster = DeviceExt->Boot->SectorsPerCluster *
|
||||
DeviceExt->Boot->BytesPerSector;
|
||||
|
@ -89,7 +96,10 @@ NTSTATUS FsdMountDevice(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
DeviceExt->FatType = FAT12;
|
||||
}
|
||||
else if (strncmp(((struct _BootSector32 *)(DeviceExt->Boot))->SysType,"FAT32",5)==0)
|
||||
else
|
||||
if (strncmp
|
||||
(((struct _BootSector32 *) (DeviceExt->Boot))->SysType, "FAT32",
|
||||
5) == 0)
|
||||
{
|
||||
DeviceExt->FatType = FAT32;
|
||||
DeviceExt->rootDirectorySectors = DeviceExt->Boot->SectorsPerCluster;
|
||||
|
@ -107,13 +117,17 @@ NTSTATUS FsdMountDevice(PDEVICE_EXTENSION DeviceExt,
|
|||
// because on a 8GB partition with 2 KO clusters, the fat = 8 MO
|
||||
if (DeviceExt->FatType != FAT32)
|
||||
{
|
||||
DeviceExt->FAT = ExAllocatePool(NonPagedPool, BLOCKSIZE*DeviceExt->Boot->FATSectors);
|
||||
VFATReadSectors(DeviceToMount, DeviceExt->FATStart, DeviceExt->Boot->FATSectors, (UCHAR *)DeviceExt->FAT);
|
||||
DeviceExt->FAT =
|
||||
ExAllocatePool (NonPagedPool,
|
||||
BLOCKSIZE * DeviceExt->Boot->FATSectors);
|
||||
VFATReadSectors (DeviceToMount, DeviceExt->FATStart,
|
||||
DeviceExt->Boot->FATSectors, (UCHAR *) DeviceExt->FAT);
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS FsdMount(PDEVICE_OBJECT DeviceToMount)
|
||||
NTSTATUS
|
||||
VfatMount (PDEVICE_OBJECT DeviceToMount)
|
||||
/*
|
||||
* FUNCTION: Mount the filesystem
|
||||
*/
|
||||
|
@ -123,16 +137,12 @@ NTSTATUS FsdMount(PDEVICE_OBJECT DeviceToMount)
|
|||
|
||||
IoCreateDevice (VfatDriverObject,
|
||||
sizeof (DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
NULL, FILE_DEVICE_FILE_SYSTEM, 0, FALSE, &DeviceObject);
|
||||
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
||||
DeviceExt = (PVOID) DeviceObject->DeviceExtension;
|
||||
// use same vpb as device disk
|
||||
DeviceObject->Vpb = DeviceToMount->Vpb;
|
||||
FsdMountDevice(DeviceExt,DeviceToMount);
|
||||
VfatMountDevice (DeviceExt, DeviceToMount);
|
||||
DeviceObject->Vpb->Flags |= VPB_MOUNTED;
|
||||
DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack (DeviceObject,
|
||||
DeviceToMount);
|
||||
|
@ -156,7 +166,8 @@ NTSTATUS FsdMount(PDEVICE_OBJECT DeviceToMount)
|
|||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: File system control
|
||||
*/
|
||||
|
@ -171,10 +182,10 @@ NTSTATUS STDCALL FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
/* FIXME: should make sure that this is actually a mount request! */
|
||||
|
||||
if (FsdHasFileSystem(DeviceToMount))
|
||||
if (VfatHasFileSystem (DeviceToMount))
|
||||
{
|
||||
DPRINT ("VFAT: Recognized volume\n");
|
||||
Status = FsdMount(DeviceToMount);
|
||||
Status = VfatMount (DeviceToMount);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -189,8 +200,8 @@ NTSTATUS STDCALL FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
return (Status);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT _DriverObject,
|
||||
PUNICODE_STRING RegistryPath)
|
||||
NTSTATUS STDCALL
|
||||
DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath)
|
||||
/*
|
||||
* FUNCTION: Called by the system to initalize the driver
|
||||
* ARGUMENTS:
|
||||
|
@ -216,22 +227,21 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT _DriverObject,
|
|||
}
|
||||
|
||||
DeviceObject->Flags = DO_DIRECT_IO;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_CLOSE] = FsdClose;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_CREATE] = FsdCreate;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_READ] = FsdRead;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_WRITE] = FsdWrite;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_CLOSE] = VfatClose;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_CREATE] = VfatCreate;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_READ] = VfatRead;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_WRITE] = VfatWrite;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
|
||||
FsdFileSystemControl;
|
||||
VfatFileSystemControl;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
|
||||
FsdQueryInformation;
|
||||
VfatQueryInformation;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
|
||||
VfatSetInformation;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
|
||||
FsdDirectoryControl;
|
||||
VfatDirectoryControl;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
|
||||
VfatQueryVolumeInformation;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_SHUTDOWN] =
|
||||
VfatShutdown;
|
||||
VfatDriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = VfatShutdown;
|
||||
|
||||
VfatDriverObject->DriverUnload = NULL;
|
||||
|
||||
|
@ -239,4 +249,3 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT _DriverObject,
|
|||
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rw.c,v 1.11 2000/12/05 17:12:16 jean Exp $
|
||||
/* $Id: rw.c,v 1.12 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <ddk/cctypes.h>
|
||||
#include <ntos/minmax.h>
|
||||
|
||||
#define NDEBUG
|
||||
|
@ -22,9 +21,9 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PVOID Buffer, ULONG Length, ULONG ReadOffset,
|
||||
PULONG LengthRead)
|
||||
NTSTATUS
|
||||
VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PVOID Buffer, ULONG Length, ULONG ReadOffset, PULONG LengthRead)
|
||||
/*
|
||||
* FUNCTION: Reads data from a file
|
||||
*/
|
||||
|
@ -70,15 +69,16 @@ CHECKPOINT;
|
|||
*LengthRead = 0;
|
||||
/* FIXME: optimize by remembering the last cluster read and using if possible */
|
||||
Temp = ExAllocatePool (NonPagedPool, DeviceExt->BytesPerCluster);
|
||||
if(!Temp) return STATUS_UNSUCCESSFUL;
|
||||
if (!Temp)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
if (FirstCluster == 1)
|
||||
{ //root of FAT16 or FAT12
|
||||
CurrentCluster = DeviceExt->rootStart + ReadOffset
|
||||
/ (DeviceExt->BytesPerCluster) * DeviceExt->Boot->SectorsPerCluster;
|
||||
}
|
||||
else
|
||||
for (FileOffset=0; FileOffset < ReadOffset / DeviceExt->BytesPerCluster
|
||||
; FileOffset++)
|
||||
for (FileOffset = 0; FileOffset < ReadOffset / DeviceExt->BytesPerCluster;
|
||||
FileOffset++)
|
||||
{
|
||||
CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster);
|
||||
}
|
||||
|
@ -89,8 +89,7 @@ CHECKPOINT;
|
|||
{
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
CurrentCluster,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Temp);
|
||||
DeviceExt->Boot->SectorsPerCluster, Temp);
|
||||
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
|
||||
}
|
||||
else
|
||||
|
@ -115,8 +114,7 @@ CHECKPOINT;
|
|||
{
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
CurrentCluster,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Buffer);
|
||||
DeviceExt->Boot->SectorsPerCluster, Buffer);
|
||||
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
|
||||
}
|
||||
else
|
||||
|
@ -142,8 +140,7 @@ CHECKPOINT;
|
|||
{
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
CurrentCluster,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Temp);
|
||||
DeviceExt->Boot->SectorsPerCluster, Temp);
|
||||
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
|
||||
}
|
||||
else
|
||||
|
@ -157,7 +154,8 @@ CHECKPOINT;
|
|||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
VfatWriteFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PVOID Buffer, ULONG Length, ULONG WriteOffset)
|
||||
/*
|
||||
* FUNCTION: Writes data to file
|
||||
|
@ -224,7 +222,8 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
FileOffset < WriteOffset / DeviceExt->BytesPerCluster;
|
||||
FileOffset++)
|
||||
{
|
||||
CurrentCluster = GetNextWriteCluster(DeviceExt,CurrentCluster);
|
||||
CurrentCluster =
|
||||
GetNextWriteCluster (DeviceExt, CurrentCluster);
|
||||
}
|
||||
}
|
||||
CHECKPOINT;
|
||||
|
@ -245,8 +244,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
{
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
CurrentCluster,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Temp);
|
||||
DeviceExt->Boot->SectorsPerCluster, Temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -255,8 +253,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
|
||||
/* Overwrite the last parts of the data as necessary */
|
||||
memcpy (Temp + (WriteOffset % DeviceExt->BytesPerCluster),
|
||||
Buffer,
|
||||
TempLength);
|
||||
Buffer, TempLength);
|
||||
|
||||
/* Write the cluster back */
|
||||
Length2 -= TempLength;
|
||||
|
@ -264,8 +261,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
{
|
||||
VFATWriteSectors (DeviceExt->StorageDevice,
|
||||
CurrentCluster,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Temp);
|
||||
DeviceExt->Boot->SectorsPerCluster, Temp);
|
||||
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
|
||||
}
|
||||
else
|
||||
|
@ -293,8 +289,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
{
|
||||
VFATWriteSectors (DeviceExt->StorageDevice,
|
||||
CurrentCluster,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Buffer);
|
||||
DeviceExt->Boot->SectorsPerCluster, Buffer);
|
||||
CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
|
||||
}
|
||||
else
|
||||
|
@ -323,8 +318,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
{
|
||||
VFATReadSectors (DeviceExt->StorageDevice,
|
||||
CurrentCluster,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Temp);
|
||||
DeviceExt->Boot->SectorsPerCluster, Temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -336,8 +330,7 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
{
|
||||
VFATWriteSectors (DeviceExt->StorageDevice,
|
||||
CurrentCluster,
|
||||
DeviceExt->Boot->SectorsPerCluster,
|
||||
Temp);
|
||||
DeviceExt->Boot->SectorsPerCluster, Temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -350,11 +343,9 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
|
||||
/* set dates and times */
|
||||
KeQuerySystemTime (&SystemTime);
|
||||
ExSystemTimeToLocalTime (&SystemTime,
|
||||
&LocalTime);
|
||||
ExSystemTimeToLocalTime (&SystemTime, &LocalTime);
|
||||
FsdFileTimeToDosDateTime ((TIME *) & LocalTime,
|
||||
&Fcb->entry.UpdateDate,
|
||||
&Fcb->entry.UpdateTime);
|
||||
&Fcb->entry.UpdateDate, &Fcb->entry.UpdateTime);
|
||||
Fcb->entry.AccessDate = Fcb->entry.UpdateDate;
|
||||
|
||||
if (Fcb->entry.FileSize < WriteOffset + Length
|
||||
|
@ -371,7 +362,8 @@ NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Write to a file
|
||||
*/
|
||||
|
@ -384,13 +376,13 @@ NTSTATUS STDCALL FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("FsdWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
|
||||
DPRINT ("VfatWrite(DeviceObject %x Irp %x)\n", DeviceObject, Irp);
|
||||
|
||||
Length = Stack->Parameters.Write.Length;
|
||||
Buffer = MmGetSystemAddressForMdl (Irp->MdlAddress);
|
||||
Offset = Stack->Parameters.Write.ByteOffset.u.LowPart;
|
||||
|
||||
Status = FsdWriteFile(DeviceExt,FileObject,Buffer,Length,Offset);
|
||||
Status = VfatWriteFile (DeviceExt, FileObject, Buffer, Length, Offset);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = Length;
|
||||
|
@ -399,7 +391,8 @@ NTSTATUS STDCALL FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
return (Status);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatRead (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Read from a file
|
||||
*/
|
||||
|
@ -414,7 +407,7 @@ NTSTATUS STDCALL FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
ULONG LengthRead;
|
||||
PVFATFCB Fcb;
|
||||
|
||||
DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||
DPRINT ("VfatRead(DeviceObject %x, Irp %x)\n", DeviceObject, Irp);
|
||||
|
||||
/* Precondition / Initialization */
|
||||
assert (Irp != NULL);
|
||||
|
@ -437,12 +430,8 @@ NTSTATUS STDCALL FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
}
|
||||
else
|
||||
{
|
||||
Status = FsdReadFile(DeviceExt,
|
||||
FileObject,
|
||||
Buffer,
|
||||
Length,
|
||||
Offset,
|
||||
&LengthRead);
|
||||
Status = VfatReadFile (DeviceExt,
|
||||
FileObject, Buffer, Length, Offset, &LengthRead);
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
@ -451,5 +440,3 @@ NTSTATUS STDCALL FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: string.c,v 1.3 2000/06/29 23:35:51 dwelch Exp $
|
||||
/* $Id: string.c,v 1.4 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <ddk/cctypes.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* $Id: vfat.h,v 1.18 2000/12/29 13:45:01 ekohl Exp $ */
|
||||
/* $Id: vfat.h,v 1.19 2000/12/29 23:17:12 dwelch Exp $ */
|
||||
|
||||
#include <ddk/ntifs.h>
|
||||
|
||||
struct _BootSector {
|
||||
unsigned char magic0, res0, magic1;
|
||||
|
@ -85,34 +87,17 @@ typedef struct
|
|||
ULONG BytesPerCluster;
|
||||
ULONG FatType;
|
||||
unsigned char* FAT;
|
||||
|
||||
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
||||
|
||||
typedef struct _FSRTL_COMMON_FCB_HEADER{
|
||||
char IsFastIoPossible;//is char the realtype ?
|
||||
ERESOURCE Resource;
|
||||
ERESOURCE PagingIoResource;
|
||||
ULONG Flags;// is long the real type ?
|
||||
LARGE_INTEGER AllocationSize;
|
||||
LARGE_INTEGER FileSize;
|
||||
LARGE_INTEGER ValidDataLength;
|
||||
// other fields ??
|
||||
} FSRTL_COMMON_FCB_HEADER;
|
||||
|
||||
typedef struct _SFsdNTRequiredFCB {
|
||||
FSRTL_COMMON_FCB_HEADER CommonFCBHeader;
|
||||
SECTION_OBJECT_POINTERS SectionObject;
|
||||
ERESOURCE MainResource;
|
||||
ERESOURCE PagingIoResource;
|
||||
} SFsdNTRequiredFCB, *PtrSFsdNTRequiredFCB;
|
||||
|
||||
typedef struct _VFATFCB
|
||||
{
|
||||
SFsdNTRequiredFCB NTRequiredFCB;
|
||||
REACTOS_COMMON_FCB_HEADER RFCB;
|
||||
FATDirEntry entry;
|
||||
WCHAR *ObjectName; // point on filename (250 chars max) in PathName
|
||||
WCHAR PathName[MAX_PATH];// path+filename 260 max
|
||||
long RefCount;
|
||||
/* point on filename (250 chars max) in PathName */
|
||||
WCHAR *ObjectName;
|
||||
/* path+filename 260 max */
|
||||
WCHAR PathName[MAX_PATH];
|
||||
LONG RefCount;
|
||||
PDEVICE_EXTENSION pDevExt;
|
||||
LIST_ENTRY FcbListEntry;
|
||||
struct _VFATFCB* parentFcb;
|
||||
|
@ -124,8 +109,10 @@ typedef struct _VFATCCB
|
|||
LIST_ENTRY NextCCB;
|
||||
PFILE_OBJECT PtrFileObject;
|
||||
LARGE_INTEGER CurrentByteOffset;
|
||||
ULONG StartSector; // for DirectoryControl
|
||||
ULONG StartEntry; //for DirectoryControl
|
||||
/* for DirectoryControl */
|
||||
ULONG StartSector;
|
||||
/* for DirectoryControl */
|
||||
ULONG StartEntry;
|
||||
// PSTRING DirectorySearchPattern;// for DirectoryControl ?
|
||||
} VFATCCB, *PVFATCCB;
|
||||
|
||||
|
@ -147,97 +134,135 @@ typedef struct __DOSDATE
|
|||
WORD Year:5;
|
||||
} DOSDATE, *PDOSDATE;
|
||||
|
||||
// functions called by i/o manager :
|
||||
NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT _DriverObject,PUNICODE_STRING RegistryPath);
|
||||
NTSTATUS STDCALL FsdDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
/* functions called by i/o manager : */
|
||||
NTSTATUS STDCALL
|
||||
DriverEntry(PDRIVER_OBJECT _DriverObject,PUNICODE_STRING RegistryPath);
|
||||
NTSTATUS STDCALL
|
||||
VfatDirectoryControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL
|
||||
VfatRead(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL
|
||||
VfatWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL
|
||||
VfatCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL
|
||||
VfatClose(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL
|
||||
VfatFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL
|
||||
VfatQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
|
||||
|
||||
// internal functions in blockdev.c
|
||||
BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
/* internal functions in blockdev.c */
|
||||
BOOLEAN
|
||||
VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector,
|
||||
IN ULONG SectorCount,
|
||||
IN UCHAR* Buffer);
|
||||
|
||||
BOOLEAN VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
BOOLEAN
|
||||
VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector,
|
||||
IN ULONG SectorCount,
|
||||
IN UCHAR* Buffer);
|
||||
|
||||
//internal functions in dir.c :
|
||||
/* internal functions in dir.c : */
|
||||
BOOL FsdDosDateTimeToFileTime(WORD wDosDate,WORD wDosTime, TIME *FileTime);
|
||||
BOOL FsdFileTimeToDosDateTime(TIME *FileTime,WORD *pwDosDate,WORD *pwDosTime);
|
||||
|
||||
//internal functions in iface.c :
|
||||
NTSTATUS FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||
/* internal functions in iface.c : */
|
||||
NTSTATUS
|
||||
FindFile(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||
PVFATFCB Parent, PWSTR FileToFind,ULONG *StartSector,ULONG *Entry);
|
||||
NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject);
|
||||
NTSTATUS FsdGetStandardInformation(PVFATFCB FCB, PDEVICE_OBJECT DeviceObject,
|
||||
NTSTATUS
|
||||
VfatCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject);
|
||||
NTSTATUS
|
||||
VfatGetStandardInformation(PVFATFCB FCB, PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_STANDARD_INFORMATION StandardInfo);
|
||||
NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
VfatOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PWSTR FileName);
|
||||
NTSTATUS FsdReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
VfatReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PVOID Buffer, ULONG Length, ULONG ReadOffset,
|
||||
PULONG LengthRead);
|
||||
NTSTATUS FsdWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
VfatWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PVOID Buffer, ULONG Length, ULONG WriteOffset);
|
||||
ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster);
|
||||
BOOLEAN IsDeletedEntry(PVOID Block, ULONG Offset);
|
||||
BOOLEAN IsLastEntry(PVOID Block, ULONG Offset);
|
||||
wchar_t * vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount);
|
||||
void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster);
|
||||
|
||||
//internal functions in dirwr.c
|
||||
NTSTATUS addEntry(PDEVICE_EXTENSION DeviceExt
|
||||
,PFILE_OBJECT pFileObject,ULONG RequestedOptions,UCHAR ReqAttr);
|
||||
NTSTATUS updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject);
|
||||
|
||||
|
||||
ULONG
|
||||
GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster);
|
||||
BOOLEAN
|
||||
IsDeletedEntry(PVOID Block, ULONG Offset);
|
||||
BOOLEAN
|
||||
IsLastEntry(PVOID Block, ULONG Offset);
|
||||
wchar_t*
|
||||
vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount);
|
||||
VOID
|
||||
VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster);
|
||||
|
||||
/* internal functions in dirwr.c */
|
||||
NTSTATUS
|
||||
addEntry(PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject,ULONG RequestedOptions,UCHAR ReqAttr);
|
||||
NTSTATUS
|
||||
updEntry(PDEVICE_EXTENSION DeviceExt,PFILE_OBJECT pFileObject);
|
||||
|
||||
/*
|
||||
* String functions
|
||||
*/
|
||||
void RtlAnsiToUnicode(PWSTR Dest, PCH Source, ULONG Length);
|
||||
void RtlCatAnsiToUnicode(PWSTR Dest, PCH Source, ULONG Length);
|
||||
void vfat_initstr(wchar_t *wstr, ULONG wsize);
|
||||
wchar_t * vfat_wcsncat(wchar_t * dest, const wchar_t * src,size_t wstart, size_t wcount);
|
||||
wchar_t * vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount);
|
||||
wchar_t * vfat_movstr(wchar_t *src, ULONG dpos, ULONG spos, ULONG len);
|
||||
BOOLEAN wstrcmpi(PWSTR s1, PWSTR s2);
|
||||
BOOLEAN wstrcmpjoki(PWSTR s1, PWSTR s2);
|
||||
VOID
|
||||
RtlAnsiToUnicode(PWSTR Dest, PCH Source, ULONG Length);
|
||||
VOID
|
||||
RtlCatAnsiToUnicode(PWSTR Dest, PCH Source, ULONG Length);
|
||||
VOID
|
||||
vfat_initstr(wchar_t *wstr, ULONG wsize);
|
||||
wchar_t*
|
||||
vfat_wcsncat(wchar_t * dest, const wchar_t * src,size_t wstart, size_t wcount);
|
||||
wchar_t*
|
||||
vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount);
|
||||
wchar_t*
|
||||
vfat_movstr(wchar_t *src, ULONG dpos, ULONG spos, ULONG len);
|
||||
BOOLEAN
|
||||
wstrcmpi(PWSTR s1, PWSTR s2);
|
||||
BOOLEAN
|
||||
wstrcmpjoki(PWSTR s1, PWSTR s2);
|
||||
|
||||
/*
|
||||
* functions from fat.c
|
||||
*/
|
||||
ULONG ClusterToSector(PDEVICE_EXTENSION DeviceExt, ULONG Cluster);
|
||||
ULONG GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster);
|
||||
VOID VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster);
|
||||
ULONG FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
|
||||
ULONG FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
|
||||
ULONG FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
|
||||
ULONG
|
||||
ClusterToSector(PDEVICE_EXTENSION DeviceExt, ULONG Cluster);
|
||||
ULONG
|
||||
GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster);
|
||||
VOID
|
||||
VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster);
|
||||
ULONG
|
||||
FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
|
||||
ULONG
|
||||
FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
|
||||
ULONG
|
||||
FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
|
||||
|
||||
/*
|
||||
* functions from volume.c
|
||||
*/
|
||||
NTSTATUS STDCALL VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL
|
||||
VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
|
||||
/*
|
||||
* functions from finfo.c
|
||||
*/
|
||||
NTSTATUS STDCALL VfatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS STDCALL
|
||||
VfatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
|
||||
/*
|
||||
* From create.c
|
||||
*/
|
||||
NTSTATUS ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb);
|
||||
NTSTATUS
|
||||
ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb);
|
||||
|
||||
/*
|
||||
* functions from shutdown.c
|
||||
*/
|
||||
NTSTATUS STDCALL VfatShutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: volume.c,v 1.4 2000/09/12 10:12:13 jean Exp $
|
||||
/* $Id: volume.c,v 1.5 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <ddk/cctypes.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -20,7 +19,8 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS FsdGetFsVolumeInformation(PFILE_OBJECT FileObject,
|
||||
NTSTATUS
|
||||
FsdGetFsVolumeInformation (PFILE_OBJECT FileObject,
|
||||
PVFATFCB FCB,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_FS_VOLUME_INFORMATION FsVolumeInfo)
|
||||
|
@ -47,7 +47,8 @@ NTSTATUS FsdGetFsVolumeInformation(PFILE_OBJECT FileObject,
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS FsdGetFsAttributeInformation(PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo)
|
||||
NTSTATUS
|
||||
FsdGetFsAttributeInformation (PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo)
|
||||
{
|
||||
DPRINT ("FsdGetFsAttributeInformation()\n");
|
||||
DPRINT ("FsAttributeInfo = %p\n", FsAttributeInfo);
|
||||
|
@ -65,7 +66,8 @@ NTSTATUS FsdGetFsAttributeInformation(PFILE_FS_ATTRIBUTE_INFORMATION FsAttribute
|
|||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
|
||||
NTSTATUS
|
||||
FsdGetFsSizeInformation (PDEVICE_OBJECT DeviceObject,
|
||||
PFILE_FS_SIZE_INFORMATION FsSizeInfo)
|
||||
{
|
||||
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
|
||||
|
@ -78,7 +80,8 @@ NTSTATUS FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
if (DeviceExt->FatType == FAT32)
|
||||
{
|
||||
struct _BootSector32 *BootSect = (struct _BootSector32 *)DeviceExt->Boot;
|
||||
struct _BootSector32 *BootSect =
|
||||
(struct _BootSector32 *) DeviceExt->Boot;
|
||||
|
||||
if (BootSect->Sectors)
|
||||
FsSizeInfo->TotalAllocationUnits.QuadPart = BootSect->Sectors;
|
||||
|
@ -117,7 +120,8 @@ NTSTATUS FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
NTSTATUS STDCALL
|
||||
VfatQueryVolumeInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Retrieve the specified file information
|
||||
*/
|
||||
|
@ -161,9 +165,7 @@ NTSTATUS STDCALL VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Ir
|
|||
{
|
||||
case FileFsVolumeInformation:
|
||||
RC = FsdGetFsVolumeInformation (FileObject,
|
||||
FCB,
|
||||
DeviceObject,
|
||||
SystemBuffer);
|
||||
FCB, DeviceObject, SystemBuffer);
|
||||
break;
|
||||
|
||||
case FileFsAttributeInformation:
|
||||
|
@ -184,5 +186,3 @@ NTSTATUS STDCALL VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Ir
|
|||
|
||||
return RC;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,4 +73,9 @@ typedef struct _SECTION_OBJECT_POINTERS
|
|||
|
||||
typedef VOID (*PFLUSH_TO_LSN)(IN PVOID LogHandle, IN LARGE_INTEGER Lsn);
|
||||
|
||||
typedef struct _REACTOS_COMMON_FCB_HEADER
|
||||
{
|
||||
PBCB Bcb;
|
||||
} REACTOS_COMMON_FCB_HEADER;
|
||||
|
||||
#endif /* __INCLUDE_DDK_CCTYPES_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: iotypes.h,v 1.20 2000/10/06 22:53:21 ekohl Exp $
|
||||
/* $Id: iotypes.h,v 1.21 2000/12/29 23:17:11 dwelch Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -267,6 +267,11 @@ typedef struct _IO_COMPLETION_CONTEXT
|
|||
#define FO_HANDLE_CREATED 0x00040000
|
||||
#define FO_FILE_FAST_IO_READ 0x00080000
|
||||
|
||||
#define FO_DIRECT_CACHE_READ 0x72000001
|
||||
#define FO_DIRECT_CACHE_WRITE 0x72000002
|
||||
#define FO_DIRECT_CACHE_PAGING_READ 0x72000004
|
||||
#define FO_DIRECT_CACHE_PAGING_WRITE 0x72000008
|
||||
|
||||
typedef struct _FILE_OBJECT
|
||||
{
|
||||
CSHORT Type;
|
||||
|
|
|
@ -34,39 +34,24 @@ typedef struct _CACHE_SEGMENT
|
|||
PBCB Bcb;
|
||||
} CACHE_SEGMENT, *PCACHE_SEGMENT;
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
CcFlushCachePage (
|
||||
PCACHE_SEGMENT CacheSeg
|
||||
);
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
CcReleaseCachePage (
|
||||
PBCB Bcb,
|
||||
NTSTATUS STDCALL
|
||||
CcFlushCachePage (PCACHE_SEGMENT CacheSeg);
|
||||
NTSTATUS STDCALL
|
||||
CcReleaseCachePage (PBCB Bcb,
|
||||
PCACHE_SEGMENT CacheSeg,
|
||||
BOOLEAN Valid
|
||||
);
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
CcRequestCachePage (
|
||||
PBCB Bcb,
|
||||
BOOLEAN Valid);
|
||||
NTSTATUS STDCALL
|
||||
CcRequestCachePage (PBCB Bcb,
|
||||
ULONG FileOffset,
|
||||
PVOID* BaseAddress,
|
||||
PBOOLEAN UptoDate,
|
||||
PCACHE_SEGMENT * CacheSeg
|
||||
);
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
CcInitializeFileCache (
|
||||
PFILE_OBJECT FileObject,
|
||||
PBCB * Bcb
|
||||
);
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
CcReleaseFileCache (
|
||||
PFILE_OBJECT FileObject,
|
||||
PBCB Bcb
|
||||
);
|
||||
PCACHE_SEGMENT* CacheSeg);
|
||||
NTSTATUS STDCALL
|
||||
CcInitializeFileCache (PFILE_OBJECT FileObject,
|
||||
PBCB* Bcb);
|
||||
NTSTATUS STDCALL
|
||||
CcReleaseFileCache (PFILE_OBJECT FileObject,
|
||||
PBCB Bcb);
|
||||
|
||||
#include <ddk/cctypes.h>
|
||||
|
||||
|
|
|
@ -304,6 +304,9 @@ NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src, ULONG Count);
|
|||
NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src, ULONG Count);
|
||||
NTSTATUS
|
||||
MmCreatePhysicalMemorySection(VOID);
|
||||
PVOID
|
||||
MmGetContinuousPages(ULONG NumberOfBytes,
|
||||
PHYSICAL_ADDRESS HighestAcceptableAddress);
|
||||
|
||||
#define MM_PHYSICAL_PAGE_MPW_PENDING (0x8)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cont.c,v 1.4 2000/03/29 13:11:54 dwelch Exp $
|
||||
/* $Id: cont.c,v 1.5 2000/12/29 23:17:12 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -12,6 +12,7 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/mm.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
@ -44,11 +45,38 @@
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
PVOID STDCALL MmAllocateContiguousMemory (
|
||||
IN ULONG NumberOfBytes,
|
||||
PVOID STDCALL
|
||||
MmAllocateContiguousMemory (IN ULONG NumberOfBytes,
|
||||
IN PHYSICAL_ADDRESS HighestAcceptableAddress)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
PMEMORY_AREA MArea;
|
||||
NTSTATUS Status;
|
||||
PVOID BaseAddress;
|
||||
PVOID PBase;
|
||||
ULONG i;
|
||||
|
||||
Status = MmCreateMemoryArea(NULL,
|
||||
MmGetKernelAddressSpace(),
|
||||
MEMORY_AREA_CONTINUOUS_MEMORY,
|
||||
&BaseAddress,
|
||||
NumberOfBytes,
|
||||
0,
|
||||
&MArea);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
PBase = MmGetContinuousPages(NumberOfBytes,
|
||||
HighestAcceptableAddress);
|
||||
for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++)
|
||||
{
|
||||
MmCreateVirtualMapping(NULL,
|
||||
BaseAddress + (i * 4096),
|
||||
PAGE_EXECUTE_READWRITE,
|
||||
(ULONG)(PBase + (i * 4096)));
|
||||
}
|
||||
return(BaseAddress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,9 +102,13 @@ PVOID STDCALL MmAllocateContiguousMemory (
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
VOID STDCALL MmFreeContiguousMemory(IN PVOID BaseAddress)
|
||||
VOID STDCALL
|
||||
MmFreeContiguousMemory(IN PVOID BaseAddress)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
MmFreeMemoryArea(MmGetKernelAddressSpace(),
|
||||
BaseAddress,
|
||||
0,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,6 +48,62 @@ static LIST_ENTRY BiosPageListHead;
|
|||
|
||||
/* FUNCTIONS *************************************************************/
|
||||
|
||||
PVOID
|
||||
MmGetContinuousPages(ULONG NumberOfBytes,
|
||||
PHYSICAL_ADDRESS HighestAcceptableAddress)
|
||||
{
|
||||
ULONG NrPages;
|
||||
ULONG i;
|
||||
ULONG start;
|
||||
ULONG length;
|
||||
KIRQL oldIrql;
|
||||
|
||||
NrPages = PAGE_ROUND_UP(NumberOfBytes) / PAGESIZE;
|
||||
|
||||
KeAcquireSpinLock(&PageListLock, &oldIrql);
|
||||
|
||||
start = -1;
|
||||
length = 0;
|
||||
for (i = 0; i < (HighestAcceptableAddress.QuadPart / PAGESIZE); i++)
|
||||
{
|
||||
if (MmPageArray[i].Flags & MM_PHYSICAL_PAGE_FREE)
|
||||
{
|
||||
if (start == -1)
|
||||
{
|
||||
start = i;
|
||||
length = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
length++;
|
||||
}
|
||||
if (length == NrPages)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (start != -1)
|
||||
{
|
||||
start = -1;
|
||||
}
|
||||
}
|
||||
if (start == -1)
|
||||
{
|
||||
KeReleaseSpinLock(&PageListLock, oldIrql);
|
||||
return(NULL);
|
||||
}
|
||||
for (i = start; i < (start + length); i++)
|
||||
{
|
||||
RemoveEntryList(&MmPageArray[i].ListEntry);
|
||||
MmPageArray[i].Flags = MM_PHYSICAL_PAGE_USED;
|
||||
MmPageArray[i].ReferenceCount = 1;
|
||||
MmPageArray[i].LockCount = 0;
|
||||
MmPageArray[i].SavedSwapEntry = 0;
|
||||
InsertTailList(&UsedPageListHead, &MmPageArray[i].ListEntry);
|
||||
}
|
||||
return((PVOID)(start * 4096));
|
||||
}
|
||||
|
||||
PVOID MmInitializePageList(PVOID FirstPhysKernelAddress,
|
||||
PVOID LastPhysKernelAddress,
|
||||
ULONG MemorySizeInPages,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue