Synchronize with trunk revision 59636 (just before Alex's CreateProcess revamp).
[reactos.git] / ntoskrnl / cache / mdlsup.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel
4 * FILE: ntoskrnl/cache/logsup.c
5 * PURPOSE: Logging and configuration routines
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include <ntoskrnl.h>
12 #include "newcc.h"
13 #define NDEBUG
14 #include <debug.h>
15
16 /* GLOBALS ********************************************************************/
17
18 /* FUNCTIONS ******************************************************************/
19
20 PMDL
21 NTAPI
22 CcpBuildCacheMdl(PFILE_OBJECT FileObject,
23 PLARGE_INTEGER FileOffset,
24 ULONG Length,
25 PIO_STATUS_BLOCK IOSB)
26 {
27 PMDL Mdl;
28 PVOID Bcb, Buffer;
29
30 BOOLEAN Result = CcMapData(FileObject,
31 FileOffset,
32 Length,
33 PIN_WAIT,
34 &Bcb,
35 &Buffer);
36
37 if (!Result)
38 {
39 IOSB->Information = 0;
40 IOSB->Status = STATUS_UNSUCCESSFUL;
41 return NULL;
42 }
43
44 IOSB->Information = Length;
45 IOSB->Status = STATUS_SUCCESS;
46
47 Mdl = IoAllocateMdl(Buffer, Length, FALSE, FALSE, NULL);
48
49 if (!Mdl)
50 {
51 IOSB->Information = 0;
52 IOSB->Status = STATUS_NO_MEMORY;
53 return NULL;
54 }
55
56 IOSB->Information = Length;
57 IOSB->Status = STATUS_SUCCESS;
58
59 return Mdl;
60 }
61
62 VOID
63 NTAPI
64 CcMdlRead(IN PFILE_OBJECT FileObject,
65 IN PLARGE_INTEGER FileOffset,
66 IN ULONG Length,
67 OUT PMDL *MdlChain,
68 OUT PIO_STATUS_BLOCK IoStatus)
69 {
70 *MdlChain = CcpBuildCacheMdl(FileObject, FileOffset, Length, IoStatus);
71 }
72
73 VOID
74 NTAPI
75 CcMdlReadComplete(IN PFILE_OBJECT FileObject,
76 IN PMDL MdlChain)
77 {
78 IoFreeMdl(MdlChain);
79 }
80
81 VOID
82 NTAPI
83 CcMdlReadComplete2(IN PFILE_OBJECT FileObject,
84 IN PMDL MdlChain)
85 {
86 UNIMPLEMENTED
87 }
88
89 VOID
90 NTAPI
91 CcPrepareMdlWrite(IN PFILE_OBJECT FileObject,
92 IN PLARGE_INTEGER FileOffset,
93 IN ULONG Length,
94 OUT PMDL *MdlChain,
95 OUT PIO_STATUS_BLOCK IoStatus)
96 {
97 *MdlChain = CcpBuildCacheMdl(FileObject, FileOffset, Length, IoStatus);
98 }
99
100 VOID
101 NTAPI
102 CcMdlWriteComplete(IN PFILE_OBJECT FileObject,
103 IN PLARGE_INTEGER FileOffset,
104 IN PMDL MdlChain)
105 {
106 IoFreeMdl(MdlChain);
107 }
108
109 VOID
110 NTAPI
111 CcMdlWriteComplete2(IN PFILE_OBJECT FileObject,
112 IN PLARGE_INTEGER FileOffset,
113 IN PMDL MdlChain)
114 {
115 UNIMPLEMENTED
116 }
117
118 VOID
119 NTAPI
120 CcMdlWriteAbort(IN PFILE_OBJECT FileObject,
121 IN PMDL MdlChain)
122 {
123 ASSERT(FALSE);
124 IoFreeMdl(MdlChain);
125 }
126
127 /* EOF */