- Remove the permanent flag from an object if ObInserObject failed (in IoCreateFile).  
- Bypass the driver for FilePositionInformation and FileAlignmentInformation in NtQueryInformationFile and NtSetInformationFile.
Modified: trunk/reactos/ntoskrnl/io/file.c

Modified: trunk/reactos/ntoskrnl/io/file.c
--- trunk/reactos/ntoskrnl/io/file.c	2005-07-26 19:21:27 UTC (rev 16754)
+++ trunk/reactos/ntoskrnl/io/file.c	2005-07-26 19:31:41 UTC (rev 16755)
@@ -845,6 +845,7 @@
      DPRINT1("FIXME: IO_CHECK_CREATE_PARAMETERS not yet supported!\n");
    }
 
+   /* First try to open an existing named object */
    Status = ObOpenObjectByName(ObjectAttributes,
                                NULL,
                                NULL,
@@ -910,6 +911,7 @@
    if (!NT_SUCCESS(Status))
      {
        DPRINT("ObInsertObject() failed! (Status %lx)\n", Status);
+       ObMakeTemporaryObject(FileObject);
        ObDereferenceObject (FileObject);
        return Status;
      }
@@ -2429,11 +2431,6 @@
                 Failed = TRUE;
             break;
 
-        case FileAlignmentInformation:
-            if (!(FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING))
-                Failed = TRUE;
-            break;
-
         default:
             break;
     }
@@ -2445,6 +2442,30 @@
         return STATUS_ACCESS_DENIED;
     }
 
+    if (FileInformationClass == FilePositionInformation)
+    {
+       if (Length < sizeof(FILE_POSITION_INFORMATION))
+       {
+          Status = STATUS_BUFFER_OVERFLOW;
+       }
+       else
+       {
+          _SEH_TRY
+          {
+             ((PFILE_POSITION_INFORMATION)FileInformation)->CurrentByteOffset = FileObject->CurrentByteOffset;
+             IoStatusBlock->Information = sizeof(FILE_POSITION_INFORMATION);
+             Status = IoStatusBlock->Status = STATUS_SUCCESS;
+          }
+          _SEH_HANDLE
+          {
+             Status = _SEH_GetExceptionCode();
+          }
+          _SEH_END;
+       }
+       ObDereferenceObject(FileObject);
+       return Status;
+    }
+
     DPRINT("FileObject 0x%p\n", FileObject);
 
     /* Check if this is a direct open or not */
@@ -2457,6 +2478,30 @@
         DeviceObject = IoGetRelatedDeviceObject(FileObject);
     }
 
+    if (FileInformationClass == FileAlignmentInformation)
+    {
+       if (Length < sizeof(FILE_ALIGNMENT_INFORMATION))
+       {
+          Status = STATUS_BUFFER_OVERFLOW;
+       }
+       else
+       {
+          _SEH_TRY
+          {
+             ((PFILE_ALIGNMENT_INFORMATION)FileInformation)->AlignmentRequirement = DeviceObject->AlignmentRequirement;
+             IoStatusBlock->Information = sizeof(FILE_ALIGNMENT_INFORMATION);
+             Status = IoStatusBlock->Status = STATUS_SUCCESS;
+          }
+          _SEH_HANDLE
+          {
+             Status = _SEH_GetExceptionCode();
+          }
+          _SEH_END;
+       }
+       ObDereferenceObject(FileObject);
+       return Status;
+    }
+
     /* Check if we should use Sync IO or not */
     if (FileObject->Flags & FO_SYNCHRONOUS_IO)
     {
@@ -2895,6 +2940,30 @@
 
     DPRINT("FileObject 0x%p\n", FileObject);
 
+    if (FileInformationClass == FilePositionInformation)
+    {
+       if (Length < sizeof(FILE_POSITION_INFORMATION))
+       {
+          Status = STATUS_BUFFER_OVERFLOW;
+       }
+       else
+       {
+          _SEH_TRY
+          {
+             FileObject->CurrentByteOffset = ((PFILE_POSITION_INFORMATION)FileInformation)->CurrentByteOffset;
+             IoStatusBlock->Information = 0;
+             Status = IoStatusBlock->Status = STATUS_SUCCESS;
+          }
+          _SEH_HANDLE
+          {
+             Status = _SEH_GetExceptionCode();
+          }
+          _SEH_END;
+       }
+       ObDereferenceObject(FileObject);
+       return Status;
+    }
+
     /* FIXME: Later, we can implement a lot of stuff here and avoid a driver call */
     /* Handle IO Completion Port quickly */
     if (FileInformationClass == FileCompletionInformation)