Removed debugging code from NTDLL loader

Make sure there is a space between the boot device and the kernel command
line
Vfat fixes

svn path=/trunk/; revision=1502
This commit is contained in:
David Welch 2001-01-12 21:00:08 +00:00
parent 1c655ae05a
commit e371c33d76
11 changed files with 247 additions and 127 deletions

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.12 2001/01/08 02:14:06 dwelch Exp $ /* $Id: create.c,v 1.13 2001/01/12 21:00:08 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -148,6 +148,7 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
char *block; char *block;
ULONG StartingSector; ULONG StartingSector;
ULONG NextCluster; ULONG NextCluster;
NTSTATUS Status;
Size = DeviceExt->rootDirectorySectors; //FIXME : in fat32, no limit Size = DeviceExt->rootDirectorySectors; //FIXME : in fat32, no limit
StartingSector = DeviceExt->rootStart; StartingSector = DeviceExt->rootStart;
@ -191,7 +192,7 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
{ {
if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1)) if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1))
{ {
NextCluster = GetNextCluster (DeviceExt, NextCluster); Status = GetNextCluster (DeviceExt, NextCluster, &NextCluster);
if (NextCluster == 0 || NextCluster == 0xffffffff) if (NextCluster == 0 || NextCluster == 0xffffffff)
{ {
*(Vpb->VolumeLabel) = 0; *(Vpb->VolumeLabel) = 0;
@ -225,6 +226,7 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
ULONG StartingSector; ULONG StartingSector;
ULONG NextCluster; ULONG NextCluster;
WCHAR TempStr[2]; WCHAR TempStr[2];
NTSTATUS Status;
DPRINT ("FindFile(Parent %x, FileToFind '%S')\n", Parent, FileToFind); DPRINT ("FindFile(Parent %x, FileToFind '%S')\n", Parent, FileToFind);
@ -352,7 +354,7 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
{ {
if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1)) if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1))
{ {
NextCluster = GetNextCluster (DeviceExt, NextCluster); Status = GetNextCluster (DeviceExt, NextCluster, &NextCluster);
if (NextCluster == 0 || NextCluster == 0xffffffff) if (NextCluster == 0 || NextCluster == 0xffffffff)
{ {
if (StartSector) if (StartSector)
@ -638,7 +640,7 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
DeviceExt = DeviceObject->DeviceExtension; DeviceExt = DeviceObject->DeviceExtension;
assert (DeviceExt); assert (DeviceExt);
Status = FsdOpenFile (DeviceExt, FileObject, FileObject->FileName.Buffer); Status = FsdOpenFile (DeviceExt, FileObject, FileObject->FileName.Buffer);
CHECKPOINT; CHECKPOINT;
@ -700,8 +702,8 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
// updEntry (DeviceExt, FileObject); // updEntry (DeviceExt, FileObject);
while (Cluster != 0xffffffff && Cluster > 1) while (Cluster != 0xffffffff && Cluster > 1)
{ {
NextCluster = GetNextCluster (DeviceExt, Cluster); Status = GetNextCluster (DeviceExt, Cluster, &NextCluster);
WriteCluster (DeviceExt, Cluster, 0); // WriteCluster (DeviceExt, Cluster, 0);
Cluster = NextCluster; Cluster = NextCluster;
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* $Id: fat.c,v 1.10 2001/01/08 02:14:06 dwelch Exp $ * $Id: fat.c,v 1.11 2001/01/12 21:00:08 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -21,8 +21,10 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
ULONG NTSTATUS
Fat32GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) Fat32GetNextCluster (PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster,
PULONG NextCluster)
/* /*
* FUNCTION: Retrieve the next FAT32 cluster from the FAT table via a physical * FUNCTION: Retrieve the next FAT32 cluster from the FAT table via a physical
* disk read * disk read
@ -31,29 +33,35 @@ Fat32GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
ULONG FATsector; ULONG FATsector;
ULONG FATeis; ULONG FATeis;
PULONG Block; PULONG Block;
NTSTATUS Status;
Block = ExAllocatePool (NonPagedPool, 1024); Block = ExAllocatePool (NonPagedPool, 1024);
FATsector = CurrentCluster / (512 / sizeof (ULONG)); FATsector = CurrentCluster / (512 / sizeof (ULONG));
FATeis = CurrentCluster - (FATsector * (512 / sizeof (ULONG))); FATeis = CurrentCluster - (FATsector * (512 / sizeof (ULONG)));
/* FIXME: Check status */ Status = VfatReadSectors (DeviceExt->StorageDevice,
VfatReadSectors (DeviceExt->StorageDevice, (ULONG) (DeviceExt->FATStart + FATsector), 1,
(ULONG) (DeviceExt->FATStart + FATsector), 1, (UCHAR *) Block);
(UCHAR *) Block); if (!NT_SUCCESS(Status))
{
return(Status);
}
CurrentCluster = Block[FATeis]; CurrentCluster = Block[FATeis];
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff) if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
CurrentCluster = 0xffffffff; CurrentCluster = 0xffffffff;
ExFreePool (Block); ExFreePool (Block);
return (CurrentCluster); *NextCluster = CurrentCluster;
return (STATUS_SUCCESS);
} }
ULONG NTSTATUS
Fat16GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) Fat16GetNextCluster (PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster,
PULONG NextCluster)
/* /*
* FUNCTION: Retrieve the next FAT16 cluster from the FAT table from the * FUNCTION: Retrieve the next FAT16 cluster from the FAT table from the
* in-memory FAT * in-memory FAT
*/ */
{ {
PUSHORT Block;
PVOID BaseAddress; PVOID BaseAddress;
BOOLEAN Valid; BOOLEAN Valid;
PCACHE_SEGMENT CacheSeg; PCACHE_SEGMENT CacheSeg;
@ -67,6 +75,10 @@ Fat16GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
&BaseAddress, &BaseAddress,
&Valid, &Valid,
&CacheSeg); &CacheSeg);
if (!NT_SUCCESS(Status))
{
return(Status);
}
if (!Valid) if (!Valid)
{ {
Status = VfatReadSectors(DeviceExt->StorageDevice, Status = VfatReadSectors(DeviceExt->StorageDevice,
@ -76,28 +88,28 @@ Fat16GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE); CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
return(0xFFFFFFFF); return(Status);
} }
} }
CurrentCluster = *((PUSHORT)(BaseAddress + (FATOffset % PAGESIZE))); CurrentCluster = *((PUSHORT)(BaseAddress + (FATOffset % PAGESIZE)));
if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff) if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff)
CurrentCluster = 0xffffffff; CurrentCluster = 0xffffffff;
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE); CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
return (CurrentCluster); *NextCluster = CurrentCluster;
return (STATUS_SUCCESS);
} }
ULONG NTSTATUS
Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster,
PULONG NextCluster)
/* /*
* FUNCTION: Retrieve the next FAT12 cluster from the FAT table from the * FUNCTION: Retrieve the next FAT12 cluster from the FAT table
* in-memory FAT
*/ */
{ {
unsigned char *CBlock;
ULONG FATOffset; ULONG FATOffset;
ULONG Entry; ULONG Entry;
PVOID PBlock;
NTSTATUS Status; NTSTATUS Status;
PVOID BaseAddress; PVOID BaseAddress;
BOOLEAN Valid; BOOLEAN Valid;
@ -114,6 +126,10 @@ Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
&BaseAddress, &BaseAddress,
&Valid, &Valid,
&CacheSeg); &CacheSeg);
if (!NT_SUCCESS(Status))
{
return(Status);
}
if (!Valid) if (!Valid)
{ {
Status = VfatReadSectors(DeviceExt->StorageDevice, Status = VfatReadSectors(DeviceExt->StorageDevice,
@ -123,7 +139,7 @@ Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE); CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
return(0xFFFFFFFF); return(Status);
} }
} }
Value1 = ((PUCHAR)BaseAddress)[FATOffset % PAGESIZE]; Value1 = ((PUCHAR)BaseAddress)[FATOffset % PAGESIZE];
@ -139,6 +155,10 @@ Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
&BaseAddress, &BaseAddress,
&Valid, &Valid,
&CacheSeg); &CacheSeg);
if (!NT_SUCCESS(Status))
{
return(Status);
}
if (!Valid) if (!Valid)
{ {
ULONG NextOffset; ULONG NextOffset;
@ -152,7 +172,7 @@ Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE); CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
return(0xFFFFFFFF); return(Status);
} }
} }
Value2 = ((PUCHAR)BaseAddress)[0]; Value2 = ((PUCHAR)BaseAddress)[0];
@ -178,16 +198,19 @@ Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
if (Entry >= 0xff8 && Entry <= 0xfff) if (Entry >= 0xff8 && Entry <= 0xfff)
Entry = 0xffffffff; Entry = 0xffffffff;
DPRINT ("Returning %x\n", Entry); DPRINT ("Returning %x\n", Entry);
return (Entry); *NextCluster = Entry;
return (STATUS_SUCCESS);
} }
ULONG NTSTATUS
GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) GetNextCluster (PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster,
PULONG NextCluster)
/* /*
* FUNCTION: Retrieve the next cluster depending on the FAT type * FUNCTION: Retrieve the next cluster depending on the FAT type
*/ */
{ {
ULONG NextCluster; NTSTATUS Status;
DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n", DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
DeviceExt, CurrentCluster); DeviceExt, CurrentCluster);
@ -196,22 +219,56 @@ GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
if (DeviceExt->FatType == FAT16) if (DeviceExt->FatType == FAT16)
{ {
NextCluster = Fat16GetNextCluster (DeviceExt, CurrentCluster); Status = Fat16GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
} }
else if (DeviceExt->FatType == FAT32) else if (DeviceExt->FatType == FAT32)
{ {
NextCluster = Fat32GetNextCluster (DeviceExt, CurrentCluster); Status = Fat32GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
} }
else else
{ {
NextCluster = Fat12GetNextCluster (DeviceExt, CurrentCluster); Status = Fat12GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
} }
ExReleaseResourceLite (&DeviceExt->FatResource); ExReleaseResourceLite (&DeviceExt->FatResource);
return (NextCluster); return (Status);
} }
NTSTATUS
VfatRequestDiskPage(PDEVICE_EXTENSION DeviceExt,
ULONG Offset,
PVOID* BaseAddress,
PCACHE_SEGMENT* CacheSeg)
{
NTSTATUS Status;
BOOLEAN Valid;
Status = CcRequestCacheSegment(DeviceExt->StorageBcb,
Offset,
BaseAddress,
&Valid,
CacheSeg);
if (!NT_SUCCESS(Status))
{
return(Status);
}
if (!Valid)
{
Status = VfatReadSectors(DeviceExt->StorageDevice,
Offset,
PAGESIZE / BLOCKSIZE,
*BaseAddress);
if (!NT_SUCCESS(Status))
{
CcReleaseCacheSegment(DeviceExt->StorageBcb, *CacheSeg, FALSE);
return(Status);
}
}
return(STATUS_SUCCESS);
}
#if 0
ULONG ULONG
FAT16FindAvailableCluster (PDEVICE_EXTENSION DeviceExt) FAT16FindAvailableCluster (PDEVICE_EXTENSION DeviceExt)
/* /*
@ -219,13 +276,67 @@ FAT16FindAvailableCluster (PDEVICE_EXTENSION DeviceExt)
*/ */
{ {
PUSHORT Block; PUSHORT Block;
int i; ULONG i;
Block = (PUSHORT) DeviceExt->FAT; PCACHE_SEG CacheSeg;
for (i = 2; i < (DeviceExt->Boot->FATSectors * 256); i++) PVOID BaseAddress;
if (Block[i] == 0) BOOLEAN Valid;
return (i); ULONG StartOffset;
/* Give an error message (out of disk space) if we reach here) */ ULONG FatLength;
return 0; ULONG j;
ULONG RCluster;
ULONG Length;
StartOffset = DeviceExt->Boot->FatStart * BLOCKSIZE;
FatLength = DevceExt->Boot->FatSectors * BLOCKSIZE;
if (StartOffset % PAGESIZE) != 0)
{
Status = VfatRequestDiskPage(DeviceExt,
PAGE_ROUND_DOWN(StartOffset),
&BaseAddress,
&CacheSeg);
if (!NT_SUCCESS(Status))
{
return(0);
}
Length = max(PAGESIZE, FatLength);
for (j = (StartOffset % PAGESIZE); j < Length; j+=2)
{
if ((*((PUSHORT)(BaseAddress + j))) == 0)
{
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
return(j);
}
}
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
StartOffset = StartOffset + (Length - (StartOffset % PAGESIZE));
FatLength = FatLength - (Length - (StartOffset % PAGESIZE));
}
for (i = 0; i < (FatLength / PAGESIZE); i++)
{
Status = VfatRequestDiskPage(DeviceExt,
PAGE_ROUND_DOWN(StartOffset),
&BaseAddress,
&CacheSeg);
if (!NT_SUCCESS(Status))
{
return(0);
}
for (j = 0; j < PAGESIZE; j+=2)
{
if (*((PUSHORT)(BaseAddress + j)) == 0)
{
CcReleaseCacheSegment(DeviceExt->StorageBcb,
CacheSeg,
TRUE);
RCluster =
(StartOffset + j) - (DeviceExt->Boot->FatStart * BLOCKSIZE);
RCluster = RCluster / 2;
return(RCluster);
}
}
}
return(0);
} }
ULONG ULONG
@ -576,6 +687,7 @@ GetNextWriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
return LastCluster; return LastCluster;
} }
} }
#endif
ULONG ULONG
ClusterToSector (PDEVICE_EXTENSION DeviceExt, unsigned long Cluster) ClusterToSector (PDEVICE_EXTENSION DeviceExt, unsigned long Cluster)
@ -607,6 +719,7 @@ VFATLoadCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
DPRINT ("Finished VFATReadSectors\n"); DPRINT ("Finished VFATReadSectors\n");
} }
#if 0
VOID VOID
VFATWriteCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) VFATWriteCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
/* /*
@ -623,3 +736,4 @@ VFATWriteCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
VfatWriteSectors (DeviceExt->StorageDevice, VfatWriteSectors (DeviceExt->StorageDevice,
Sector, DeviceExt->Boot->SectorsPerCluster, Buffer); Sector, DeviceExt->Boot->SectorsPerCluster, Buffer);
} }
#endif

View file

@ -1,4 +1,4 @@
/* $Id: iface.c,v 1.47 2001/01/08 02:14:06 dwelch Exp $ /* $Id: iface.c,v 1.48 2001/01/12 21:00:08 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -128,17 +128,6 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
DeviceExt->FatType = FAT16; DeviceExt->FatType = FAT16;
} }
// with FAT32 it's not a good idea to load always fat in memory
// 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);
/* FIXME: Check status */
VfatReadSectors (DeviceToMount, DeviceExt->FATStart,
DeviceExt->Boot->FATSectors, (UCHAR *) DeviceExt->FAT);
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.25 2001/01/01 04:42:12 dwelch Exp $ # $Id: makefile,v 1.26 2001/01/12 21:00:08 dwelch Exp $
# #
# #
PATH_TO_TOP = ../../.. PATH_TO_TOP = ../../..
@ -9,7 +9,7 @@ OBJECTS = blockdev.o close.o create.o dir.o dirwr.o iface.o string.o fat.o \
rw.o finfo.o volume.o shutdown.o $(TARGET).coff rw.o finfo.o volume.o shutdown.o $(TARGET).coff
LIBS = ../../../ntoskrnl/ntoskrnl.a LIBS = ../../../ntoskrnl/ntoskrnl.a
CFLAGS = -g CFLAGS = -g -Wall -Werror
all: $(TARGET).nostrip.sys $(TARGET).sys all: $(TARGET).nostrip.sys $(TARGET).sys

