1 /* $Id: util.c,v 1.14 2003/07/10 06:27:13 royce Exp $
3 * reactos/ntoskrnl/fs/util.c
10 /**********************************************************************
12 * FsRtlIsTotalDeviceFailure@4
15 * Check if an NTSTATUS error code represents a
16 * disk hardware failure.
23 * FALSE if either (NtStatus >= STATUS_SUCCESS),
24 * STATUS_CRC_ERROR, STATUS_DEVICE_DATA_ERROR;
31 FsRtlIsTotalDeviceFailure (
36 (NT_SUCCESS(NtStatus
))
37 || (STATUS_CRC_ERROR
== NtStatus
)
38 || (STATUS_DEVICE_DATA_ERROR
== NtStatus
)
45 /**********************************************************************
47 * FsRtlIsNtstatusExpected/1
51 * Check an NTSTATUS value is expected by the FS kernel
59 * TRUE if NtStatus is NOT one out of:
60 * - STATUS_ACCESS_VIOLATION
61 * - STATUS_ILLEGAL_INSTRUCTION
62 * - STATUS_DATATYPE_MISALIGNMENT
63 * - STATUS_INSTRUCTION_MISALIGNMENT
64 * which are the forbidden return stati in the FsRtl
65 * subsystem; FALSE otherwise.
68 * 2002-01-17 Fixed a bad bug reported by Bo Brantén.
69 * Up to version 1.8, this function's semantics was
70 * exactly the opposite! Thank you Bo.
76 FsRtlIsNtstatusExpected (
81 (STATUS_DATATYPE_MISALIGNMENT
== NtStatus
)
82 || (STATUS_ACCESS_VIOLATION
== NtStatus
)
83 || (STATUS_ILLEGAL_INSTRUCTION
== NtStatus
)
84 || (STATUS_INSTRUCTION_MISALIGNMENT
== NtStatus
)
91 /**********************************************************************
93 * FsRtlNormalizeNtstatus@8
96 * Normalize an NTSTATUS value for using in the FS subsystem.
100 * NTSTATUS to normalize.
102 * NTSTATUS to return if the NtStatusToNormalize
103 * value is unexpected by the FS kernel subsystem.
106 * NtStatusToNormalize if it is an expected value,
107 * otherwise NormalizedNtStatus.
113 FsRtlNormalizeNtstatus (
114 IN NTSTATUS NtStatusToNormalize
,
115 IN NTSTATUS NormalizedNtStatus
119 (TRUE
== FsRtlIsNtstatusExpected(NtStatusToNormalize
))
120 ? NtStatusToNormalize
121 : NormalizedNtStatus
;
125 /**********************************************************************
126 * Miscellanea (they may fit somewhere else)
127 *********************************************************************/
130 /**********************************************************************
132 * FsRtlAllocateResource@0
145 FsRtlAllocateResource (VOID
)
151 /**********************************************************************
153 * FsRtlBalanceReads@4
174 /**********************************************************************
185 * From Bo Branten's ntifs.h v12.
192 IN PFILE_OBJECT FileObject
,
193 IN PLARGE_INTEGER FileOffset
,
198 OUT PIO_STATUS_BLOCK IoStatus
,
199 IN PDEVICE_OBJECT DeviceObject
206 /**********************************************************************
217 * From Bo Branten's ntifs.h v12.
224 IN PFILE_OBJECT FileObject
,
225 IN PLARGE_INTEGER FileOffset
,
230 OUT PIO_STATUS_BLOCK IoStatus
,
231 IN PDEVICE_OBJECT DeviceObject
238 /**********************************************************************
253 IN PFILE_OBJECT FileObject
,
254 IN OUT PLARGE_INTEGER FileSize
257 FILE_STANDARD_INFORMATION Info
;
261 Status
= IoQueryFileInformation(FileObject
,
262 FileStandardInformation
,
266 if (NT_SUCCESS(Status
))
268 FileSize
->QuadPart
= Info
.EndOfFile
.QuadPart
;
275 /**********************************************************************
277 * FsRtlPostPagingFileStackOverflow@12
289 FsRtlPostPagingFileStackOverflow (
298 /**********************************************************************
300 * FsRtlPostStackOverflow@12
312 FsRtlPostStackOverflow (
321 /**********************************************************************
323 * FsRtlSyncVolumes@12
331 * It always returns STATUS_SUCCESS.
343 return STATUS_SUCCESS
;