3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: drivers/fs/np/create.c
6 * PURPOSE: Named pipe filesystem
7 * PROGRAMMER: David Welch <welch@cwcom.net>
10 /* INCLUDES ******************************************************************/
12 #include <ddk/ntddk.h>
19 /* FUNCTIONS *****************************************************************/
22 NpfsFindPipe(PNPFS_DEVICE_EXTENSION DeviceExt
,
23 PUNICODE_STRING PipeName
)
25 PLIST_ENTRY CurrentEntry
;
28 CurrentEntry
= DeviceExt
->PipeListHead
.Flink
;
29 while (CurrentEntry
!= &DeviceExt
->PipeListHead
)
31 Pipe
= CONTAINING_RECORD(CurrentEntry
, NPFS_PIPE
, PipeListEntry
);
32 if (RtlCompareUnicodeString(PipeName
,
36 DPRINT("<%wZ> = <%wZ>\n", PipeName
, &Pipe
->PipeName
);
40 CurrentEntry
= CurrentEntry
->Flink
;
48 NpfsFindListeningServerInstance(PNPFS_PIPE Pipe
)
50 PLIST_ENTRY CurrentEntry
;
51 PNPFS_WAITER_ENTRY Waiter
;
55 CurrentEntry
= Pipe
->WaiterListHead
.Flink
;
56 while (CurrentEntry
!= &Pipe
->WaiterListHead
)
58 Waiter
= CONTAINING_RECORD(CurrentEntry
, NPFS_WAITER_ENTRY
, Entry
);
59 Irp
= CONTAINING_RECORD(Waiter
, IRP
, Tail
.Overlay
.DriverContext
);
60 if (Waiter
->Fcb
->PipeState
== FILE_PIPE_LISTENING_STATE
)
62 DPRINT("Server found! Fcb %p\n", Waiter
->Fcb
);
64 IoAcquireCancelSpinLock(&oldIrql
);
67 IoSetCancelRoutine(Irp
, NULL
);
68 IoReleaseCancelSpinLock(oldIrql
);
71 IoReleaseCancelSpinLock(oldIrql
);
74 CurrentEntry
= CurrentEntry
->Flink
;
82 NpfsSignalAndRemoveListeningServerInstance(PNPFS_PIPE Pipe
,
85 PLIST_ENTRY CurrentEntry
;
86 PNPFS_WAITER_ENTRY Waiter
;
89 CurrentEntry
= Pipe
->WaiterListHead
.Flink
;
90 while (CurrentEntry
!= &Pipe
->WaiterListHead
)
92 Waiter
= CONTAINING_RECORD(CurrentEntry
, NPFS_WAITER_ENTRY
, Entry
);
93 if (Waiter
->Fcb
== Fcb
)
95 DPRINT("Server found! Fcb %p\n", Waiter
->Fcb
);
97 RemoveEntryList(&Waiter
->Entry
);
98 Irp
= CONTAINING_RECORD(Waiter
, IRP
, Tail
.Overlay
.DriverContext
);
99 Irp
->IoStatus
.Status
= STATUS_PIPE_CONNECTED
;
100 Irp
->IoStatus
.Information
= 0;
101 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
104 CurrentEntry
= CurrentEntry
->Flink
;
110 NpfsCreate(PDEVICE_OBJECT DeviceObject
,
113 PIO_STACK_LOCATION IoStack
;
114 PFILE_OBJECT FileObject
;
117 PNPFS_FCB ServerFcb
= NULL
;
118 PNPFS_DEVICE_EXTENSION DeviceExt
;
119 BOOLEAN SpecialAccess
;
121 DPRINT("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
123 DeviceExt
= (PNPFS_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
124 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
125 FileObject
= IoStack
->FileObject
;
126 DPRINT("FileObject %p\n", FileObject
);
127 DPRINT("FileName %wZ\n", &FileObject
->FileName
);
129 Irp
->IoStatus
.Information
= 0;
131 SpecialAccess
= ((IoStack
->Parameters
.Create
.ShareAccess
& 3) == 3);
134 DPRINT("NpfsCreate() open client end for special use!\n");
138 * Step 1. Find the pipe we're trying to open.
140 KeLockMutex(&DeviceExt
->PipeListLock
);
141 Pipe
= NpfsFindPipe(DeviceExt
,
142 &FileObject
->FileName
);
145 /* Not found, bail out with error. */
146 DPRINT("No pipe found!\n");
147 KeUnlockMutex(&DeviceExt
->PipeListLock
);
148 Irp
->IoStatus
.Status
= STATUS_OBJECT_NAME_NOT_FOUND
;
149 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
150 return STATUS_OBJECT_NAME_NOT_FOUND
;
153 KeUnlockMutex(&DeviceExt
->PipeListLock
);
156 * Acquire the lock for FCB lists. From now on no modifications to the
157 * FCB lists are allowed, because it can cause various misconsistencies.
159 KeLockMutex(&Pipe
->FcbListLock
);
162 * Step 2. Create the client FCB.
164 ClientFcb
= ExAllocatePool(NonPagedPool
, sizeof(NPFS_FCB
));
165 if (ClientFcb
== NULL
)
167 DPRINT("No memory!\n");
168 KeUnlockMutex(&Pipe
->FcbListLock
);
169 Irp
->IoStatus
.Status
= STATUS_NO_MEMORY
;
170 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
171 return STATUS_NO_MEMORY
;
174 ClientFcb
->Thread
= (struct ETHREAD
*)Irp
->Tail
.Overlay
.Thread
;
175 ClientFcb
->Pipe
= Pipe
;
176 ClientFcb
->PipeEnd
= FILE_PIPE_CLIENT_END
;
177 ClientFcb
->OtherSide
= NULL
;
178 ClientFcb
->PipeState
= SpecialAccess
? 0 : FILE_PIPE_DISCONNECTED_STATE
;
179 InitializeListHead(&ClientFcb
->ReadRequestListHead
);
181 DPRINT("Fcb: %x\n", ClientFcb
);
183 /* Initialize data list. */
184 if (Pipe
->OutboundQuota
)
186 ClientFcb
->Data
= ExAllocatePool(PagedPool
, Pipe
->OutboundQuota
);
187 if (ClientFcb
->Data
== NULL
)
189 DPRINT("No memory!\n");
190 ExFreePool(ClientFcb
);
191 KeUnlockMutex(&Pipe
->FcbListLock
);
192 Irp
->IoStatus
.Status
= STATUS_NO_MEMORY
;
193 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
194 return STATUS_NO_MEMORY
;
199 ClientFcb
->Data
= NULL
;
202 ClientFcb
->ReadPtr
= ClientFcb
->Data
;
203 ClientFcb
->WritePtr
= ClientFcb
->Data
;
204 ClientFcb
->ReadDataAvailable
= 0;
205 ClientFcb
->WriteQuotaAvailable
= Pipe
->OutboundQuota
;
206 ClientFcb
->MaxDataLength
= Pipe
->OutboundQuota
;
207 ExInitializeFastMutex(&ClientFcb
->DataListLock
);
208 KeInitializeEvent(&ClientFcb
->ConnectEvent
, SynchronizationEvent
, FALSE
);
209 KeInitializeEvent(&ClientFcb
->ReadEvent
, SynchronizationEvent
, FALSE
);
210 KeInitializeEvent(&ClientFcb
->WriteEvent
, SynchronizationEvent
, FALSE
);
214 * Step 3. Search for listening server FCB.
220 * WARNING: Point of no return! Once we get the server FCB it's
221 * possible that we completed a wait request and so we have to
222 * complete even this request.
225 ServerFcb
= NpfsFindListeningServerInstance(Pipe
);
226 if (ServerFcb
== NULL
)
228 PLIST_ENTRY CurrentEntry
;
232 * If no waiting server FCB was found then try to pick
233 * one of the listing server FCB on the pipe.
236 CurrentEntry
= Pipe
->ServerFcbListHead
.Flink
;
237 while (CurrentEntry
!= &Pipe
->ServerFcbListHead
)
239 Fcb
= CONTAINING_RECORD(CurrentEntry
, NPFS_FCB
, FcbListEntry
);
240 if (Fcb
->PipeState
== FILE_PIPE_LISTENING_STATE
)
245 CurrentEntry
= CurrentEntry
->Flink
;
249 * No one is listening to me?! I'm so lonely... :(
252 if (ServerFcb
== NULL
)
254 /* Not found, bail out with error for FILE_OPEN requests. */
255 DPRINT("No listening server fcb found!\n");
257 ExFreePool(ClientFcb
->Data
);
258 KeUnlockMutex(&Pipe
->FcbListLock
);
259 Irp
->IoStatus
.Status
= STATUS_PIPE_BUSY
;
260 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
261 return STATUS_PIPE_BUSY
;
266 /* Signal the server thread and remove it from the waiter list */
267 /* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */
268 NpfsSignalAndRemoveListeningServerInstance(Pipe
, ServerFcb
);
271 else if (IsListEmpty(&Pipe
->ServerFcbListHead
))
273 DPRINT("No server fcb found!\n");
274 KeUnlockMutex(&Pipe
->FcbListLock
);
275 Irp
->IoStatus
.Status
= STATUS_UNSUCCESSFUL
;
276 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
277 return STATUS_UNSUCCESSFUL
;
281 * Step 4. Add the client FCB to a list and connect it if possible.
284 /* Add the client FCB to the pipe FCB list. */
285 InsertTailList(&Pipe
->ClientFcbListHead
, &ClientFcb
->FcbListEntry
);
287 /* Connect to listening server side */
290 ClientFcb
->OtherSide
= ServerFcb
;
291 ServerFcb
->OtherSide
= ClientFcb
;
292 ClientFcb
->PipeState
= FILE_PIPE_CONNECTED_STATE
;
293 ServerFcb
->PipeState
= FILE_PIPE_CONNECTED_STATE
;
296 KeUnlockMutex(&Pipe
->FcbListLock
);
298 FileObject
->FsContext
= ClientFcb
;
300 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
301 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
303 DPRINT("Success!\n");
305 return STATUS_SUCCESS
;
310 NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject
,
313 PIO_STACK_LOCATION IoStack
;
314 PFILE_OBJECT FileObject
;
315 PNPFS_DEVICE_EXTENSION DeviceExt
;
318 PNAMED_PIPE_CREATE_PARAMETERS Buffer
;
319 BOOLEAN NewPipe
= FALSE
;
321 DPRINT("NpfsCreateNamedPipe(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
323 DeviceExt
= (PNPFS_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
324 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
325 FileObject
= IoStack
->FileObject
;
326 DPRINT("FileObject %p\n", FileObject
);
327 DPRINT("Pipe name %wZ\n", &FileObject
->FileName
);
329 Buffer
= IoStack
->Parameters
.CreatePipe
.Parameters
;
331 Irp
->IoStatus
.Information
= 0;
333 Fcb
= ExAllocatePool(NonPagedPool
, sizeof(NPFS_FCB
));
336 Irp
->IoStatus
.Status
= STATUS_NO_MEMORY
;
337 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
338 return STATUS_NO_MEMORY
;
341 Fcb
->Thread
= (struct ETHREAD
*)Irp
->Tail
.Overlay
.Thread
;
342 KeLockMutex(&DeviceExt
->PipeListLock
);
345 * First search for existing Pipe with the same name.
347 Pipe
= NpfsFindPipe(DeviceExt
,
348 &FileObject
->FileName
);
352 * Found Pipe with the same name. Check if we are
355 KeUnlockMutex(&DeviceExt
->PipeListLock
);
357 if (Pipe
->CurrentInstances
>= Pipe
->MaximumInstances
)
359 DPRINT("Out of instances.\n");
361 Irp
->IoStatus
.Status
= STATUS_PIPE_BUSY
;
362 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
363 return STATUS_PIPE_BUSY
;
366 /* FIXME: Check pipe modes also! */
367 if (Pipe
->MaximumInstances
!= Buffer
->MaximumInstances
||
368 Pipe
->TimeOut
.QuadPart
!= Buffer
->DefaultTimeout
.QuadPart
)
370 DPRINT("Asked for invalid pipe mode.\n");
372 Irp
->IoStatus
.Status
= STATUS_ACCESS_DENIED
;
373 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
374 return STATUS_ACCESS_DENIED
;
380 Pipe
= ExAllocatePool(NonPagedPool
, sizeof(NPFS_PIPE
));
383 KeUnlockMutex(&DeviceExt
->PipeListLock
);
384 Irp
->IoStatus
.Status
= STATUS_NO_MEMORY
;
385 Irp
->IoStatus
.Information
= 0;
386 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
387 return STATUS_NO_MEMORY
;
390 if (RtlCreateUnicodeString(&Pipe
->PipeName
, FileObject
->FileName
.Buffer
) == FALSE
)
392 KeUnlockMutex(&DeviceExt
->PipeListLock
);
395 Irp
->IoStatus
.Status
= STATUS_NO_MEMORY
;
396 Irp
->IoStatus
.Information
= 0;
397 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
398 return STATUS_NO_MEMORY
;
401 InitializeListHead(&Pipe
->ServerFcbListHead
);
402 InitializeListHead(&Pipe
->ClientFcbListHead
);
403 InitializeListHead(&Pipe
->WaiterListHead
);
404 KeInitializeMutex(&Pipe
->FcbListLock
, 0);
406 Pipe
->PipeType
= Buffer
->NamedPipeType
;
407 Pipe
->WriteMode
= Buffer
->ReadMode
;
408 Pipe
->ReadMode
= Buffer
->ReadMode
;
409 Pipe
->CompletionMode
= Buffer
->CompletionMode
;
410 Pipe
->PipeConfiguration
= IoStack
->Parameters
.CreatePipe
.Options
& 0x3;
411 Pipe
->MaximumInstances
= Buffer
->MaximumInstances
;
412 Pipe
->CurrentInstances
= 0;
413 Pipe
->TimeOut
= Buffer
->DefaultTimeout
;
414 if (!(IoStack
->Parameters
.Create
.Options
& FILE_PIPE_OUTBOUND
) ||
415 IoStack
->Parameters
.Create
.Options
& FILE_PIPE_FULL_DUPLEX
)
417 if (Buffer
->InboundQuota
== 0)
419 Pipe
->InboundQuota
= DeviceExt
->DefaultQuota
;
423 Pipe
->InboundQuota
= PAGE_ROUND_UP(Buffer
->InboundQuota
);
424 if (Pipe
->InboundQuota
< DeviceExt
->MinQuota
)
426 Pipe
->InboundQuota
= DeviceExt
->MinQuota
;
428 else if (Pipe
->InboundQuota
> DeviceExt
->MaxQuota
)
430 Pipe
->InboundQuota
= DeviceExt
->MaxQuota
;
436 Pipe
->InboundQuota
= 0;
439 if (IoStack
->Parameters
.Create
.Options
& (FILE_PIPE_FULL_DUPLEX
|FILE_PIPE_OUTBOUND
))
441 if (Buffer
->OutboundQuota
== 0)
443 Pipe
->OutboundQuota
= DeviceExt
->DefaultQuota
;
447 Pipe
->OutboundQuota
= PAGE_ROUND_UP(Buffer
->OutboundQuota
);
448 if (Pipe
->OutboundQuota
< DeviceExt
->MinQuota
)
450 Pipe
->OutboundQuota
= DeviceExt
->MinQuota
;
452 else if (Pipe
->OutboundQuota
> DeviceExt
->MaxQuota
)
454 Pipe
->OutboundQuota
= DeviceExt
->MaxQuota
;
460 Pipe
->OutboundQuota
= 0;
463 InsertTailList(&DeviceExt
->PipeListHead
, &Pipe
->PipeListEntry
);
464 KeUnlockMutex(&DeviceExt
->PipeListLock
);
467 if (Pipe
->InboundQuota
)
469 Fcb
->Data
= ExAllocatePool(PagedPool
, Pipe
->InboundQuota
);
470 if (Fcb
->Data
== NULL
)
476 KeLockMutex(&DeviceExt
->PipeListLock
);
477 RemoveEntryList(&Pipe
->PipeListEntry
);
478 KeUnlockMutex(&DeviceExt
->PipeListLock
);
479 RtlFreeUnicodeString(&Pipe
->PipeName
);
483 Irp
->IoStatus
.Status
= STATUS_NO_MEMORY
;
484 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
485 return STATUS_NO_MEMORY
;
493 Fcb
->ReadPtr
= Fcb
->Data
;
494 Fcb
->WritePtr
= Fcb
->Data
;
495 Fcb
->ReadDataAvailable
= 0;
496 Fcb
->WriteQuotaAvailable
= Pipe
->InboundQuota
;
497 Fcb
->MaxDataLength
= Pipe
->InboundQuota
;
498 InitializeListHead(&Fcb
->ReadRequestListHead
);
499 ExInitializeFastMutex(&Fcb
->DataListLock
);
501 Pipe
->CurrentInstances
++;
504 Fcb
->PipeEnd
= FILE_PIPE_SERVER_END
;
505 Fcb
->PipeState
= FILE_PIPE_LISTENING_STATE
;
506 Fcb
->OtherSide
= NULL
;
508 DPRINT("Fcb: %x\n", Fcb
);
510 KeInitializeEvent(&Fcb
->ConnectEvent
, SynchronizationEvent
, FALSE
);
511 KeInitializeEvent(&Fcb
->ReadEvent
, SynchronizationEvent
, FALSE
);
512 KeInitializeEvent(&Fcb
->WriteEvent
, SynchronizationEvent
, FALSE
);
514 KeLockMutex(&Pipe
->FcbListLock
);
515 InsertTailList(&Pipe
->ServerFcbListHead
, &Fcb
->FcbListEntry
);
516 KeUnlockMutex(&Pipe
->FcbListLock
);
518 FileObject
->FsContext
= Fcb
;
520 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
521 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
523 DPRINT("Success!\n");
525 return STATUS_SUCCESS
;
530 NpfsCleanup(PDEVICE_OBJECT DeviceObject
,
533 PNPFS_DEVICE_EXTENSION DeviceExt
;
534 PIO_STACK_LOCATION IoStack
;
535 PFILE_OBJECT FileObject
;
536 PNPFS_FCB Fcb
, OtherSide
;
540 DPRINT("NpfsCleanup(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
542 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
543 DeviceExt
= (PNPFS_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
544 FileObject
= IoStack
->FileObject
;
545 Fcb
= FileObject
->FsContext
;
549 DPRINT("Success!\n");
550 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
551 Irp
->IoStatus
.Information
= 0;
552 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
553 return STATUS_SUCCESS
;
556 DPRINT("Fcb %x\n", Fcb
);
559 DPRINT("Cleaning pipe %wZ\n", &Pipe
->PipeName
);
561 KeLockMutex(&Pipe
->FcbListLock
);
563 Server
= (Fcb
->PipeEnd
== FILE_PIPE_SERVER_END
);
567 /* FIXME: Clean up existing connections here ?? */
574 if (Fcb
->PipeState
== FILE_PIPE_CONNECTED_STATE
)
576 OtherSide
= Fcb
->OtherSide
;
577 /* Lock the server first */
580 ExAcquireFastMutex(&Fcb
->DataListLock
);
581 ExAcquireFastMutex(&OtherSide
->DataListLock
);
585 ExAcquireFastMutex(&OtherSide
->DataListLock
);
586 ExAcquireFastMutex(&Fcb
->DataListLock
);
588 OtherSide
->PipeState
= FILE_PIPE_DISCONNECTED_STATE
;
589 OtherSide
->OtherSide
= NULL
;
591 * Signaling the write event. If is possible that an other
592 * thread waits for an empty buffer.
594 KeSetEvent(&OtherSide
->ReadEvent
, IO_NO_INCREMENT
, FALSE
);
595 KeSetEvent(&OtherSide
->WriteEvent
, IO_NO_INCREMENT
, FALSE
);
598 ExReleaseFastMutex(&Fcb
->DataListLock
);
599 ExReleaseFastMutex(&OtherSide
->DataListLock
);
603 ExReleaseFastMutex(&OtherSide
->DataListLock
);
604 ExReleaseFastMutex(&Fcb
->DataListLock
);
607 else if (Fcb
->PipeState
== FILE_PIPE_LISTENING_STATE
)
610 PNPFS_WAITER_ENTRY WaitEntry
= NULL
;
611 BOOLEAN Complete
= FALSE
;
615 Entry
= Fcb
->Pipe
->WaiterListHead
.Flink
;
616 while (Entry
!= &Fcb
->Pipe
->WaiterListHead
)
618 WaitEntry
= CONTAINING_RECORD(Entry
, NPFS_WAITER_ENTRY
, Entry
);
619 if (WaitEntry
->Fcb
== Fcb
)
621 RemoveEntryList(Entry
);
622 tmpIrp
= CONTAINING_RECORD(WaitEntry
, IRP
, Tail
.Overlay
.DriverContext
);
623 IoAcquireCancelSpinLock(&oldIrql
);
626 IoSetCancelRoutine(tmpIrp
, NULL
);
629 IoReleaseCancelSpinLock(oldIrql
);
632 tmpIrp
->IoStatus
.Status
= STATUS_PIPE_BROKEN
;
633 tmpIrp
->IoStatus
.Information
= 0;
634 IoCompleteRequest(tmpIrp
, IO_NO_INCREMENT
);
638 Entry
= Entry
->Flink
;
642 Fcb
->PipeState
= FILE_PIPE_CLOSING_STATE
;
644 KeUnlockMutex(&Pipe
->FcbListLock
);
646 ExAcquireFastMutex(&Fcb
->DataListLock
);
649 ExFreePool(Fcb
->Data
);
652 Fcb
->WritePtr
= NULL
;
654 ExReleaseFastMutex(&Fcb
->DataListLock
);
656 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
657 Irp
->IoStatus
.Information
= 0;
658 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
660 DPRINT("Success!\n");
662 return STATUS_SUCCESS
;
666 NpfsClose(PDEVICE_OBJECT DeviceObject
,
669 PNPFS_DEVICE_EXTENSION DeviceExt
;
670 PIO_STACK_LOCATION IoStack
;
671 PFILE_OBJECT FileObject
;
676 DPRINT("NpfsClose(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
678 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
679 DeviceExt
= (PNPFS_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
680 FileObject
= IoStack
->FileObject
;
681 Fcb
= FileObject
->FsContext
;
685 DPRINT("Success!\n");
686 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
687 Irp
->IoStatus
.Information
= 0;
688 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
689 return STATUS_SUCCESS
;
692 DPRINT("Fcb %x\n", Fcb
);
695 DPRINT("Closing pipe %wZ\n", &Pipe
->PipeName
);
697 KeLockMutex(&Pipe
->FcbListLock
);
699 Server
= (Fcb
->PipeEnd
== FILE_PIPE_SERVER_END
);
704 Pipe
->CurrentInstances
--;
711 ASSERT (Fcb
->PipeState
== FILE_PIPE_CLOSING_STATE
);
713 FileObject
->FsContext
= NULL
;
715 RemoveEntryList(&Fcb
->FcbListEntry
);
719 KeUnlockMutex(&Pipe
->FcbListLock
);
721 if (IsListEmpty(&Pipe
->ServerFcbListHead
) &&
722 IsListEmpty(&Pipe
->ClientFcbListHead
))
724 RtlFreeUnicodeString(&Pipe
->PipeName
);
725 KeLockMutex(&DeviceExt
->PipeListLock
);
726 RemoveEntryList(&Pipe
->PipeListEntry
);
727 KeUnlockMutex(&DeviceExt
->PipeListLock
);
731 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
732 Irp
->IoStatus
.Information
= 0;
733 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
735 DPRINT("Success!\n");
737 return STATUS_SUCCESS
;