View file

@ -1,4 +1,5 @@
/* $Id: rw.c,v 1.14 2001/01/08 02:14:06 dwelch Exp $
/* $Id: rw.c,v 1.15 2001/01/12 21:00:08 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -26,50 +27,56 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID NTSTATUS
NextCluster(PDEVICE_EXTENSION DeviceExt, NextCluster(PDEVICE_EXTENSION DeviceExt,
ULONG FirstCluster, ULONG FirstCluster,
PULONG CurrentCluster) PULONG CurrentCluster)
{ {
DPRINT("NextCluster() (*CurrentCluster) 0x%x\n", (*CurrentCluster));
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
(*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster; (*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster;
return(STATUS_SUCCESS);
} }
else else
{ {
(*CurrentCluster) = GetNextCluster(DeviceExt, (*CurrentCluster)); NTSTATUS Status;
Status = GetNextCluster(DeviceExt, (*CurrentCluster), CurrentCluster);
return(Status);
} }
DPRINT("NextCluster() finished (*CurrentCluster) 0x%x\n",
(*CurrentCluster));
} }
ULONG NTSTATUS
OffsetToCluster(PDEVICE_EXTENSION DeviceExt, OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
ULONG FirstCluster, ULONG FirstCluster,
ULONG FileOffset) ULONG FileOffset,
PULONG Cluster)
{ {
ULONG CurrentCluster; ULONG CurrentCluster;
ULONG i; ULONG i;
NTSTATUS Status;
DPRINT("OffsetToCluster(FirstCluster 0x%x)\n", FirstCluster);
CurrentCluster = FirstCluster;
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
/* root of FAT16 or FAT12 */ /* root of FAT16 or FAT12 */
CurrentCluster = DeviceExt->rootStart + FileOffset *Cluster = DeviceExt->rootStart + FileOffset
/ (DeviceExt->BytesPerCluster) * DeviceExt->Boot->SectorsPerCluster; / (DeviceExt->BytesPerCluster) * DeviceExt->Boot->SectorsPerCluster;
return(STATUS_SUCCESS);
} }
else else
{ {
CurrentCluster = FirstCluster;
for (i = 0; i < FileOffset / DeviceExt->BytesPerCluster; i++) for (i = 0; i < FileOffset / DeviceExt->BytesPerCluster; i++)
{ {
CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster); Status = GetNextCluster (DeviceExt, CurrentCluster, &CurrentCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
}
} }
*Cluster = CurrentCluster;
return(STATUS_SUCCESS);
} }
DPRINT("OffsetToCluster() = 0x%x\n", CurrentCluster);
return(CurrentCluster);
} }
NTSTATUS NTSTATUS
@ -86,6 +93,7 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
PVFATFCB Fcb; PVFATFCB Fcb;
PVOID Temp; PVOID Temp;
ULONG TempLength; ULONG TempLength;
NTSTATUS Status;
/* PRECONDITION */ /* PRECONDITION */
assert (DeviceExt != NULL); assert (DeviceExt != NULL);
@ -149,7 +157,8 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
for (FileOffset = 0; FileOffset < ReadOffset / DeviceExt->BytesPerCluster; for (FileOffset = 0; FileOffset < ReadOffset / DeviceExt->BytesPerCluster;
FileOffset++) FileOffset++)
{ {
CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster); Status = GetNextCluster (DeviceExt, CurrentCluster, &CurrentCluster);
return(Status);
} }
/* /*
@ -169,7 +178,7 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
else else
{ {
VFATLoadCluster (DeviceExt, Temp, CurrentCluster); VFATLoadCluster (DeviceExt, Temp, CurrentCluster);
CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster); Status = GetNextCluster (DeviceExt, CurrentCluster, &CurrentCluster);
} }
TempLength = min (Length, DeviceExt->BytesPerCluster - TempLength = min (Length, DeviceExt->BytesPerCluster -
(ReadOffset % DeviceExt->BytesPerCluster)); (ReadOffset % DeviceExt->BytesPerCluster));
@ -195,7 +204,7 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
else else
{ {
VFATLoadCluster (DeviceExt, Buffer, CurrentCluster); VFATLoadCluster (DeviceExt, Buffer, CurrentCluster);
CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster); Status = GetNextCluster (DeviceExt, CurrentCluster, &CurrentCluster);
} }
if (CurrentCluster == 0xffffffff) if (CurrentCluster == 0xffffffff)
{ {
@ -222,7 +231,7 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
else else
{ {
VFATLoadCluster (DeviceExt, Temp, CurrentCluster); VFATLoadCluster (DeviceExt, Temp, CurrentCluster);
CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster); Status = GetNextCluster (DeviceExt, CurrentCluster, &CurrentCluster);
} }
memcpy (Buffer, Temp, Length); memcpy (Buffer, Temp, Length);
} }
@ -236,24 +245,22 @@ VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
PULONG CurrentCluster, PULONG CurrentCluster,
PVOID Destination) PVOID Destination)
{ {
DPRINT("VfatRawReadCluster() *CurrentCluster 0x%x\n", *CurrentCluster); NTSTATUS Status;
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
/* FIXME: Check status */ Status = VfatReadSectors (DeviceExt->StorageDevice,
VfatReadSectors (DeviceExt->StorageDevice, (*CurrentCluster),
(*CurrentCluster), DeviceExt->Boot->SectorsPerCluster,
DeviceExt->Boot->SectorsPerCluster, Destination);
Destination); return(Status);
(*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster;
} }
else else
{ {
VFATLoadCluster (DeviceExt, Destination, (*CurrentCluster)); VFATLoadCluster (DeviceExt, Destination, (*CurrentCluster));
(*CurrentCluster) = GetNextCluster (DeviceExt, (*CurrentCluster)); Status = STATUS_SUCCESS;
return(Status);
} }
DPRINT("VfatRawReadCluster() finished *CurrentCluster 0x%x\n",
*CurrentCluster);
return(STATUS_SUCCESS);
} }
NTSTATUS NTSTATUS
@ -300,25 +307,17 @@ VfatReadCluster(PDEVICE_EXTENSION DeviceExt,
return(Status); return(Status);
} }
} }
else
{
/*
* Otherwise go on to the next cluster
*/
if (FirstCluster == 1)
{
(*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster;
}
else
{
(*CurrentCluster) = GetNextCluster(DeviceExt, (*CurrentCluster));
}
}
/* /*
* Copy the data from the cache to the caller * Copy the data from the cache to the caller
*/ */
memcpy(Destination, BaseAddress, BytesPerCluster); memcpy(Destination, BaseAddress, BytesPerCluster);
CcReleaseCacheSegment(Fcb->RFCB.Bcb, CacheSeg, TRUE); CcReleaseCacheSegment(Fcb->RFCB.Bcb, CacheSeg, TRUE);
Status = NextCluster(DeviceExt, FirstCluster, CurrentCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
}
} }
else else
{ {
@ -358,7 +357,8 @@ VfatReadCluster(PDEVICE_EXTENSION DeviceExt,
CcReleaseCacheSegment(Fcb->RFCB.Bcb, CacheSeg, FALSE); CcReleaseCacheSegment(Fcb->RFCB.Bcb, CacheSeg, FALSE);
return(Status); return(Status);
} }
if (CurrentCluster == 0xFFFFFFFF) Status = NextCluster(DeviceExt, FirstCluster, CurrentCluster);
if ((*CurrentCluster) == 0xFFFFFFFF)
{ {
break; break;
} }
@ -372,7 +372,7 @@ VfatReadCluster(PDEVICE_EXTENSION DeviceExt,
for (i = 0; i < (PAGESIZE / DeviceExt->BytesPerCluster); i++) for (i = 0; i < (PAGESIZE / DeviceExt->BytesPerCluster); i++)
{ {
NextCluster(DeviceExt, FirstCluster, CurrentCluster); NextCluster(DeviceExt, FirstCluster, CurrentCluster);
if (CurrentCluster == 0xFFFFFFFF) if ((*CurrentCluster) == 0xFFFFFFFF)
{ {
break; break;
} }
@ -396,12 +396,12 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
*/ */
{ {
ULONG CurrentCluster; ULONG CurrentCluster;
ULONG FileOffset;
ULONG FirstCluster; ULONG FirstCluster;
PVFATFCB Fcb; PVFATFCB Fcb;
PVOID Temp; PVOID Temp;
ULONG TempLength; ULONG TempLength;
ULONG ChunkSize; ULONG ChunkSize;
NTSTATUS Status;
/* PRECONDITION */ /* PRECONDITION */
assert (DeviceExt != NULL); assert (DeviceExt != NULL);
@ -450,14 +450,21 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
*/ */
Temp = ExAllocatePool (NonPagedPool, ChunkSize); Temp = ExAllocatePool (NonPagedPool, ChunkSize);
if (!Temp) if (!Temp)
return STATUS_UNSUCCESSFUL; {
return(STATUS_NO_MEMORY);
}
/* /*
* Find the cluster to start the read from * Find the cluster to start the read from
* FIXME: Optimize by remembering the last cluster read and using if * FIXME: Optimize by remembering the last cluster read and using if
* possible. * possible.
*/ */
CurrentCluster = OffsetToCluster(DeviceExt, FirstCluster, ReadOffset); Status = OffsetToCluster(DeviceExt, FirstCluster, ReadOffset,
&CurrentCluster);
if (!NT_SUCCESS(Status))
{
return(Status);
}
/* /*
* If the read doesn't begin on a cluster boundary then read a full * If the read doesn't begin on a cluster boundary then read a full
@ -727,8 +734,8 @@ VfatWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
PVOID Buffer; PVOID Buffer;
ULONG Offset; ULONG Offset;
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation (Irp); PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation (Irp);
PFILE_OBJECT FileObject = Stack->FileObject; /* PFILE_OBJECT FileObject = Stack->FileObject; */
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension; /* PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension; */
NTSTATUS Status; NTSTATUS Status;
DPRINT ("VfatWrite(DeviceObject %x Irp %x)\n", DeviceObject, Irp); DPRINT ("VfatWrite(DeviceObject %x Irp %x)\n", DeviceObject, Irp);

View file

@ -1,4 +1,4 @@
/* $Id: shutdown.c,v 1.1 2000/12/29 13:45:01 ekohl Exp $ /* $Id: shutdown.c,v 1.2 2001/01/12 21:00:08 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -21,9 +21,6 @@
NTSTATUS STDCALL NTSTATUS STDCALL
VfatShutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp) VfatShutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{ {
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
PFILE_OBJECT FileObject = Stack->FileObject;
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
NTSTATUS Status; NTSTATUS Status;
DPRINT("VfatShutdown(DeviceObject %x, Irp %x)\n",DeviceObject, Irp); DPRINT("VfatShutdown(DeviceObject %x, Irp %x)\n",DeviceObject, Irp);

View file

@ -1,4 +1,4 @@
/* $Id: vfat.h,v 1.20 2001/01/08 02:14:06 dwelch Exp $ */ /* $Id: vfat.h,v 1.21 2001/01/12 21:00:08 dwelch Exp $ */
#include <ddk/ntifs.h> #include <ddk/ntifs.h>
@ -88,7 +88,6 @@ typedef struct
int FATEntriesPerSector, FATUnit; int FATEntriesPerSector, FATUnit;
ULONG BytesPerCluster; ULONG BytesPerCluster;
ULONG FatType; ULONG FatType;
unsigned char* FAT;
} DEVICE_EXTENSION, *PDEVICE_EXTENSION; } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
typedef struct _VFATFCB typedef struct _VFATFCB
@ -233,8 +232,10 @@ wstrcmpjoki(PWSTR s1, PWSTR s2);
*/ */
ULONG ULONG
ClusterToSector(PDEVICE_EXTENSION DeviceExt, ULONG Cluster); ClusterToSector(PDEVICE_EXTENSION DeviceExt, ULONG Cluster);
ULONG NTSTATUS
GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster); GetNextCluster(PDEVICE_EXTENSION DeviceExt,
ULONG CurrentCluster,
PULONG NextCluster);
VOID VOID
VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster); VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster);
ULONG ULONG
@ -243,6 +244,9 @@ ULONG
FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt); FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
ULONG ULONG
FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt); FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt);
VOID
WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
ULONG NewValue);
/* /*
* functions from volume.c * functions from volume.c

View file

@ -1,4 +1,4 @@
/* $Id: volume.c,v 1.5 2000/12/29 23:17:12 dwelch Exp $ /* $Id: volume.c,v 1.6 2001/01/12 21:00:08 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -88,8 +88,8 @@ FsdGetFsSizeInformation (PDEVICE_OBJECT DeviceObject,
else else
FsSizeInfo->TotalAllocationUnits.QuadPart = BootSect->SectorsHuge; FsSizeInfo->TotalAllocationUnits.QuadPart = BootSect->SectorsHuge;
FsSizeInfo->AvailableAllocationUnits.QuadPart = /* FsSizeInfo->AvailableAllocationUnits.QuadPart =
FAT32CountAvailableClusters (DeviceExt); FAT32CountAvailableClusters (DeviceExt); */
FsSizeInfo->SectorsPerAllocationUnit = BootSect->SectorsPerCluster; FsSizeInfo->SectorsPerAllocationUnit = BootSect->SectorsPerCluster;
FsSizeInfo->BytesPerSector = BootSect->BytesPerSector; FsSizeInfo->BytesPerSector = BootSect->BytesPerSector;
@ -102,14 +102,14 @@ FsdGetFsSizeInformation (PDEVICE_OBJECT DeviceObject,
FsSizeInfo->TotalAllocationUnits.QuadPart = BootSect->Sectors; FsSizeInfo->TotalAllocationUnits.QuadPart = BootSect->Sectors;
else else
FsSizeInfo->TotalAllocationUnits.QuadPart = BootSect->SectorsHuge; FsSizeInfo->TotalAllocationUnits.QuadPart = BootSect->SectorsHuge;
/*
if (DeviceExt->FatType == FAT16) if (DeviceExt->FatType == FAT16)
FsSizeInfo->AvailableAllocationUnits.QuadPart = FsSizeInfo->AvailableAllocationUnits.QuadPart =
FAT16CountAvailableClusters (DeviceExt); FAT16CountAvailableClusters (DeviceExt);
else else
FsSizeInfo->AvailableAllocationUnits.QuadPart = FsSizeInfo->AvailableAllocationUnits.QuadPart =
FAT12CountAvailableClusters (DeviceExt); FAT12CountAvailableClusters (DeviceExt);
*/
FsSizeInfo->SectorsPerAllocationUnit = BootSect->SectorsPerCluster; FsSizeInfo->SectorsPerAllocationUnit = BootSect->SectorsPerCluster;
FsSizeInfo->BytesPerSector = BootSect->BytesPerSector; FsSizeInfo->BytesPerSector = BootSect->BytesPerSector;
} }

