mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Fix bug in MmAllocateContinuousPages spotted by Philip Susi
Fixed compilation bugs in roshttpd Work on write support (still not working) svn path=/trunk/; revision=1524
This commit is contained in:
parent
7887cc9965
commit
25dc208536
18 changed files with 1027 additions and 576 deletions
|
@ -61,7 +61,7 @@ APPS = args hello test cat bench apc shm lpc thread event file gditest \
|
||||||
# objdir
|
# objdir
|
||||||
|
|
||||||
#NET_APPS = ping roshttpd
|
#NET_APPS = ping roshttpd
|
||||||
NET_APPS = ping roshttpd
|
NET_APPS = ping
|
||||||
|
|
||||||
|
|
||||||
KERNEL_SERVICES = $(DEVICE_DRIVERS) $(INPUT_DRIVERS) $(FS_DRIVERS) $(NET_DRIVERS) $(NET_DEVICE_DRIVERS)
|
KERNEL_SERVICES = $(DEVICE_DRIVERS) $(INPUT_DRIVERS) $(FS_DRIVERS) $(NET_DRIVERS) $(NET_DEVICE_DRIVERS)
|
||||||
|
|
|
@ -34,7 +34,7 @@ CListNode::CListNode(PVOID element, CListNode *next, CListNode *prev)
|
||||||
Prev = prev;
|
Prev = prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID CListNode::operator new(/*size_t*/ UINT size)
|
void* CListNode::operator new(/*size_t*/ UINT size)
|
||||||
{
|
{
|
||||||
PVOID p;
|
PVOID p;
|
||||||
if (hHeap == NULL) {
|
if (hHeap == NULL) {
|
||||||
|
@ -47,7 +47,7 @@ PVOID CListNode::operator new(/*size_t*/ UINT size)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID CListNode::operator delete(PVOID p)
|
VOID CListNode::operator delete(void* p)
|
||||||
{
|
{
|
||||||
if (HeapFree(hHeap, 0, p) != FALSE)
|
if (HeapFree(hHeap, 0, p) != FALSE)
|
||||||
nRef--;
|
nRef--;
|
||||||
|
|
|
@ -162,11 +162,12 @@ VOID CHttpClient::SendFile(LPSTR lpsFilename)
|
||||||
CHAR str[255];
|
CHAR str[255];
|
||||||
CHAR str2[32];
|
CHAR str2[32];
|
||||||
union BigNum {
|
union BigNum {
|
||||||
unsigned __int64 Big;
|
// unsigned __int64 Big;
|
||||||
|
unsigned long long Big;
|
||||||
struct {
|
struct {
|
||||||
DWORD Low;
|
DWORD Low;
|
||||||
DWORD High;
|
DWORD High;
|
||||||
};
|
} u;
|
||||||
} nTotalBytes;
|
} nTotalBytes;
|
||||||
DWORD nBytesToRead;
|
DWORD nBytesToRead;
|
||||||
DWORD nBytesRead;
|
DWORD nBytesRead;
|
||||||
|
@ -186,8 +187,8 @@ VOID CHttpClient::SendFile(LPSTR lpsFilename)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get file size
|
// Get file size
|
||||||
nTotalBytes.Low = GetFileSize(hFile, &nTotalBytes.High);
|
nTotalBytes.u.Low = GetFileSize(hFile, &nTotalBytes.u.High);
|
||||||
if ((nTotalBytes.Low == 0xFFFFFFFF) && ((GetLastError()) != NO_ERROR)) {
|
if ((nTotalBytes.u.Low == 0xFFFFFFFF) && ((GetLastError()) != NO_ERROR)) {
|
||||||
// Internal server error
|
// Internal server error
|
||||||
Report("500 Internal Server Error", HttpMsg500);
|
Report("500 Internal Server Error", HttpMsg500);
|
||||||
// Close file
|
// Close file
|
||||||
|
@ -217,7 +218,7 @@ VOID CHttpClient::SendFile(LPSTR lpsFilename)
|
||||||
SendText("Content-Type: text/plain");
|
SendText("Content-Type: text/plain");
|
||||||
SendText("Accept-Ranges: bytes");
|
SendText("Accept-Ranges: bytes");
|
||||||
strcpy(str, "Content-Length: ");
|
strcpy(str, "Content-Length: ");
|
||||||
_itoa(nTotalBytes.Low, str2, 10);
|
_itoa(nTotalBytes.u.Low, str2, 10);
|
||||||
strcat(str, str2);
|
strcat(str, str2);
|
||||||
SendText(str);
|
SendText(str);
|
||||||
SendText("");
|
SendText("");
|
||||||
|
|
|
@ -42,8 +42,10 @@ private:
|
||||||
BOOL bStop;
|
BOOL bStop;
|
||||||
LPSTR lpsBuffer;
|
LPSTR lpsBuffer;
|
||||||
LONG nBufferSize;
|
LONG nBufferSize;
|
||||||
unsigned __int64 nTotalRead;
|
// unsigned __int64 nTotalRead;
|
||||||
unsigned __int64 nFileSize;
|
unsigned long long nTotalRead;
|
||||||
|
// unsigned __int64 nFileSize;
|
||||||
|
unsigned long long nFileSize;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
};
|
};
|
||||||
typedef CHttpClient* LPCHttpClient;
|
typedef CHttpClient* LPCHttpClient;
|
||||||
|
|
|
@ -14,8 +14,8 @@ public:
|
||||||
CListNode();
|
CListNode();
|
||||||
CListNode(VOID *element, CListNode *next, CListNode *prev);
|
CListNode(VOID *element, CListNode *next, CListNode *prev);
|
||||||
~CListNode() {};
|
~CListNode() {};
|
||||||
PVOID operator new(/*size_t s*/ UINT s);
|
void* operator new(/*size_t s*/ UINT s);
|
||||||
VOID operator delete(PVOID p);
|
VOID operator delete(void* p);
|
||||||
|
|
||||||
VOID SetElement(PVOID element);
|
VOID SetElement(PVOID element);
|
||||||
VOID SetNext(CListNode *next);
|
VOID SetNext(CListNode *next);
|
||||||
|
|
|
@ -13,7 +13,8 @@ COMMON_OBJECTS = common/list.o common/socket.o common/thread.o
|
||||||
OBJECTS = $(MAIN_OBJECTS) $(COMMON_OBJECTS)
|
OBJECTS = $(MAIN_OBJECTS) $(COMMON_OBJECTS)
|
||||||
PROGS = $(TARGETNAME).exe
|
PROGS = $(TARGETNAME).exe
|
||||||
LIBS = ../../../lib/kernel32/kernel32.a \
|
LIBS = ../../../lib/kernel32/kernel32.a \
|
||||||
../../../lib/ws2_32/ws2_32.a
|
../../../lib/ws2_32/ws2_32.a \
|
||||||
|
../../../lib/user32/user32.a
|
||||||
|
|
||||||
ifeq ($(DOSCLI), yes)
|
ifeq ($(DOSCLI), yes)
|
||||||
CLEAN_FILES = *.o $(TARGETNAME).exe $(TARGETNAME).sym common\*.o
|
CLEAN_FILES = *.o $(TARGETNAME).exe $(TARGETNAME).sym common\*.o
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: services/fs/vfat/blockdev.c
|
* FILE: services/fs/vfat/blockdev.c
|
||||||
* PURPOSE: Temporary sector reading support
|
* PURPOSE: Temporary sector reading support
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ VfatWriteSectors (IN PDEVICE_OBJECT pDeviceObject,
|
||||||
|
|
||||||
if (!NT_SUCCESS (Status))
|
if (!NT_SUCCESS (Status))
|
||||||
{
|
{
|
||||||
DPRINT ("IO failed!!! VFATWriteSectors : Error code: %x\n", Status);
|
DPRINT1 ("IO failed!!! VFATWriteSectors : Error code: %x\n", Status);
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: close.c,v 1.3 2000/12/29 23:17:12 dwelch Exp $
|
/* $Id: close.c,v 1.4 2001/01/16 09:55:02 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -28,7 +28,7 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
||||||
PVFATCCB pCcb;
|
PVFATCCB pCcb;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
|
|
||||||
DPRINT ("FsdCloseFile(DeviceExt %x, FileObject %x)\n",
|
DPRINT ("VfatCloseFile(DeviceExt %x, FileObject %x)\n",
|
||||||
DeviceExt, FileObject);
|
DeviceExt, FileObject);
|
||||||
|
|
||||||
//FIXME : update entry in directory ?
|
//FIXME : update entry in directory ?
|
||||||
|
@ -65,7 +65,7 @@ VfatClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT ("FsdClose(DeviceObject %x, Irp %x)\n", DeviceObject, Irp);
|
DPRINT ("VfatClose(DeviceObject %x, Irp %x)\n", DeviceObject, Irp);
|
||||||
|
|
||||||
Status = VfatCloseFile (DeviceExtension, FileObject);
|
Status = VfatCloseFile (DeviceExtension, FileObject);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.13 2001/01/12 21:00:08 dwelch Exp $
|
/* $Id: create.c,v 1.14 2001/01/16 09:55:02 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -150,7 +150,7 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
|
||||||
ULONG NextCluster;
|
ULONG NextCluster;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Size = DeviceExt->rootDirectorySectors; //FIXME : in fat32, no limit
|
Size = DeviceExt->rootDirectorySectors; /* FIXME : in fat32, no limit */
|
||||||
StartingSector = DeviceExt->rootStart;
|
StartingSector = DeviceExt->rootStart;
|
||||||
NextCluster = 0;
|
NextCluster = 0;
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
|
||||||
return (STATUS_UNSUCCESSFUL);
|
return (STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not found in this sector, try next :
|
/* not found in this sector, try next : */
|
||||||
|
|
||||||
/* directory can be fragmented although it is best to keep them
|
/* directory can be fragmented although it is best to keep them
|
||||||
unfragmented */
|
unfragmented */
|
||||||
|
@ -192,7 +192,8 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb)
|
||||||
{
|
{
|
||||||
if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1))
|
if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1))
|
||||||
{
|
{
|
||||||
Status = GetNextCluster (DeviceExt, NextCluster, &NextCluster);
|
Status = GetNextCluster (DeviceExt, NextCluster, &NextCluster,
|
||||||
|
FALSE);
|
||||||
if (NextCluster == 0 || NextCluster == 0xffffffff)
|
if (NextCluster == 0 || NextCluster == 0xffffffff)
|
||||||
{
|
{
|
||||||
*(Vpb->VolumeLabel) = 0;
|
*(Vpb->VolumeLabel) = 0;
|
||||||
|
@ -235,17 +236,11 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
TempStr[0] = (WCHAR) '.';
|
TempStr[0] = (WCHAR) '.';
|
||||||
TempStr[1] = 0;
|
TempStr[1] = 0;
|
||||||
FileToFind = (PWSTR) & TempStr;
|
FileToFind = (PWSTR)&TempStr;
|
||||||
}
|
|
||||||
if (Parent != NULL)
|
|
||||||
{
|
|
||||||
DPRINT ("Parent->entry.FirstCluster %d\n", Parent->entry.FirstCluster);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT ("FindFile '%S'\n", FileToFind);
|
|
||||||
if (Parent == NULL || Parent->entry.FirstCluster == 1)
|
if (Parent == NULL || Parent->entry.FirstCluster == 1)
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
|
||||||
Size = DeviceExt->rootDirectorySectors; /* FIXME : in fat32, no limit */
|
Size = DeviceExt->rootDirectorySectors; /* FIXME : in fat32, no limit */
|
||||||
StartingSector = DeviceExt->rootStart;
|
StartingSector = DeviceExt->rootStart;
|
||||||
NextCluster = 0;
|
NextCluster = 0;
|
||||||
|
@ -253,7 +248,6 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||||
|| (FileToFind[0] == '.' && FileToFind[1] == 0))
|
|| (FileToFind[0] == '.' && FileToFind[1] == 0))
|
||||||
{
|
{
|
||||||
/* it's root : complete essentials fields then return ok */
|
/* it's root : complete essentials fields then return ok */
|
||||||
CHECKPOINT;
|
|
||||||
memset (Fcb, 0, sizeof (VFATFCB));
|
memset (Fcb, 0, sizeof (VFATFCB));
|
||||||
memset (Fcb->entry.Filename, ' ', 11);
|
memset (Fcb->entry.Filename, ' ', 11);
|
||||||
Fcb->entry.FileSize = DeviceExt->rootDirectorySectors * BLOCKSIZE;
|
Fcb->entry.FileSize = DeviceExt->rootDirectorySectors * BLOCKSIZE;
|
||||||
|
@ -261,7 +255,7 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||||
if (DeviceExt->FatType == FAT32)
|
if (DeviceExt->FatType == FAT32)
|
||||||
Fcb->entry.FirstCluster = 2;
|
Fcb->entry.FirstCluster = 2;
|
||||||
else
|
else
|
||||||
Fcb->entry.FirstCluster = 1; /* FIXME : is 1 the good value for mark root? */
|
Fcb->entry.FirstCluster = 1;
|
||||||
if (StartSector)
|
if (StartSector)
|
||||||
*StartSector = StartingSector;
|
*StartSector = StartingSector;
|
||||||
if (Entry)
|
if (Entry)
|
||||||
|
@ -286,13 +280,10 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||||
StartingSector = DeviceExt->rootStart;
|
StartingSector = DeviceExt->rootStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
|
||||||
block = ExAllocatePool (NonPagedPool, BLOCKSIZE);
|
block = ExAllocatePool (NonPagedPool, BLOCKSIZE);
|
||||||
CHECKPOINT;
|
|
||||||
if (StartSector && (*StartSector))
|
if (StartSector && (*StartSector))
|
||||||
StartingSector = *StartSector;
|
StartingSector = *StartSector;
|
||||||
i = (Entry) ? (*Entry) : 0;
|
i = (Entry) ? (*Entry) : 0;
|
||||||
DPRINT ("FindFile : start at sector %lx, entry %ld\n", StartingSector, i);
|
|
||||||
for (j = 0; j < Size; j++)
|
for (j = 0; j < Size; j++)
|
||||||
{
|
{
|
||||||
/* FIXME: Check status */
|
/* FIXME: Check status */
|
||||||
|
@ -316,8 +307,8 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||||
{
|
{
|
||||||
if (wstrcmpjoki (name, FileToFind))
|
if (wstrcmpjoki (name, FileToFind))
|
||||||
{
|
{
|
||||||
/* In the case of a long filename, the firstcluster is stored in
|
/* In the case of a long filename, the firstcluster is
|
||||||
the next record -- where it's short name is */
|
stored in the next record -- where it's short name is */
|
||||||
if (((FATDirEntry *) block)[i].Attrib == 0x0f)
|
if (((FATDirEntry *) block)[i].Attrib == 0x0f)
|
||||||
i++;
|
i++;
|
||||||
if (i == (ENTRIES_PER_SECTOR))
|
if (i == (ENTRIES_PER_SECTOR))
|
||||||
|
@ -354,7 +345,8 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||||
{
|
{
|
||||||
if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1))
|
if (StartingSector == ClusterToSector (DeviceExt, NextCluster + 1))
|
||||||
{
|
{
|
||||||
Status = GetNextCluster (DeviceExt, NextCluster, &NextCluster);
|
Status = GetNextCluster (DeviceExt, NextCluster, &NextCluster,
|
||||||
|
FALSE);
|
||||||
if (NextCluster == 0 || NextCluster == 0xffffffff)
|
if (NextCluster == 0 || NextCluster == 0xffffffff)
|
||||||
{
|
{
|
||||||
if (StartSector)
|
if (StartSector)
|
||||||
|
@ -379,7 +371,7 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb,
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
FsdOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
PWSTR FileName)
|
PWSTR FileName)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Opens a file
|
* FUNCTION: Opens a file
|
||||||
|
@ -400,7 +392,7 @@ FsdOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
ULONG BytesPerCluster;
|
ULONG BytesPerCluster;
|
||||||
|
|
||||||
DPRINT ("FsdOpenFile(%08lx, %08lx, %S)\n", DeviceExt, FileObject, FileName);
|
DPRINT ("VfatOpenFile(%08lx, %08lx, %S)\n", DeviceExt, FileObject, FileName);
|
||||||
|
|
||||||
/* FIXME : treat relative name */
|
/* FIXME : treat relative name */
|
||||||
if (FileObject->RelatedFileObject)
|
if (FileObject->RelatedFileObject)
|
||||||
|
@ -641,9 +633,12 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
DeviceExt = DeviceObject->DeviceExtension;
|
DeviceExt = DeviceObject->DeviceExtension;
|
||||||
assert (DeviceExt);
|
assert (DeviceExt);
|
||||||
|
|
||||||
Status = FsdOpenFile (DeviceExt, FileObject, FileObject->FileName.Buffer);
|
Status = VfatOpenFile (DeviceExt, FileObject, FileObject->FileName.Buffer);
|
||||||
|
|
||||||
CHECKPOINT;
|
/*
|
||||||
|
* If the directory containing the file to open doesn't exist then
|
||||||
|
* fail immediately
|
||||||
|
*/
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
if (Status == STATUS_OBJECT_PATH_NOT_FOUND)
|
if (Status == STATUS_OBJECT_PATH_NOT_FOUND)
|
||||||
{
|
{
|
||||||
|
@ -651,23 +646,21 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECKPOINT;
|
|
||||||
if (!NT_SUCCESS (Status))
|
if (!NT_SUCCESS (Status))
|
||||||
{
|
{
|
||||||
if (RequestedDisposition == FILE_CREATE
|
/*
|
||||||
|| RequestedDisposition == FILE_OPEN_IF
|
* If the file open failed then create the required file
|
||||||
|| RequestedDisposition == FILE_OVERWRITE_IF
|
*/
|
||||||
|| RequestedDisposition == FILE_SUPERSEDE)
|
if (RequestedDisposition == FILE_CREATE ||
|
||||||
|
RequestedDisposition == FILE_OPEN_IF ||
|
||||||
|
RequestedDisposition == FILE_OVERWRITE_IF ||
|
||||||
|
RequestedDisposition == FILE_SUPERSEDE)
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
#if 0
|
Status =
|
||||||
Status =
|
|
||||||
addEntry (DeviceExt, FileObject, RequestedOptions,
|
addEntry (DeviceExt, FileObject, RequestedOptions,
|
||||||
(Stack->Parameters.
|
(Stack->Parameters.
|
||||||
Create.FileAttributes & FILE_ATTRIBUTE_VALID_FLAGS));
|
Create.FileAttributes & FILE_ATTRIBUTE_VALID_FLAGS));
|
||||||
#else
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
|
||||||
#endif
|
|
||||||
if (NT_SUCCESS (Status))
|
if (NT_SUCCESS (Status))
|
||||||
Irp->IoStatus.Information = FILE_CREATED;
|
Irp->IoStatus.Information = FILE_CREATED;
|
||||||
/* FIXME set size if AllocationSize requested */
|
/* FIXME set size if AllocationSize requested */
|
||||||
|
@ -680,13 +673,20 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Otherwise fail if the caller wanted to create a new file
|
||||||
|
*/
|
||||||
if (RequestedDisposition == FILE_CREATE)
|
if (RequestedDisposition == FILE_CREATE)
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Information = FILE_EXISTS;
|
Irp->IoStatus.Information = FILE_EXISTS;
|
||||||
Status = STATUS_OBJECT_NAME_COLLISION;
|
Status = STATUS_OBJECT_NAME_COLLISION;
|
||||||
}
|
}
|
||||||
pCcb = FileObject->FsContext2;
|
pCcb = FileObject->FsContext2;
|
||||||
pFcb = pCcb->pFcb;
|
pFcb = pCcb->pFcb;
|
||||||
|
/*
|
||||||
|
* If requested then delete the file and create a new one with the
|
||||||
|
* same name
|
||||||
|
*/
|
||||||
if (RequestedDisposition == FILE_SUPERSEDE)
|
if (RequestedDisposition == FILE_SUPERSEDE)
|
||||||
{
|
{
|
||||||
ULONG Cluster, NextCluster;
|
ULONG Cluster, NextCluster;
|
||||||
|
@ -699,14 +699,18 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
Cluster = pFcb->entry.FirstCluster;
|
Cluster = pFcb->entry.FirstCluster;
|
||||||
pFcb->entry.FirstCluster = 0;
|
pFcb->entry.FirstCluster = 0;
|
||||||
pFcb->entry.FirstClusterHigh = 0;
|
pFcb->entry.FirstClusterHigh = 0;
|
||||||
// updEntry (DeviceExt, FileObject);
|
updEntry (DeviceExt, FileObject);
|
||||||
while (Cluster != 0xffffffff && Cluster > 1)
|
while (Cluster != 0xffffffff && Cluster > 1)
|
||||||
{
|
{
|
||||||
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster);
|
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, TRUE);
|
||||||
// WriteCluster (DeviceExt, Cluster, 0);
|
// WriteCluster (DeviceExt, Cluster, 0);
|
||||||
Cluster = NextCluster;
|
Cluster = NextCluster;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check the file has the requested attributes
|
||||||
|
*/
|
||||||
if ((RequestedOptions & FILE_NON_DIRECTORY_FILE)
|
if ((RequestedOptions & FILE_NON_DIRECTORY_FILE)
|
||||||
&& (pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
|
&& (pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: dirwr.c,v 1.15 2001/01/01 04:42:11 dwelch Exp $
|
/* $Id: dirwr.c,v 1.16 2001/01/16 09:55:02 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "vfat.h"
|
#include "vfat.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
/*
|
||||||
* Copies a file name into a directory slot (long file name entry)
|
* Copies a file name into a directory slot (long file name entry)
|
||||||
* and fills trailing slot space with 0xFFFF. This keeps scandisk
|
* and fills trailing slot space with 0xFFFF. This keeps scandisk
|
||||||
|
@ -127,7 +126,7 @@ NTSTATUS updEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
|
||||||
memset (&FileObject, 0, sizeof (FILE_OBJECT));
|
memset (&FileObject, 0, sizeof (FILE_OBJECT));
|
||||||
DPRINT ("open directory \'%S\' for update of entry \'%S\'\n", DirName,
|
DPRINT ("open directory \'%S\' for update of entry \'%S\'\n", DirName,
|
||||||
FileName);
|
FileName);
|
||||||
status = FsdOpenFile (DeviceExt, &FileObject, DirName);
|
status = VfatOpenFile (DeviceExt, &FileObject, DirName);
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
DbgPrint ("Failed to open \'%S\'. Status %lx\n", DirName, status);
|
DbgPrint ("Failed to open \'%S\'. Status %lx\n", DirName, status);
|
||||||
|
@ -143,10 +142,10 @@ NTSTATUS updEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
|
||||||
{
|
{
|
||||||
Buffer = ExAllocatePool (NonPagedPool, BLOCKSIZE);
|
Buffer = ExAllocatePool (NonPagedPool, BLOCKSIZE);
|
||||||
DPRINT ("update entry: sector %d, entry %d\n", Sector, Entry);
|
DPRINT ("update entry: sector %d, entry %d\n", Sector, Entry);
|
||||||
VFATReadSectors (DeviceExt->StorageDevice, Sector, 1, Buffer);
|
VfatReadSectors (DeviceExt->StorageDevice, Sector, 1, Buffer);
|
||||||
pEntries = (FATDirEntry *) Buffer;
|
pEntries = (FATDirEntry *) Buffer;
|
||||||
memcpy (&pEntries[Entry], &pFcb->entry, sizeof (FATDirEntry));
|
memcpy (&pEntries[Entry], &pFcb->entry, sizeof (FATDirEntry));
|
||||||
VFATWriteSectors (DeviceExt->StorageDevice, Sector, 1, Buffer);
|
VfatWriteSectors (DeviceExt->StorageDevice, Sector, 1, Buffer);
|
||||||
ExFreePool (Buffer);
|
ExFreePool (Buffer);
|
||||||
}
|
}
|
||||||
VfatCloseFile (DeviceExt, &FileObject);
|
VfatCloseFile (DeviceExt, &FileObject);
|
||||||
|
@ -177,6 +176,8 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG CurrentCluster;
|
ULONG CurrentCluster;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
LARGE_INTEGER SystemTime, LocalTime;
|
LARGE_INTEGER SystemTime, LocalTime;
|
||||||
|
ULONG BytesPerCluster;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
PathFileName = pFileObject->FileName.Buffer;
|
PathFileName = pFileObject->FileName.Buffer;
|
||||||
DPRINT ("addEntry: Pathname=%S\n", PathFileName);
|
DPRINT ("addEntry: Pathname=%S\n", PathFileName);
|
||||||
|
@ -194,7 +195,7 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
DirName[posCar] = 0;
|
DirName[posCar] = 0;
|
||||||
// open parent directory
|
// open parent directory
|
||||||
memset (&FileObject, 0, sizeof (FILE_OBJECT));
|
memset (&FileObject, 0, sizeof (FILE_OBJECT));
|
||||||
status = FsdOpenFile (DeviceExt, &FileObject, DirName);
|
status = VfatOpenFile (DeviceExt, &FileObject, DirName);
|
||||||
nbSlots = (NameLen + 12) / 13 + 1; //nb of entry needed for long name+normal entry
|
nbSlots = (NameLen + 12) / 13 + 1; //nb of entry needed for long name+normal entry
|
||||||
DPRINT ("NameLen= %d, nbSlots =%d\n", NameLen, nbSlots);
|
DPRINT ("NameLen= %d, nbSlots =%d\n", NameLen, nbSlots);
|
||||||
Buffer =
|
Buffer =
|
||||||
|
@ -356,7 +357,7 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
{
|
{
|
||||||
status =
|
status =
|
||||||
VfatReadFile (DeviceExt, &FileObject, &FatEntry, sizeof (FATDirEntry),
|
VfatReadFile (DeviceExt, &FileObject, &FatEntry, sizeof (FATDirEntry),
|
||||||
i * sizeof (FATDirEntry), &LengthRead);
|
i * sizeof (FATDirEntry), &LengthRead, FALSE);
|
||||||
if (status == STATUS_END_OF_FILE)
|
if (status == STATUS_END_OF_FILE)
|
||||||
break;
|
break;
|
||||||
if (!NT_SUCCESS (status))
|
if (!NT_SUCCESS (status))
|
||||||
|
@ -381,11 +382,11 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
|
|
||||||
if (RequestedOptions & FILE_DIRECTORY_FILE)
|
if (RequestedOptions & FILE_DIRECTORY_FILE)
|
||||||
{
|
{
|
||||||
CurrentCluster = GetNextWriteCluster (DeviceExt, 0);
|
NextCluster (DeviceExt, 0, &CurrentCluster, TRUE);
|
||||||
// zero the cluster
|
// zero the cluster
|
||||||
Buffer2 = ExAllocatePool (NonPagedPool, DeviceExt->BytesPerCluster);
|
Buffer2 = ExAllocatePool (NonPagedPool, DeviceExt->BytesPerCluster);
|
||||||
memset (Buffer2, 0, DeviceExt->BytesPerCluster);
|
memset (Buffer2, 0, DeviceExt->BytesPerCluster);
|
||||||
VFATWriteCluster (DeviceExt, Buffer2, CurrentCluster);
|
VfatRawWriteCluster (DeviceExt, 0, Buffer2, CurrentCluster);
|
||||||
ExFreePool (Buffer2);
|
ExFreePool (Buffer2);
|
||||||
if (DeviceExt->FatType == FAT32)
|
if (DeviceExt->FatType == FAT32)
|
||||||
{
|
{
|
||||||
|
@ -400,7 +401,7 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
Offset = (i - nbSlots + 1) * sizeof (FATDirEntry);
|
Offset = (i - nbSlots + 1) * sizeof (FATDirEntry);
|
||||||
status =
|
status =
|
||||||
VfatWriteFile (DeviceExt, &FileObject, Buffer,
|
VfatWriteFile (DeviceExt, &FileObject, Buffer,
|
||||||
sizeof (FATDirEntry) * nbSlots, Offset);
|
sizeof (FATDirEntry) * nbSlots, Offset, FALSE);
|
||||||
DPRINT ("VfatWriteFile() returned: %x\n", status);
|
DPRINT ("VfatWriteFile() returned: %x\n", status);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -408,7 +409,7 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
Offset = (i - nbFree) * sizeof (FATDirEntry);
|
Offset = (i - nbFree) * sizeof (FATDirEntry);
|
||||||
status =
|
status =
|
||||||
VfatWriteFile (DeviceExt, &FileObject, Buffer,
|
VfatWriteFile (DeviceExt, &FileObject, Buffer,
|
||||||
sizeof (FATDirEntry) * (nbSlots + 1), Offset);
|
sizeof (FATDirEntry) * (nbSlots + 1), Offset, FALSE);
|
||||||
}
|
}
|
||||||
DPRINT ("write entry offset %d status=%x\n", Offset, status);
|
DPRINT ("write entry offset %d status=%x\n", Offset, status);
|
||||||
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
|
||||||
|
@ -418,6 +419,18 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
newCCB->pFcb = newFCB;
|
newCCB->pFcb = newFCB;
|
||||||
newCCB->PtrFileObject = pFileObject;
|
newCCB->PtrFileObject = pFileObject;
|
||||||
newFCB->RefCount++;
|
newFCB->RefCount++;
|
||||||
|
|
||||||
|
BytesPerCluster = DeviceExt->Boot->SectorsPerCluster * BLOCKSIZE;
|
||||||
|
if (BytesPerCluster >= PAGESIZE)
|
||||||
|
{
|
||||||
|
Status = CcInitializeFileCache(pFileObject, &newFCB->RFCB.Bcb,
|
||||||
|
BytesPerCluster);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = CcInitializeFileCache(pFileObject, &newFCB->RFCB.Bcb,
|
||||||
|
PAGESIZE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME : initialize all fields in FCB and CCB
|
* FIXME : initialize all fields in FCB and CCB
|
||||||
|
@ -441,7 +454,7 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
memcpy (pEntry->Filename, ". ", 11);
|
memcpy (pEntry->Filename, ". ", 11);
|
||||||
status =
|
status =
|
||||||
VfatWriteFile (DeviceExt, pFileObject, pEntry, sizeof (FATDirEntry),
|
VfatWriteFile (DeviceExt, pFileObject, pEntry, sizeof (FATDirEntry),
|
||||||
0L);
|
0L, FALSE);
|
||||||
pEntry->FirstCluster =
|
pEntry->FirstCluster =
|
||||||
((VFATCCB *) (FileObject.FsContext2))->pFcb->entry.FirstCluster;
|
((VFATCCB *) (FileObject.FsContext2))->pFcb->entry.FirstCluster;
|
||||||
pEntry->FirstClusterHigh =
|
pEntry->FirstClusterHigh =
|
||||||
|
@ -451,13 +464,12 @@ addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||||
pEntry->FirstCluster = 0;
|
pEntry->FirstCluster = 0;
|
||||||
status =
|
status =
|
||||||
VfatWriteFile (DeviceExt, pFileObject, pEntry, sizeof (FATDirEntry),
|
VfatWriteFile (DeviceExt, pFileObject, pEntry, sizeof (FATDirEntry),
|
||||||
sizeof (FATDirEntry));
|
sizeof (FATDirEntry), FALSE);
|
||||||
}
|
}
|
||||||
VfatCloseFile (DeviceExt, &FileObject);
|
VfatCloseFile (DeviceExt, &FileObject);
|
||||||
ExFreePool (Buffer);
|
ExFreePool (Buffer);
|
||||||
DPRINT ("addentry ok\n");
|
DPRINT ("addentry ok\n");
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Id: fat.c,v 1.13 2001/01/14 15:05:53 dwelch Exp $
|
* $Id: fat.c,v 1.14 2001/01/16 09:55:02 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -109,24 +109,21 @@ Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
* FUNCTION: Retrieve the next FAT12 cluster from the FAT table
|
* FUNCTION: Retrieve the next FAT12 cluster from the FAT table
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ULONG FATOffset;
|
unsigned char* CBlock;
|
||||||
ULONG Entry;
|
ULONG FATOffset;
|
||||||
NTSTATUS Status;
|
ULONG Entry;
|
||||||
PVOID BaseAddress;
|
BOOLEAN Valid;
|
||||||
BOOLEAN Valid;
|
PCACHE_SEGMENT CacheSeg;
|
||||||
PCACHE_SEGMENT CacheSeg;
|
NTSTATUS Status;
|
||||||
UCHAR Value1, Value2;
|
PVOID BaseAddress;
|
||||||
|
|
||||||
FATOffset = (DeviceExt->FATStart * BLOCKSIZE) + ((CurrentCluster * 12) / 8);
|
*NextCluster = 0;
|
||||||
|
|
||||||
/*
|
Status = CcRequestCacheSegment(DeviceExt->Fat12StorageBcb,
|
||||||
* Get the page containing this offset
|
0,
|
||||||
*/
|
&BaseAddress,
|
||||||
Status = CcRequestCacheSegment(DeviceExt->StorageBcb,
|
&Valid,
|
||||||
PAGE_ROUND_DOWN(FATOffset),
|
&CacheSeg);
|
||||||
&BaseAddress,
|
|
||||||
&Valid,
|
|
||||||
&CacheSeg);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
|
@ -134,106 +131,35 @@ Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
if (!Valid)
|
if (!Valid)
|
||||||
{
|
{
|
||||||
Status = VfatReadSectors(DeviceExt->StorageDevice,
|
Status = VfatReadSectors(DeviceExt->StorageDevice,
|
||||||
PAGE_ROUND_DOWN(FATOffset) / BLOCKSIZE,
|
DeviceExt->FATStart,
|
||||||
PAGESIZE / BLOCKSIZE,
|
DeviceExt->Boot->FATSectors,
|
||||||
BaseAddress);
|
BaseAddress);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
|
CcReleaseCacheSegment(DeviceExt->Fat12StorageBcb, CacheSeg, FALSE);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Value1 = ((PUCHAR)BaseAddress)[FATOffset % PAGESIZE];
|
CBlock = (PUCHAR)BaseAddress;
|
||||||
|
|
||||||
/*
|
FATOffset = (CurrentCluster * 12) / 8; /* first byte containing value */
|
||||||
* A FAT12 entry may straggle two sectors
|
|
||||||
*/
|
|
||||||
if ((FATOffset + 1) == PAGESIZE)
|
|
||||||
{
|
|
||||||
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
|
||||||
Status = CcRequestCacheSegment(DeviceExt->StorageBcb,
|
|
||||||
PAGE_ROUND_DOWN(FATOffset) + PAGESIZE,
|
|
||||||
&BaseAddress,
|
|
||||||
&Valid,
|
|
||||||
&CacheSeg);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
if (!Valid)
|
|
||||||
{
|
|
||||||
ULONG NextOffset;
|
|
||||||
|
|
||||||
NextOffset = (PAGE_ROUND_DOWN(FATOffset) + PAGESIZE) / BLOCKSIZE;
|
|
||||||
Status =
|
|
||||||
VfatReadSectors(DeviceExt->StorageDevice,
|
|
||||||
NextOffset,
|
|
||||||
PAGESIZE / BLOCKSIZE,
|
|
||||||
BaseAddress);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Value2 = ((PUCHAR)BaseAddress)[0];
|
|
||||||
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Value2 = ((PUCHAR)BaseAddress)[(FATOffset % PAGESIZE) + 1];
|
|
||||||
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((CurrentCluster % 2) == 0)
|
if ((CurrentCluster % 2) == 0)
|
||||||
{
|
{
|
||||||
Entry = Value1;
|
Entry = CBlock[FATOffset];
|
||||||
Entry |= ((Value2 & 0xf) << 8);
|
Entry |= ((CBlock[FATOffset+1] & 0xf)<<8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Entry = (Value1 >> 4);
|
Entry = (CBlock[FATOffset] >> 4);
|
||||||
Entry |= (Value2 << 4);
|
Entry |= (CBlock[FATOffset+1] << 4);
|
||||||
}
|
}
|
||||||
DPRINT ("Entry %x\n", Entry);
|
DPRINT("Entry %x\n",Entry);
|
||||||
if (Entry >= 0xff8 && Entry <= 0xfff)
|
if (Entry >= 0xff8 && Entry <= 0xfff)
|
||||||
Entry = 0xffffffff;
|
Entry = 0xffffffff;
|
||||||
DPRINT ("Returning %x\n", Entry);
|
DPRINT("Returning %x\n",Entry);
|
||||||
*NextCluster = Entry;
|
*NextCluster = Entry;
|
||||||
return (STATUS_SUCCESS);
|
CcReleaseCacheSegment(DeviceExt->Fat12StorageBcb, CacheSeg, TRUE);
|
||||||
}
|
return(STATUS_SUCCESS);
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
|
||||||
ULONG CurrentCluster,
|
|
||||||
PULONG NextCluster)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Retrieve the next cluster depending on the FAT type
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
|
|
||||||
DeviceExt, CurrentCluster);
|
|
||||||
|
|
||||||
ExAcquireResourceSharedLite (&DeviceExt->FatResource, TRUE);
|
|
||||||
|
|
||||||
if (DeviceExt->FatType == FAT16)
|
|
||||||
{
|
|
||||||
Status = Fat16GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
|
|
||||||
}
|
|
||||||
else if (DeviceExt->FatType == FAT32)
|
|
||||||
{
|
|
||||||
Status = Fat32GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = Fat12GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
|
|
||||||
}
|
|
||||||
|
|
||||||
ExReleaseResourceLite (&DeviceExt->FatResource);
|
|
||||||
|
|
||||||
return (Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -256,16 +182,16 @@ FAT16FindAvailableCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
CacheSeg = NULL;
|
CacheSeg = NULL;
|
||||||
*Cluster = 0;
|
*Cluster = 0;
|
||||||
|
|
||||||
for (i = 0; i < FatLength; i+=2)
|
for (i = 2; i < FatLength; i+=2)
|
||||||
{
|
{
|
||||||
if ((i % PAGESIZE) == 0)
|
if (((FatStart + i) % PAGESIZE) == 0 || CacheSeg == NULL)
|
||||||
{
|
{
|
||||||
if (CacheSeg != NULL)
|
if (CacheSeg != NULL)
|
||||||
{
|
{
|
||||||
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
||||||
}
|
}
|
||||||
Status = CcRequestCacheSegment(DeviceExt->StorageBcb,
|
Status = CcRequestCacheSegment(DeviceExt->StorageBcb,
|
||||||
FatStart + i,
|
PAGE_ROUND_DOWN(FatStart + i),
|
||||||
&BaseAddress,
|
&BaseAddress,
|
||||||
&Valid,
|
&Valid,
|
||||||
&CacheSeg);
|
&CacheSeg);
|
||||||
|
@ -276,7 +202,8 @@ FAT16FindAvailableCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
if (!Valid)
|
if (!Valid)
|
||||||
{
|
{
|
||||||
Status = VfatReadSectors(DeviceExt->StorageDevice,
|
Status = VfatReadSectors(DeviceExt->StorageDevice,
|
||||||
(FatStart + i) / BLOCKSIZE,
|
PAGE_ROUND_DOWN(FatStart + i)
|
||||||
|
/ BLOCKSIZE,
|
||||||
PAGESIZE / BLOCKSIZE,
|
PAGESIZE / BLOCKSIZE,
|
||||||
BaseAddress);
|
BaseAddress);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -287,13 +214,15 @@ FAT16FindAvailableCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*((PUSHORT)(BaseAddress + (i % PAGESIZE))) == 0)
|
if (*((PUSHORT)(BaseAddress + ((FatStart + i) % PAGESIZE))) == 0)
|
||||||
{
|
{
|
||||||
|
DPRINT1("Found available cluster 0x%x\n", i);
|
||||||
*Cluster = i / 2;
|
*Cluster = i / 2;
|
||||||
|
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
||||||
return(STATUS_DISK_FULL);
|
return(STATUS_DISK_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,14 +232,40 @@ FAT12FindAvailableCluster (PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
|
||||||
* FUNCTION: Finds the first available cluster in a FAT12 table
|
* FUNCTION: Finds the first available cluster in a FAT12 table
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
*Cluster = 0;
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
ULONG FATOffset;
|
ULONG FATOffset;
|
||||||
ULONG Entry;
|
ULONG Entry;
|
||||||
PUCHAR CBlock = DeviceExt->FAT;
|
PUCHAR CBlock;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
PVOID BaseAddress;
|
||||||
|
BOOLEAN Valid;
|
||||||
|
PCACHE_SEGMENT CacheSeg;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
*Cluster = 0;
|
||||||
|
|
||||||
|
Status = CcRequestCacheSegment(DeviceExt->Fat12StorageBcb,
|
||||||
|
0,
|
||||||
|
&BaseAddress,
|
||||||
|
&Valid,
|
||||||
|
&CacheSeg);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
if (!Valid)
|
||||||
|
{
|
||||||
|
Status = VfatReadSectors(DeviceExt->StorageDevice,
|
||||||
|
DeviceExt->FATStart,
|
||||||
|
DeviceExt->Boot->FATSectors,
|
||||||
|
BaseAddress);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
CcReleaseCacheSegment(DeviceExt->Fat12StorageBcb, CacheSeg, FALSE);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CBlock = (PUCHAR)BaseAddress;
|
||||||
|
|
||||||
for (i = 2; i < ((DeviceExt->Boot->FATSectors * 512 * 8) / 12); i++)
|
for (i = 2; i < ((DeviceExt->Boot->FATSectors * 512 * 8) / 12); i++)
|
||||||
{
|
{
|
||||||
FATOffset = (i * 12) / 8;
|
FATOffset = (i * 12) / 8;
|
||||||
|
@ -325,12 +280,14 @@ FAT12FindAvailableCluster (PDEVICE_EXTENSION DeviceExt, PULONG Cluster)
|
||||||
Entry |= (CBlock[FATOffset + 1] << 4);
|
Entry |= (CBlock[FATOffset + 1] << 4);
|
||||||
}
|
}
|
||||||
if (Entry == 0)
|
if (Entry == 0)
|
||||||
return (i);
|
{
|
||||||
|
DPRINT1("Found available cluster 0x%x\n", i);
|
||||||
|
*Cluster = i;
|
||||||
|
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Give an error message (out of disk space) if we reach here) */
|
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
||||||
DbgPrint ("Disk full, %d clusters used\n", i);
|
return (STATUS_DISK_FULL);
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -474,14 +431,41 @@ FAT12WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
||||||
* FUNCTION: Writes a cluster to the FAT12 physical and in-memory tables
|
* FUNCTION: Writes a cluster to the FAT12 physical and in-memory tables
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
ULONG FATsector;
|
ULONG FATsector;
|
||||||
ULONG FATOffset;
|
ULONG FATOffset;
|
||||||
PUCHAR CBlock = DeviceExt->FAT;
|
PUCHAR CBlock;
|
||||||
int i;
|
int i;
|
||||||
|
NTSTATUS Status;
|
||||||
|
PVOID BaseAddress;
|
||||||
|
BOOLEAN Valid;
|
||||||
|
PCACHE_SEGMENT CacheSeg;
|
||||||
|
|
||||||
|
Status = CcRequestCacheSegment(DeviceExt->Fat12StorageBcb,
|
||||||
|
0,
|
||||||
|
&BaseAddress,
|
||||||
|
&Valid,
|
||||||
|
&CacheSeg);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
if (!Valid)
|
||||||
|
{
|
||||||
|
Status = VfatReadSectors(DeviceExt->StorageDevice,
|
||||||
|
DeviceExt->FATStart,
|
||||||
|
DeviceExt->Boot->FATSectors,
|
||||||
|
BaseAddress);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
CcReleaseCacheSegment(DeviceExt->Fat12StorageBcb, CacheSeg, FALSE);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CBlock = (PUCHAR)BaseAddress;
|
||||||
|
|
||||||
FATOffset = (ClusterToWrite * 12) / 8;
|
FATOffset = (ClusterToWrite * 12) / 8;
|
||||||
|
DPRINT1("Writing 0x%x for 0x%x at 0x%x\n",
|
||||||
|
NewValue, ClusterToWrite, FATOffset);
|
||||||
if ((ClusterToWrite % 2) == 0)
|
if ((ClusterToWrite % 2) == 0)
|
||||||
{
|
{
|
||||||
CBlock[FATOffset] = NewValue;
|
CBlock[FATOffset] = NewValue;
|
||||||
|
@ -515,7 +499,8 @@ FAT12WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
||||||
1, CBlock + FATsector * 512);
|
1, CBlock + FATsector * 512);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -535,10 +520,10 @@ FAT16WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
||||||
|
|
||||||
Start = DeviceExt->FATStart;
|
Start = DeviceExt->FATStart;
|
||||||
|
|
||||||
|
FATOffset = (Start * BLOCKSIZE) + (ClusterToWrite * 2);
|
||||||
|
|
||||||
for (i = 0; i < DeviceExt->Boot->FATCount; i++)
|
for (i = 0; i < DeviceExt->Boot->FATCount; i++)
|
||||||
{
|
{
|
||||||
FATOffset = (Start * BLOCKSIZE) + (ClusterToWrite * 2);
|
|
||||||
|
|
||||||
Status = CcRequestCacheSegment(DeviceExt->StorageBcb,
|
Status = CcRequestCacheSegment(DeviceExt->StorageBcb,
|
||||||
PAGE_ROUND_DOWN(FATOffset),
|
PAGE_ROUND_DOWN(FATOffset),
|
||||||
&BaseAddress,
|
&BaseAddress,
|
||||||
|
@ -560,11 +545,19 @@ FAT16WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DPRINT1("Writing 0x%x for offset 0x%x 0x%x\n", NewValue, FATOffset,
|
||||||
|
ClusterToWrite);
|
||||||
*((PUSHORT)(BaseAddress + (FATOffset % PAGESIZE))) = NewValue;
|
*((PUSHORT)(BaseAddress + (FATOffset % PAGESIZE))) = NewValue;
|
||||||
|
Status = VfatWriteSectors(DeviceExt->StorageDevice,
|
||||||
|
PAGE_ROUND_DOWN(FATOffset) / BLOCKSIZE,
|
||||||
|
PAGESIZE / BLOCKSIZE,
|
||||||
|
BaseAddress);
|
||||||
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
|
||||||
|
|
||||||
Start = Start + DeviceExt->Boot->FATSectors;
|
DPRINT1("DeviceExt->Boot->FATSectors %d\n",
|
||||||
|
DeviceExt->Boot->FATSectors);
|
||||||
|
FATOffset = FATOffset + DeviceExt->Boot->FATSectors * BLOCKSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (STATUS_SUCCESS);
|
return (STATUS_SUCCESS);
|
||||||
|
@ -629,77 +622,6 @@ WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
GetNextWriteCluster (PDEVICE_EXTENSION DeviceExt,
|
|
||||||
ULONG CurrentCluster,
|
|
||||||
PULONG NextCluster)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Determines the next cluster to be written
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
ULONG LastCluster, NewCluster;
|
|
||||||
UCHAR *Buffer2;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT ("GetNextWriteCluster(DeviceExt %x, CurrentCluster %x)\n",
|
|
||||||
DeviceExt, CurrentCluster);
|
|
||||||
|
|
||||||
*NextCluster = 0;
|
|
||||||
|
|
||||||
/* Find out what was happening in the last cluster's AU */
|
|
||||||
Status = GetNextCluster (DeviceExt, CurrentCluster, &LastCluster);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
/* Check to see if we must append or overwrite */
|
|
||||||
if (LastCluster == 0xFFFFFFFF)
|
|
||||||
{
|
|
||||||
/* we are after last existing cluster : we must add one to file */
|
|
||||||
/* Append */
|
|
||||||
/* Firstly, find the next available open allocation unit */
|
|
||||||
if (DeviceExt->FatType == FAT16)
|
|
||||||
{
|
|
||||||
Status = FAT16FindAvailableCluster (DeviceExt, &NewCluster);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (DeviceExt->FatType == FAT32)
|
|
||||||
{
|
|
||||||
Status = FAT32FindAvailableCluster (DeviceExt, &NewCluster);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = FAT12FindAvailableCluster (DeviceExt, &NewCluster);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Mark the new AU as the EOF */
|
|
||||||
WriteCluster (DeviceExt, NewCluster, 0xFFFFFFFF);
|
|
||||||
/* Now, write the AU of the LastCluster with the value of the newly
|
|
||||||
found AU */
|
|
||||||
WriteCluster (DeviceExt, CurrentCluster, NewCluster);
|
|
||||||
/* fill cluster with zero */
|
|
||||||
Buffer2 = ExAllocatePool (NonPagedPool, DeviceExt->BytesPerCluster);
|
|
||||||
memset (Buffer2, 0, DeviceExt->BytesPerCluster);
|
|
||||||
VfatWriteCluster (DeviceExt, Buffer2, NewCluster);
|
|
||||||
ExFreePool (Buffer2);
|
|
||||||
/* Return NewCluster as CurrentCluster */
|
|
||||||
*NextCluster = NewCluster;
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Overwrite: Return LastCluster as CurrentCluster */
|
|
||||||
*NextCluster = LastCluster;
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
ClusterToSector (PDEVICE_EXTENSION DeviceExt, unsigned long Cluster)
|
ClusterToSector (PDEVICE_EXTENSION DeviceExt, unsigned long Cluster)
|
||||||
/*
|
/*
|
||||||
|
@ -745,7 +667,10 @@ VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VfatWriteCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
|
VfatRawWriteCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
|
ULONG FirstCluster,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG Cluster)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Write a cluster to the physical device
|
* FUNCTION: Write a cluster to the physical device
|
||||||
*/
|
*/
|
||||||
|
@ -756,11 +681,134 @@ VfatWriteCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
|
||||||
DPRINT ("VfatWriteCluster(DeviceExt %x, Buffer %x, Cluster %d)\n",
|
DPRINT ("VfatWriteCluster(DeviceExt %x, Buffer %x, Cluster %d)\n",
|
||||||
DeviceExt, Buffer, Cluster);
|
DeviceExt, Buffer, Cluster);
|
||||||
|
|
||||||
Sector = ClusterToSector (DeviceExt, Cluster);
|
if (FirstCluster == 1)
|
||||||
|
{
|
||||||
Status = VfatWriteSectors (DeviceExt->StorageDevice,
|
Status = VfatWriteSectors (DeviceExt->StorageDevice,
|
||||||
Sector, DeviceExt->Boot->SectorsPerCluster,
|
Cluster,
|
||||||
Buffer);
|
DeviceExt->Boot->SectorsPerCluster, Buffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Sector = ClusterToSector (DeviceExt, Cluster);
|
||||||
|
|
||||||
|
Status = VfatWriteSectors (DeviceExt->StorageDevice,
|
||||||
|
Sector, DeviceExt->Boot->SectorsPerCluster,
|
||||||
|
Buffer);
|
||||||
|
}
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
GetNextCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
|
ULONG CurrentCluster,
|
||||||
|
PULONG NextCluster,
|
||||||
|
BOOLEAN Extend)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Retrieve the next cluster depending on the FAT type
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT ("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n",
|
||||||
|
DeviceExt, CurrentCluster);
|
||||||
|
|
||||||
|
if (Extend)
|
||||||
|
{
|
||||||
|
ExAcquireResourceSharedLite (&DeviceExt->FatResource, TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ExAcquireResourceExclusiveLite (&DeviceExt->FatResource, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the file hasn't any clusters allocated then we need special
|
||||||
|
* handling
|
||||||
|
*/
|
||||||
|
if (CurrentCluster == 0 && Extend)
|
||||||
|
{
|
||||||
|
ULONG NewCluster;
|
||||||
|
|
||||||
|
if (DeviceExt->FatType == FAT16)
|
||||||
|
{
|
||||||
|
Status = FAT16FindAvailableCluster (DeviceExt, &NewCluster);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DeviceExt->FatType == FAT32)
|
||||||
|
{
|
||||||
|
Status = FAT32FindAvailableCluster (DeviceExt, &NewCluster);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = FAT12FindAvailableCluster (DeviceExt, &NewCluster);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Mark the new AU as the EOF */
|
||||||
|
WriteCluster (DeviceExt, NewCluster, 0xFFFFFFFF);
|
||||||
|
*NextCluster = NewCluster;
|
||||||
|
ExReleaseResourceLite(&DeviceExt->FatResource);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
else if (CurrentCluster == 0)
|
||||||
|
{
|
||||||
|
ExReleaseResourceLite(&DeviceExt->FatResource);
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DeviceExt->FatType == FAT16)
|
||||||
|
{
|
||||||
|
Status = Fat16GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
|
||||||
|
}
|
||||||
|
else if (DeviceExt->FatType == FAT32)
|
||||||
|
{
|
||||||
|
Status = Fat32GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = Fat12GetNextCluster (DeviceExt, CurrentCluster, NextCluster);
|
||||||
|
}
|
||||||
|
if (Extend && (*NextCluster) == 0xFFFFFFFF)
|
||||||
|
{
|
||||||
|
ULONG NewCluster;
|
||||||
|
|
||||||
|
/* We are after last existing cluster, we must add one to file */
|
||||||
|
/* Firstly, find the next available open allocation unit */
|
||||||
|
if (DeviceExt->FatType == FAT16)
|
||||||
|
{
|
||||||
|
Status = FAT16FindAvailableCluster (DeviceExt, &NewCluster);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DeviceExt->FatType == FAT32)
|
||||||
|
{
|
||||||
|
Status = FAT32FindAvailableCluster (DeviceExt, &NewCluster);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = FAT12FindAvailableCluster (DeviceExt, &NewCluster);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Mark the new AU as the EOF */
|
||||||
|
WriteCluster (DeviceExt, NewCluster, 0xFFFFFFFF);
|
||||||
|
/* Now, write the AU of the LastCluster with the value of the newly
|
||||||
|
found AU */
|
||||||
|
WriteCluster (DeviceExt, CurrentCluster, NewCluster);
|
||||||
|
*NextCluster = NewCluster;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExReleaseResourceLite (&DeviceExt->FatResource);
|
||||||
|
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: iface.c,v 1.48 2001/01/12 21:00:08 dwelch Exp $
|
/* $Id: iface.c,v 1.49 2001/01/16 09:55:02 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -157,6 +157,14 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
|
||||||
Status = CcInitializeFileCache(DeviceExt->StreamStorageDevice,
|
Status = CcInitializeFileCache(DeviceExt->StreamStorageDevice,
|
||||||
&DeviceExt->StorageBcb,
|
&DeviceExt->StorageBcb,
|
||||||
PAGESIZE);
|
PAGESIZE);
|
||||||
|
if (DeviceExt->FatType == FAT12)
|
||||||
|
{
|
||||||
|
DeviceExt->Fat12StorageDevice =
|
||||||
|
IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
|
||||||
|
Status = CcInitializeFileCache(DeviceExt->Fat12StorageDevice,
|
||||||
|
&DeviceExt->Fat12StorageBcb,
|
||||||
|
PAGESIZE * 3);
|
||||||
|
}
|
||||||
ExInitializeResourceLite (&DeviceExt->DirResource);
|
ExInitializeResourceLite (&DeviceExt->DirResource);
|
||||||
ExInitializeResourceLite (&DeviceExt->FatResource);
|
ExInitializeResourceLite (&DeviceExt->FatResource);
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: vfat.h,v 1.23 2001/01/14 15:05:53 dwelch Exp $ */
|
/* $Id: vfat.h,v 1.24 2001/01/16 09:55:02 dwelch Exp $ */
|
||||||
|
|
||||||
#include <ddk/ntifs.h>
|
#include <ddk/ntifs.h>
|
||||||
|
|
||||||
|
@ -83,6 +83,8 @@ typedef struct
|
||||||
PDEVICE_OBJECT StorageDevice;
|
PDEVICE_OBJECT StorageDevice;
|
||||||
PFILE_OBJECT StreamStorageDevice;
|
PFILE_OBJECT StreamStorageDevice;
|
||||||
PBCB StorageBcb;
|
PBCB StorageBcb;
|
||||||
|
PFILE_OBJECT Fat12StorageDevice;
|
||||||
|
PBCB Fat12StorageBcb;
|
||||||
BootSector *Boot;
|
BootSector *Boot;
|
||||||
int rootDirectorySectors, FATStart, rootStart, dataStart;
|
int rootDirectorySectors, FATStart, rootStart, dataStart;
|
||||||
int FATEntriesPerSector, FATUnit;
|
int FATEntriesPerSector, FATUnit;
|
||||||
|
@ -153,6 +155,12 @@ NTSTATUS STDCALL
|
||||||
VfatQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
VfatQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NextCluster(PDEVICE_EXTENSION DeviceExt,
|
||||||
|
ULONG FirstCluster,
|
||||||
|
PULONG CurrentCluster,
|
||||||
|
BOOLEAN Extend);
|
||||||
|
|
||||||
/* internal functions in blockdev.c */
|
/* internal functions in blockdev.c */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VfatReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
VfatReadSectors(IN PDEVICE_OBJECT pDeviceObject,
|
||||||
|
@ -188,9 +196,11 @@ VfatReadFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
PULONG LengthRead, ULONG NoCache);
|
PULONG LengthRead, ULONG NoCache);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VfatWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
VfatWriteFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
PVOID Buffer, ULONG Length, ULONG WriteOffset);
|
PVOID Buffer, ULONG Length, ULONG WriteOffset, ULONG NoCache);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster,
|
GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt,
|
||||||
|
ULONG FirstCluster,
|
||||||
|
ULONG CurrentCluster,
|
||||||
PULONG NextCluster);
|
PULONG NextCluster);
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IsDeletedEntry(PVOID Block, ULONG Offset);
|
IsDeletedEntry(PVOID Block, ULONG Offset);
|
||||||
|
@ -199,7 +209,8 @@ IsLastEntry(PVOID Block, ULONG Offset);
|
||||||
wchar_t*
|
wchar_t*
|
||||||
vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount);
|
vfat_wcsncpy(wchar_t * dest, const wchar_t *src,size_t wcount);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VfatWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster);
|
VfatRawWriteCluster(PDEVICE_EXTENSION DeviceExt,
|
||||||
|
ULONG FirstCluster, PVOID Buffer, ULONG Cluster);
|
||||||
|
|
||||||
/* internal functions in dirwr.c */
|
/* internal functions in dirwr.c */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -236,7 +247,8 @@ ClusterToSector(PDEVICE_EXTENSION DeviceExt, ULONG Cluster);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
GetNextCluster(PDEVICE_EXTENSION DeviceExt,
|
GetNextCluster(PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG CurrentCluster,
|
ULONG CurrentCluster,
|
||||||
PULONG NextCluster);
|
PULONG NextCluster,
|
||||||
|
BOOLEAN Extend);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
|
VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
|
||||||
ULONG FirstCluster,
|
ULONG FirstCluster,
|
||||||
|
@ -269,6 +281,9 @@ VfatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb);
|
ReadVolumeLabel(PDEVICE_EXTENSION DeviceExt, PVPB Vpb);
|
||||||
|
NTSTATUS
|
||||||
|
VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||||
|
PWSTR FileName);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* functions from shutdown.c
|
* functions from shutdown.c
|
||||||
|
|
|
@ -10,7 +10,7 @@ cp services/dd/vga/miniport/vgamp.sys $1/reactos/system32/drivers
|
||||||
cp services/dd/vga/display/vgaddi.dll $1/reactos/system32/drivers
|
cp services/dd/vga/display/vgaddi.dll $1/reactos/system32/drivers
|
||||||
cp services/dd/vidport/vidport.sys $1/reactos/system32/drivers
|
cp services/dd/vidport/vidport.sys $1/reactos/system32/drivers
|
||||||
cp services/fs/minix/minixfs.sys $1/reactos/system32/drivers
|
cp services/fs/minix/minixfs.sys $1/reactos/system32/drivers
|
||||||
cp apps/shell/shell.exe $1/reactos/system32
|
cp apps/system/shell/shell.exe $1/reactos/system32
|
||||||
cp lib/ntdll/ntdll.dll $1/reactos/system32
|
cp lib/ntdll/ntdll.dll $1/reactos/system32
|
||||||
cp lib/kernel32/kernel32.dll $1/reactos/system32
|
cp lib/kernel32/kernel32.dll $1/reactos/system32
|
||||||
cp lib/crtdll/crtdll.dll $1/reactos/system32
|
cp lib/crtdll/crtdll.dll $1/reactos/system32
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: rw.c,v 1.14 2000/10/11 20:50:31 dwelch Exp $
|
/* $Id: rw.c,v 1.15 2001/01/16 09:55:02 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -101,8 +101,6 @@ WINBOOL STDCALL ReadFile(HANDLE hFile,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock;
|
PIO_STATUS_BLOCK IoStatusBlock;
|
||||||
PLARGE_INTEGER ptrOffset;
|
PLARGE_INTEGER ptrOffset;
|
||||||
|
|
||||||
DbgPrint("ReadFile(hFile %x)\n", hFile);
|
|
||||||
|
|
||||||
if (IsConsoleHandle(hFile))
|
if (IsConsoleHandle(hFile))
|
||||||
{
|
{
|
||||||
return(ReadConsoleA(hFile,
|
return(ReadConsoleA(hFile,
|
||||||
|
|
|
@ -101,6 +101,7 @@ MmGetContinuousPages(ULONG NumberOfBytes,
|
||||||
MmPageArray[i].SavedSwapEntry = 0;
|
MmPageArray[i].SavedSwapEntry = 0;
|
||||||
InsertTailList(&UsedPageListHead, &MmPageArray[i].ListEntry);
|
InsertTailList(&UsedPageListHead, &MmPageArray[i].ListEntry);
|
||||||
}
|
}
|
||||||
|
KeReleaseSpinLock(&PageListLock, oldIrql);
|
||||||
return((PVOID)(start * 4096));
|
return((PVOID)(start * 4096));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ DIST_DIR = dist
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC = $(PREFIX)gcc
|
CC = $(PREFIX)gcc
|
||||||
|
CXX = $(PREFIX)g++
|
||||||
HOST_CC = gcc
|
HOST_CC = gcc
|
||||||
HOST_NM = nm
|
HOST_NM = nm
|
||||||
CFLAGS := $(CFLAGS) -I$(PATH_TO_TOP)/include -pipe
|
CFLAGS := $(CFLAGS) -I$(PATH_TO_TOP)/include -pipe
|
||||||
|
|
Loading…
Reference in a new issue