[NTFS]
[reactos.git] / reactos / drivers / filesystems / ntfs / dispatch.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2008 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 * COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS kernel
21 * FILE: drivers/filesystem/ntfs/dispatch.c
22 * PURPOSE: NTFS filesystem driver
23 * PROGRAMMER: Pierre Schweitzer
24 * UPDATE HISTORY:
25 */
26
27 /* INCLUDES *****************************************************************/
28
29 #include "ntfs.h"
30
31 #define NDEBUG
32 #include <debug.h>
33
34 /* FUNCTIONS ****************************************************************/
35
36 /*
37 * FUNCTION: This function manages IRP for various major functions
38 * ARGUMENTS:
39 * DriverObject = object describing this driver
40 * Irp = IRP to be passed to internal functions
41 * RETURNS: Status of I/O Request
42 */
43 NTSTATUS
44 NTAPI
45 NtfsFsdDispatch(PDEVICE_OBJECT DeviceObject,
46 PIRP Irp)
47 {
48 PNTFS_IRP_CONTEXT IrpContext = NULL;
49 NTSTATUS Status = STATUS_UNSUCCESSFUL;
50
51 TRACE_(NTFS, "NtfsFsdDispatch()\n");
52
53 FsRtlEnterFileSystem();
54 ASSERT(DeviceObject);
55 ASSERT(Irp);
56
57 NtfsIsIrpTopLevel(Irp);
58
59 IrpContext = NtfsAllocateIrpContext(DeviceObject, Irp);
60 if (IrpContext)
61 {
62 switch (IrpContext->MajorFunction)
63 {
64 case IRP_MJ_QUERY_VOLUME_INFORMATION:
65 Status = NtfsQueryVolumeInformation(IrpContext);
66 break;
67
68 case IRP_MJ_SET_VOLUME_INFORMATION:
69 Status = NtfsSetVolumeInformation(IrpContext);
70 break;
71
72 case IRP_MJ_QUERY_INFORMATION:
73 Status = NtfsQueryInformation(IrpContext);
74 break;
75
76 case IRP_MJ_DIRECTORY_CONTROL:
77 Status = NtfsDirectoryControl(IrpContext);
78 break;
79 }
80 }
81 else
82 Status = STATUS_INSUFFICIENT_RESOURCES;
83
84 Irp->IoStatus.Status = Status;
85 IoCompleteRequest(Irp, IrpContext->PriorityBoost);
86
87 if (IrpContext)
88 ExFreePoolWithTag(IrpContext, 'PRIN');
89
90 IoSetTopLevelIrp(NULL);
91 FsRtlExitFileSystem();
92
93 return Status;
94 }