merge ROS Shell without integrated explorer part into trunk
[reactos.git] / reactos / drivers / fs / np / volume.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: drivers/fs/npfs/volume.c
6 * PURPOSE: Named pipe filesystem
7 * PROGRAMMER: Eric Kohl
8 */
9
10 /* INCLUDES *****************************************************************/
11
12 #include <ddk/ntddk.h>
13 #include <wchar.h>
14
15 #define NDEBUG
16 #include <debug.h>
17
18 #include "npfs.h"
19
20 /* FUNCTIONS ****************************************************************/
21
22 static NTSTATUS
23 NpfsQueryFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
24 PULONG BufferLength)
25 {
26 DPRINT("NpfsQueryFsDeviceInformation()\n");
27 DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo);
28
29 if (*BufferLength < sizeof(FILE_FS_DEVICE_INFORMATION))
30 return STATUS_BUFFER_OVERFLOW;
31
32 FsDeviceInfo->DeviceType = FILE_DEVICE_NAMED_PIPE;
33 FsDeviceInfo->Characteristics = 0;
34
35 *BufferLength -= sizeof(FILE_FS_DEVICE_INFORMATION);
36
37 DPRINT("NpfsQueryFsDeviceInformation() finished.\n");
38
39 return STATUS_SUCCESS;
40 }
41
42
43 static NTSTATUS
44 NpfsQueryFsAttributeInformation(PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo,
45 PULONG BufferLength)
46 {
47 DPRINT("NpfsQueryFsAttributeInformation() called.\n");
48 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
49
50 if (*BufferLength < sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8)
51 return STATUS_BUFFER_OVERFLOW;
52
53 FsAttributeInfo->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES;
54 FsAttributeInfo->MaximumComponentNameLength = 255;
55 FsAttributeInfo->FileSystemNameLength = 8;
56 wcscpy(FsAttributeInfo->FileSystemName,
57 L"NPFS");
58
59 DPRINT("NpfsQueryFsAttributeInformation() finished.\n");
60 *BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);
61
62 return STATUS_SUCCESS;
63 }
64
65
66 NTSTATUS STDCALL
67 NpfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
68 PIRP Irp)
69 {
70 PIO_STACK_LOCATION Stack;
71 FS_INFORMATION_CLASS FsInformationClass;
72 NTSTATUS Status = STATUS_SUCCESS;
73 PVOID SystemBuffer;
74 ULONG BufferLength;
75
76 /* PRECONDITION */
77 ASSERT(DeviceObject != NULL);
78 ASSERT(Irp != NULL);
79
80 DPRINT("NpfsQueryVolumeInformation(DeviceObject %x, Irp %x)\n",
81 DeviceObject,
82 Irp);
83
84 Stack = IoGetCurrentIrpStackLocation(Irp);
85 FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
86 BufferLength = Stack->Parameters.QueryVolume.Length;
87 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
88
89 DPRINT("FsInformationClass %d\n", FsInformationClass);
90 DPRINT("SystemBuffer %x\n", SystemBuffer);
91
92 switch (FsInformationClass)
93 {
94 case FileFsDeviceInformation:
95 Status = NpfsQueryFsDeviceInformation(SystemBuffer,
96 &BufferLength);
97 break;
98
99 case FileFsAttributeInformation:
100 Status = NpfsQueryFsAttributeInformation(SystemBuffer,
101 &BufferLength);
102 break;
103
104 default:
105 Status = STATUS_NOT_SUPPORTED;
106 }
107
108 Irp->IoStatus.Status = Status;
109 if (NT_SUCCESS(Status))
110 Irp->IoStatus.Information = Stack->Parameters.QueryVolume.Length - BufferLength;
111 else
112 Irp->IoStatus.Information = 0;
113 IoCompleteRequest(Irp,
114 IO_NO_INCREMENT);
115
116 return Status;
117 }
118
119 /* EOF */