3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/io/flush.c
6 * PURPOSE: Flushing file buffer
8 * PROGRAMMERS: David Welch (welch@cwcom.net)
11 /* INCLUDES *****************************************************************/
15 #include <internal/debug.h>
17 /* FUNCTIONS *****************************************************************/
22 NtFlushWriteBuffer(VOID
)
25 return STATUS_SUCCESS
;
32 OUT PIO_STATUS_BLOCK IoStatusBlock
35 * FUNCTION: Flushes cached file data to disk
37 * FileHandle = Points to the file
38 * IoStatusBlock = Caller must supply storage to receive the result of
39 * the flush buffers operation. The information field is
40 * set to number of bytes flushed to disk.
42 * REMARKS: This function maps to the win32 FlushFileBuffers
45 PFILE_OBJECT FileObject
= NULL
;
47 PIO_STACK_LOCATION StackPtr
;
49 KPROCESSOR_MODE PreviousMode
;
51 PreviousMode
= ExGetPreviousMode();
53 Status
= ObReferenceObjectByHandle(FileHandle
,
59 if (Status
!= STATUS_SUCCESS
)
63 KeResetEvent( &FileObject
->Event
);
64 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_FLUSH_BUFFERS
,
65 FileObject
->DeviceObject
,
72 /* Trigger FileObject/Event dereferencing */
73 Irp
->Tail
.Overlay
.OriginalFileObject
= FileObject
;
75 Irp
->RequestorMode
= PreviousMode
;
77 StackPtr
= IoGetNextIrpStackLocation(Irp
);
78 StackPtr
->FileObject
= FileObject
;
80 Status
= IoCallDriver(FileObject
->DeviceObject
,Irp
);
81 if (Status
== STATUS_PENDING
)
83 KeWaitForSingleObject(&FileObject
->Event
,
86 FileObject
->Flags
& FO_ALERTABLE_IO
,
88 Status
= IoStatusBlock
->Status
;