Create a branch for work on porting an alternate TCP library with the main focus...
[reactos.git] / 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 {
27 *BufferLength = sizeof(FILE_FS_DEVICE_INFORMATION);
28 return STATUS_BUFFER_OVERFLOW;
29 }
30
31 FsDeviceInfo->DeviceType = FILE_DEVICE_NAMED_PIPE;
32 FsDeviceInfo->Characteristics = 0;
33
34 *BufferLength = sizeof(FILE_FS_DEVICE_INFORMATION);
35
36 DPRINT("NpfsQueryFsDeviceInformation() finished.\n");
37
38 return STATUS_SUCCESS;
39 }
40
41
42 static NTSTATUS
43 NpfsQueryFsAttributeInformation(PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo,
44 PULONG BufferLength)
45 {
46 DPRINT("NpfsQueryFsAttributeInformation() called.\n");
47 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
48
49 if (*BufferLength < sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8)
50 {
51 *BufferLength = (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);
52 return STATUS_BUFFER_OVERFLOW;
53 }
54
55 FsAttributeInfo->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES;
56 FsAttributeInfo->MaximumComponentNameLength = 255;
57 FsAttributeInfo->FileSystemNameLength = 8;
58 wcscpy(FsAttributeInfo->FileSystemName,
59 L"NPFS");
60
61 DPRINT("NpfsQueryFsAttributeInformation() finished.\n");
62 *BufferLength = (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);
63
64 return STATUS_SUCCESS;
65 }
66
67
68 NTSTATUS NTAPI
69 NpfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
70 PIRP Irp)
71 {
72 PIO_STACK_LOCATION Stack;
73 FS_INFORMATION_CLASS FsInformationClass;
74 NTSTATUS Status = STATUS_SUCCESS;
75 PVOID SystemBuffer;
76 ULONG BufferLength;
77
78 /* PRECONDITION */
79 ASSERT(DeviceObject != NULL);
80 ASSERT(Irp != NULL);
81
82 DPRINT("NpfsQueryVolumeInformation(DeviceObject %p, Irp %p)\n",
83 DeviceObject,
84 Irp);
85
86 Stack = IoGetCurrentIrpStackLocation(Irp);
87 FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
88 BufferLength = Stack->Parameters.QueryVolume.Length;
89 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
90
91 DPRINT("FsInformationClass %d\n", FsInformationClass);
92 DPRINT("SystemBuffer %p\n", SystemBuffer);
93
94 switch (FsInformationClass)
95 {
96 case FileFsDeviceInformation:
97 Status = NpfsQueryFsDeviceInformation(SystemBuffer,
98 &BufferLength);
99 break;
100
101 case FileFsAttributeInformation:
102 Status = NpfsQueryFsAttributeInformation(SystemBuffer,
103 &BufferLength);
104 break;
105
106 default:
107 Status = STATUS_NOT_SUPPORTED;
108 }
109
110 Irp->IoStatus.Status = Status;
111 Irp->IoStatus.Information = BufferLength;
112
113 IoCompleteRequest(Irp,
114 IO_NO_INCREMENT);
115
116 return Status;
117 }
118
119 /* EOF */