2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/io_x.h
5 * PURPOSE: Internal Inlined Functions for the I/O Manager
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
11 IopLockFileObject(IN PFILE_OBJECT FileObject
)
13 /* Lock the FO and check for contention */
14 if (InterlockedExchange((PLONG
)&FileObject
->Busy
, TRUE
))
16 /* FIXME: Implement contention case */
23 IopUnlockFileObject(IN PFILE_OBJECT FileObject
)
25 /* Unlock the FO and wake any waiters up */
26 InterlockedExchange((PLONG
)&FileObject
->Busy
, FALSE
);
27 if (FileObject
->Waiters
) KeSetEvent(&FileObject
->Lock
, 0, FALSE
);
32 IopQueueIrpToThread(IN PIRP Irp
)
36 /* Raise to APC Level */
37 KeRaiseIrql(APC_LEVEL
, &OldIrql
);
39 /* Insert it into the list */
40 InsertHeadList(&Irp
->Tail
.Overlay
.Thread
->IrpList
, &Irp
->ThreadListEntry
);
48 IopUnQueueIrpFromThread(IN PIRP Irp
)
50 /* Remove it from the list and reset it */
51 RemoveEntryList(&Irp
->ThreadListEntry
);
52 InitializeListHead(&Irp
->ThreadListEntry
);
57 IopUpdateOperationCount(IN IOP_TRANSFER_TYPE Type
)
59 PLARGE_INTEGER CountToChange
;
61 /* Make sure I/O operations are being counted */
62 if (IoCountOperations
)
64 if (Type
== IopReadTransfer
)
66 /* Increase read count */
67 IoReadOperationCount
++;
68 CountToChange
= &PsGetCurrentProcess()->ReadOperationCount
;
70 else if (Type
== IopWriteTransfer
)
72 /* Increase write count */
73 IoWriteOperationCount
++;
74 CountToChange
= &PsGetCurrentProcess()->ReadOperationCount
;
78 /* Increase other count */
79 IoOtherOperationCount
++;
80 CountToChange
= &PsGetCurrentProcess()->ReadOperationCount
;
83 /* Increase the process-wide count */
84 ExInterlockedAddLargeStatistic(CountToChange
, 1);
90 IopValidateOpenPacket(IN POPEN_PACKET OpenPacket
)
92 /* Validate the packet */
94 (OpenPacket
->Type
!= IO_TYPE_OPEN_PACKET
) ||
95 (OpenPacket
->Size
!= sizeof(OPEN_PACKET
)))