View file

@ -71,6 +71,15 @@ typedef struct
PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES]; PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
} SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY; } SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
typedef struct
{
ULONG FileOffset;
ULONG Protection;
ULONG Attributes;
SECTION_PAGE_DIRECTORY PageDirectory;
KMUTEX Lock;
} MM_SECTION_SEGMENT;
typedef struct typedef struct
{ {
CSHORT Type; CSHORT Type;

View file

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.71 2001/01/06 21:40:13 rex Exp $ /* $Id: main.c,v 1.72 2001/01/12 21:00:07 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -443,11 +443,12 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
sizeof(LOADER_MODULE) * KeLoaderBlock.ModsCount); sizeof(LOADER_MODULE) * KeLoaderBlock.ModsCount);
KeLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules; KeLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules;
/*FIXME: Preliminary hack!!!! Add boot device to beginning of command line. /*
* FIXME: Preliminary hack!!!! Add boot device to beginning of command line.
* This should be done by the boot loader. * This should be done by the boot loader.
*/ */
strcpy (KeLoaderCommandLine, strcpy (KeLoaderCommandLine,
"multi(0)disk(0)rdisk(0)partition(1)\\reactos"); "multi(0)disk(0)rdisk(0)partition(1)\\reactos ");
strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine); strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine);
KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine; KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine;

View file

@ -235,7 +235,6 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
*/ */
RtlInitAnsiString (&ProcedureName, RtlInitAnsiString (&ProcedureName,
"LdrInitializeThunk"); "LdrInitializeThunk");
DPRINT1("Getting address of system DLL entrypoint\n");
Status = LdrGetProcedureAddress ((PVOID)ImageBase, Status = LdrGetProcedureAddress ((PVOID)ImageBase,
&ProcedureName, &ProcedureName,
0, 0,
@ -248,8 +247,6 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
ZwClose(NTDllSectionHandle); ZwClose(NTDllSectionHandle);
return (Status); return (Status);
} }
DPRINT1("SystemDllEntryPoint 0x%08lx\n",
SystemDllEntryPoint);
*LdrStartupAddr = SystemDllEntryPoint; *LdrStartupAddr = SystemDllEntryPoint;
/* /*