Separated close request
[reactos.git] / reactos / drivers / fs / vfat / close.c
1 /* $Id: close.c,v 1.1 2000/07/07 02:14:14 ekohl Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/fs/vfat/close.c
6 * PURPOSE: VFAT Filesystem
7 * PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
8 */
9
10 /* INCLUDES *****************************************************************/
11
12 #include <ddk/ntddk.h>
13
14 #define NDEBUG
15 #include <debug.h>
16
17 #include "vfat.h"
18
19 /* FUNCTIONS ****************************************************************/
20
21 NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
22 /*
23 * FUNCTION: Closes a file
24 */
25 {
26 PVFATFCB pFcb;
27 PVFATCCB pCcb;
28 KIRQL oldIrql;
29
30 DPRINT("FsdCloseFile(DeviceExt %x, FileObject %x)\n",
31 DeviceExt,FileObject);
32
33 //FIXME : update entry in directory ?
34 pCcb = (PVFATCCB)(FileObject->FsContext2);
35
36 DPRINT("pCcb %x\n",pCcb);
37 if (pCcb == NULL)
38 {
39 return(STATUS_SUCCESS);
40 }
41
42 pFcb = pCcb->pFcb;
43
44 pFcb->RefCount--;
45 if(pFcb->RefCount<=0)
46 {
47 KeAcquireSpinLock(&DeviceExt->FcbListLock, &oldIrql);
48 RemoveEntryList(&pFcb->FcbListEntry);
49 KeReleaseSpinLock(&DeviceExt->FcbListLock, oldIrql);
50 ExFreePool(pFcb);
51 }
52 ExFreePool(pCcb);
53 return STATUS_SUCCESS;
54 }
55
56 NTSTATUS FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
57 /*
58 * FUNCTION: Closes a file
59 */
60 {
61 PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
62 PFILE_OBJECT FileObject = Stack->FileObject;
63 PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
64 NTSTATUS Status;
65
66 DPRINT("FsdClose(DeviceObject %x, Irp %x)\n",DeviceObject, Irp);
67
68 Status = FsdCloseFile(DeviceExtension,FileObject);
69
70 Irp->IoStatus.Status = Status;
71 Irp->IoStatus.Information = 0;
72
73 IoCompleteRequest(Irp, IO_NO_INCREMENT);
74 return(Status);
75 }
76
77 /* EOF */