+2002-12-15 Casper S. Hornstrup <chorns@users.sourceforge.net>\r
+\r
+ * drivers/fs/vfat/cleanup.c (VfatCleanupFile): Only uninitialize caching\r
+ when initialized.\r
+ * drivers/fs/vfat/fcb.c (vfatReleaseFCB): Ditto.\r
+ * lib/kernel32/mem/section.c (CreateFileMappingW): Pass NULL as\r
+ MaximumSize to NtCreateSection if dwMaximumSizeHigh and dwMaximumSizeLow\r
+ are both 0.\r
+ * ntoskrnl/cc/pin.c (CcMapData): Assert if Bcb is NULL.\r
+ * ntoskrnl/cc/view.c (CcRosReleaseCacheSegment, CcRosLookupCacheSegment,\r
+ CcRosMarkDirtyCacheSegment, CcRosUnmapCacheSegment,\r
+ CcRosCreateCacheSegment, CcRosGetCacheSegmentChain,\r
+ CcRosGetCacheSegment, CcRosRequestCacheSegment, CcFlushCache,\r
+ CcRosDeleteFileCache, CcRosReferenceCache, CcRosDereferenceCache,\r
+ CcRosReleaseFileCache, CcGetFileObjectFromSectionPtrs): Ditto.\r
+ * ntoskrnl/mm/section.c (MiReadPage): Assert if Fcb->Bcb is NULL.\r
+ (MmCreateDataFileSection): Make sure caching is initialized for the file\r
+ stream.\r
+\r
2002-11-15 Casper S. Hornstrup <chorns@users.sourceforge.net>\r
\r
* include/ddk/ldrtypes.h: Move ...\r
-/* $Id: cleanup.c,v 1.7 2002/08/14 20:58:31 dwelch Exp $
+/* $Id: cleanup.c,v 1.8 2002/12/15 17:01:51 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
}
}
- /* Uninitialize the file cache. */
- CcRosReleaseFileCache (FileObject, pFcb->RFCB.Bcb);
+ /* Uninitialize file cache if initialized for this file object. */
+ if (pFcb->RFCB.Bcb != NULL)
+ {
+ CcRosReleaseFileCache (FileObject, pFcb->RFCB.Bcb);
+ }
return STATUS_SUCCESS;
}
-/* $Id: fcb.c,v 1.22 2002/11/11 21:49:18 hbirr Exp $
+/* $Id: fcb.c,v 1.23 2002/12/15 17:01:51 chorns Exp $
*
*
* FILE: fcb.c
KeReleaseSpinLock (&pVCB->FcbListLock, oldIrql);
if (vfatFCBIsDirectory(pFCB))
{
- CcRosReleaseFileCache(pFCB->FileObject, pFCB->RFCB.Bcb);
+ /* Uninitialize file cache if initialized for this file object. */
+ if (pFCB->RFCB.Bcb != NULL)
+ {
+ CcRosReleaseFileCache(pFCB->FileObject, pFCB->RFCB.Bcb);
+ }
vfatDestroyCCB(pFCB->FileObject->FsContext2);
pFCB->FileObject->FsContext2 = NULL;
ObDereferenceObject(pFCB->FileObject);
-/* $Id: section.c,v 1.16 2002/09/08 10:22:43 chorns Exp $
+/* $Id: section.c,v 1.17 2002/12/15 17:01:51 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
NTSTATUS Status;
HANDLE SectionHandle;
LARGE_INTEGER MaximumSize;
+ PLARGE_INTEGER MaximumSizePointer;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
PSECURITY_DESCRIPTOR SecurityDescriptor;
SecurityDescriptor = NULL;
}
- MaximumSize.u.LowPart = dwMaximumSizeLow;
- MaximumSize.u.HighPart = dwMaximumSizeHigh;
+ if ((dwMaximumSizeLow == 0) && (dwMaximumSizeHigh == 0))
+ {
+ MaximumSizePointer = NULL;
+ }
+ else
+ {
+ MaximumSize.u.LowPart = dwMaximumSizeLow;
+ MaximumSize.u.HighPart = dwMaximumSizeHigh;
+ MaximumSizePointer = &MaximumSize;
+ }
RtlInitUnicodeString(&UnicodeName,
lpName);
InitializeObjectAttributes(&ObjectAttributes,
Status = NtCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
&ObjectAttributes,
- &MaximumSize,
+ MaximumSizePointer,
flProtect,
0,
hFile);
-/* $Id: pin.c,v 1.8 2002/10/02 19:23:42 hbirr Exp $
+/* $Id: pin.c,v 1.9 2002/12/15 17:01:52 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
ReadOffset = FileOffset->QuadPart;
Bcb = ((REACTOS_COMMON_FCB_HEADER*)FileObject->FsContext)->Bcb;
-
+ assert(Bcb);
+
DPRINT("AllocationSize %d, FileSize %d\n",
(ULONG)Bcb->AllocationSize.QuadPart,
(ULONG)Bcb->FileSize.QuadPart);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: view.c,v 1.53 2002/10/02 19:20:51 hbirr Exp $
+/* $Id: view.c,v 1.54 2002/12/15 17:01:52 chorns Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cc/view.c
BOOLEAN WasDirty = CacheSeg->Dirty;
KIRQL oldIrql;
+ assert(Bcb);
+
DPRINT("CcReleaseCacheSegment(Bcb %x, CacheSeg %x, Valid %d)\n",
Bcb, CacheSeg, Valid);
PCACHE_SEGMENT current;
KIRQL oldIrql;
+ assert(Bcb);
+
DPRINT("CcRosLookupCacheSegment(Bcb %x, FileOffset %d)\n", Bcb, FileOffset);
KeAcquireSpinLock(&Bcb->BcbLock, &oldIrql);
PCACHE_SEGMENT CacheSeg;
KIRQL oldIrql;
+ assert(Bcb);
+
DPRINT("CcRosMarkDirtyCacheSegment(Bcb %x, FileOffset %d)\n", Bcb, FileOffset);
CacheSeg = CcRosLookupCacheSegment(Bcb, FileOffset);
BOOLEAN WasDirty;
KIRQL oldIrql;
+ assert(Bcb);
+
DPRINT("CcRosUnmapCacheSegment(Bcb %x, FileOffset %d, NowDirty %d)\n",
Bcb, FileOffset, NowDirty);
NTSTATUS Status;
KIRQL oldIrql;
+ assert(Bcb);
+
DPRINT("CcRosCreateCacheSegment()\n");
current = ExAllocatePoolWithTag(NonPagedPool, sizeof(CACHE_SEGMENT),
PCACHE_SEGMENT* CacheSegList;
PCACHE_SEGMENT Previous = NULL;
+ assert(Bcb);
+
DPRINT("CcRosGetCacheSegmentChain()\n");
Length = ROUND_UP(Length, Bcb->CacheSegmentSize);
PCACHE_SEGMENT current;
NTSTATUS Status;
+ assert(Bcb);
+
DPRINT("CcRosGetCacheSegment()\n");
/*
{
ULONG BaseOffset;
+ assert(Bcb);
+
if ((FileOffset % Bcb->CacheSegmentSize) != 0)
{
CPRINT("Bad fileoffset %x should be multiple of %x",
NTSTATUS Status;
KIRQL oldIrql;
+ assert(Bcb);
+
DPRINT("CcRosFreeCacheSegment(Bcb %x, CacheSeg %x)\n",
Bcb, CacheSeg);
if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
{
Bcb = (PBCB)SectionObjectPointers->SharedCacheMap;
+ assert(Bcb);
if (FileOffset)
{
Offset = *FileOffset;
LIST_ENTRY FreeList;
KIRQL oldIrql;
+ assert(Bcb);
+
DPRINT("CcRosDeleteFileCache(FileObject %x, Bcb %x)\n",
Bcb->FileObject, Bcb);
PBCB Bcb;
ExAcquireFastMutex(&ViewLock);
Bcb = (PBCB)FileObject->SectionObjectPointers->SharedCacheMap;
+ assert(Bcb);
Bcb->RefCount++;
ExReleaseFastMutex(&ViewLock);
}
PBCB Bcb;
ExAcquireFastMutex(&ViewLock);
Bcb = (PBCB)FileObject->SectionObjectPointers->SharedCacheMap;
+ assert(Bcb);
Bcb->RefCount--;
if (Bcb->RefCount == 0)
{
* has been closed.
*/
{
+ assert(Bcb);
+
ExAcquireFastMutex(&ViewLock);
if (FileObject->SectionObjectPointers->SharedCacheMap != NULL)
if (SectionObjectPointers && SectionObjectPointers->SharedCacheMap)
{
Bcb = (PBCB)SectionObjectPointers->SharedCacheMap;
+ assert(Bcb);
return Bcb->FileObject;
}
return NULL;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: section.c,v 1.101 2002/11/10 18:17:42 chorns Exp $
+/* $Id: section.c,v 1.102 2002/12/15 17:01:52 chorns Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
+ assert(Fcb->Bcb);
+
/*
* If the file system is letting us go directly to the cache and the
* memory area was mapped at an offset in the file which is page aligned
PFILE_OBJECT FileObject;
PMM_SECTION_SEGMENT Segment;
ULONG FileAccess;
+ IO_STATUS_BLOCK Iosb;
+ LARGE_INTEGER Offset;
+ CHAR Buffer;
/*
* Check the protection
{
return(STATUS_INVALID_PAGE_PROTECTION);
}
-
+
+ /*
+ * Read a bit so caching is initiated for the file object.
+ * This is only needed because MiReadPage currently cannot
+ * handle non-cached streams.
+ */
+ Offset.QuadPart = 0;
+ Status = ZwReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &Iosb,
+ &Buffer,
+ sizeof (Buffer),
+ &Offset,
+ 0);
+ if (!NT_SUCCESS(Status) && (Status != STATUS_END_OF_FILE))
+ {
+ return(Status);
+ }
+
/*
* Create the section
*/