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