- Reference the file object in IopSecurityFile.  
- Don't set FO_DIRECT_DEVICE_OPEN in IoCreateStreamFileObject.  
- Disabled the setting of IRP_NOCACHE, because vfat cannot handle cached and non cached requests for the same file.  
- Set the correct device object in NtWriteFile.
Modified: trunk/reactos/ntoskrnl/io/file.c

Modified: trunk/reactos/ntoskrnl/io/file.c
--- trunk/reactos/ntoskrnl/io/file.c	2005-05-17 18:04:23 UTC (rev 15380)
+++ trunk/reactos/ntoskrnl/io/file.c	2005-05-17 19:00:12 UTC (rev 15381)
@@ -344,6 +344,8 @@
         StackPtr->Parameters.SetSecurity.SecurityDescriptor = SecurityDescriptor;
     }
 
+    ObReferenceObject(FileObject);
+
     /* Call the Driver */
     Status = IoCallDriver(FileObject->DeviceObject, Irp);
 
@@ -1022,8 +1024,8 @@
     CreatedFileObject->Vpb = DeviceObject->Vpb;
     CreatedFileObject->Type = IO_TYPE_FILE;
     /* HACK */
-    CreatedFileObject->Flags |= FO_DIRECT_DEVICE_OPEN;
-    //CreatedFileObject->Flags = FO_STREAM_FILE;
+    //CreatedFileObject->Flags |= FO_DIRECT_DEVICE_OPEN;
+    CreatedFileObject->Flags |= FO_STREAM_FILE;
 
     /* Initialize Lock and Event */
     KeInitializeEvent(&CreatedFileObject->Event, NotificationEvent, FALSE);
@@ -2536,7 +2538,12 @@
     Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
     Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
     Irp->Flags |= IRP_READ_OPERATION;
+#if 0
+    /* FIXME:
+     *    Vfat doesn't handle non cached files correctly.
+     */     
     if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) Irp->Flags |= IRP_NOCACHE;
+#endif      
 
     /* Setup Stack Data */
     StackPtr = IoGetNextIrpStackLocation(Irp);
@@ -3114,7 +3121,7 @@
     _SEH_TRY
     {
         Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
-                                           FileObject->DeviceObject,
+                                           DeviceObject,
                                            Buffer,
                                            Length,
                                            ByteOffset,
@@ -3148,7 +3155,12 @@
     Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
     Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
     Irp->Flags |= IRP_WRITE_OPERATION;
+#if 0    
+    /* FIXME:
+     *    Vfat doesn't handle non cached files correctly.
+     */     
     if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) Irp->Flags |= IRP_NOCACHE;
+#endif    
 
     /* Setup Stack Data */
     StackPtr = IoGetNextIrpStackLocation(Irp);