2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/io/flush.c
5 * PURPOSE: Flushing file buffer
6 * PROGRAMMER: David Welch (welch@cwcom.net)
11 /* INCLUDES *****************************************************************/
13 #include <ddk/ntddk.h>
14 #include <internal/ob.h>
17 #include <internal/debug.h>
19 /* FUNCTIONS *****************************************************************/
24 NtFlushWriteBuffer(VOID
)
27 return STATUS_SUCCESS
;
34 OUT PIO_STATUS_BLOCK IoStatusBlock
37 * FUNCTION: Flushes cached file data to disk
39 * FileHandle = Points to the file
40 * IoStatusBlock = Caller must supply storage to receive the result of
41 * the flush buffers operation. The information field is
42 * set to number of bytes flushed to disk.
44 * REMARKS: This function maps to the win32 FlushFileBuffers
47 PFILE_OBJECT FileObject
= NULL
;
49 PIO_STACK_LOCATION StackPtr
;
51 KPROCESSOR_MODE PreviousMode
;
53 PreviousMode
= ExGetPreviousMode();
55 Status
= ObReferenceObjectByHandle(FileHandle
,
61 if (Status
!= STATUS_SUCCESS
)
65 KeResetEvent( &FileObject
->Event
);
66 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_FLUSH_BUFFERS
,
67 FileObject
->DeviceObject
,
74 /* Trigger FileObject/Event dereferencing */
75 Irp
->Tail
.Overlay
.OriginalFileObject
= FileObject
;
77 Irp
->RequestorMode
= PreviousMode
;
79 StackPtr
= IoGetNextIrpStackLocation(Irp
);
80 StackPtr
->FileObject
= FileObject
;
82 Status
= IoCallDriver(FileObject
->DeviceObject
,Irp
);
83 if (Status
== STATUS_PENDING
)
85 KeWaitForSingleObject(&FileObject
->Event
,
88 FileObject
->Flags
& FO_ALERTABLE_IO
,
90 Status
= IoStatusBlock
->Status
;