Partial merge of the condrv_restructure branch, including:
[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/filesystems/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 NTSTATUS
19 NTAPI
20 NpQueryFsDeviceInformation(IN PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
21 OUT PULONG BufferLength)
22 {
23 PAGED_CODE();
24 DPRINT("NpfsQueryFsDeviceInformation()\n");
25 DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo);
26
27 if (*BufferLength < sizeof(FILE_FS_DEVICE_INFORMATION))
28 {
29 return STATUS_BUFFER_OVERFLOW;
30 }
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 NTSTATUS
43 NTAPI
44 NpQueryFsFullSizeInfo(IN PFILE_FS_FULL_SIZE_INFORMATION FsSizeInfo,
45 OUT PULONG BufferSize)
46 {
47 RtlZeroMemory(FsSizeInfo, sizeof(FILE_FS_FULL_SIZE_INFORMATION));
48 *BufferSize -= sizeof(FILE_FS_FULL_SIZE_INFORMATION);
49 return STATUS_SUCCESS;
50 }
51
52 NTSTATUS
53 NTAPI
54 NpQueryFsSizeInfo(IN PFILE_FS_SIZE_INFORMATION FsSizeInfo,
55 OUT PULONG BufferSize)
56 {
57 FsSizeInfo->TotalAllocationUnits.LowPart = 0;
58 FsSizeInfo->TotalAllocationUnits.HighPart = 0;
59 FsSizeInfo->AvailableAllocationUnits.LowPart = 0;
60 FsSizeInfo->AvailableAllocationUnits.HighPart = 0;
61 FsSizeInfo->SectorsPerAllocationUnit = 1;
62 FsSizeInfo->BytesPerSector = 1;
63 *BufferSize -= sizeof(FILE_FS_SIZE_INFORMATION);
64 return STATUS_SUCCESS;
65 }
66
67 NTSTATUS
68 NTAPI
69 NpQueryFsAttributeInformation(IN PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo,
70 OUT PULONG BufferLength)
71 {
72 PAGED_CODE();
73 DPRINT("NpfsQueryFsAttributeInformation() called.\n");
74 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
75
76 if (*BufferLength < sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8)
77 {
78 *BufferLength = 0;
79 return STATUS_BUFFER_OVERFLOW;
80 }
81
82 FsAttributeInfo->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES;
83 FsAttributeInfo->MaximumComponentNameLength = -1;
84 FsAttributeInfo->FileSystemNameLength = 8;
85 wcscpy(FsAttributeInfo->FileSystemName, L"NPFS");
86
87 DPRINT("NpfsQueryFsAttributeInformation() finished.\n");
88 *BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);
89
90 return STATUS_SUCCESS;
91 }
92
93 NTSTATUS
94 NTAPI
95 NpCommonQueryVolumeInformation(IN PIRP Irp)
96 {
97 PIO_STACK_LOCATION Stack;
98 FS_INFORMATION_CLASS FsInformationClass;
99 PVOID SystemBuffer;
100 ULONG BufferLength;
101 NTSTATUS Status;
102 PAGED_CODE();
103
104 Stack = IoGetCurrentIrpStackLocation(Irp);
105 FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
106 BufferLength = Stack->Parameters.QueryVolume.Length;
107 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
108
109 DPRINT("FsInformationClass %d\n", FsInformationClass);
110 DPRINT("SystemBuffer %p\n", SystemBuffer);
111
112 switch (FsInformationClass)
113 {
114 case FileFsFullSizeInformation:
115 Status = NpQueryFsFullSizeInfo(SystemBuffer, &BufferLength);
116 break;
117 case FileFsSizeInformation:
118 Status = NpQueryFsSizeInfo(SystemBuffer, &BufferLength);
119 break;
120
121 case FileFsDeviceInformation:
122 Status = NpQueryFsDeviceInformation(SystemBuffer, &BufferLength);
123 break;
124
125 case FileFsAttributeInformation:
126 Status = NpQueryFsAttributeInformation(SystemBuffer, &BufferLength);
127 break;
128
129 default:
130 DPRINT1("Query not implemented: %d\n", FsInformationClass);
131 Status = STATUS_NOT_SUPPORTED;
132 }
133
134 Irp->IoStatus.Information = Stack->Parameters.QueryVolume.Length - BufferLength;
135 return Status;
136 }
137
138 NTSTATUS
139 NTAPI
140 NpfsQueryVolumeInformation(IN PDEVICE_OBJECT DeviceObject,
141 IN PIRP Irp)
142 {
143 NTSTATUS Status;
144 PAGED_CODE();
145 DPRINT("NpfsQueryVolumeInformation(DeviceObject %p, Irp %p)\n", DeviceObject, Irp);
146
147 FsRtlEnterFileSystem();
148 Status = NpCommonQueryVolumeInformation(Irp);
149 FsRtlExitFileSystem();
150
151 if (Status != STATUS_PENDING)
152 {
153 Irp->IoStatus.Status = Status;
154
155 IoCompleteRequest(Irp, IO_DISK_INCREMENT);
156 }
157
158 return Status;
159 }
160
161 /* EOF */