5a6f0a0b9d343e37d7296367ba035693be6be399
[reactos.git] / reactos / drivers / filesystems / npfs / volinfo.c
1 /*
2 * PROJECT: ReactOS Named Pipe FileSystem
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/filesystems/npfs/volinfo.c
5 * PURPOSE: Named Pipe FileSystem Volume Information
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include "npfs.h"
12
13 // File ID number for NPFS bugchecking support
14 #define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_VOLINFO)
15
16 /* FUNCTIONS ******************************************************************/
17
18 NTSTATUS
19 NTAPI
20 NpQueryFsVolumeInfo(IN PVOID Buffer,
21 IN OUT PULONG Length)
22 {
23 PFILE_FS_VOLUME_INFORMATION InfoBuffer = Buffer;
24 NTSTATUS Status;
25 USHORT NameLength;
26 TRACE("Entered\n");
27
28 *Length -= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel);
29
30 InfoBuffer->VolumeCreationTime.LowPart = 0;
31 InfoBuffer->VolumeCreationTime.HighPart = 0;
32 InfoBuffer->VolumeSerialNumber = 0;
33 InfoBuffer->SupportsObjects = 0;
34
35 NameLength = 18;
36 InfoBuffer->VolumeLabelLength = 18;
37
38 if (*Length < 18)
39 {
40 NameLength = (USHORT)*Length;
41 Status = STATUS_BUFFER_OVERFLOW;
42 }
43 else
44 {
45 Status = STATUS_SUCCESS;
46 }
47
48 RtlCopyMemory(InfoBuffer->VolumeLabel, L"NamedPipe", NameLength);
49 *Length -= NameLength;
50
51 TRACE("Leaving, Status = %lx\n", Status);
52 return Status;
53 }
54
55 NTSTATUS
56 NTAPI
57 NpQueryFsSizeInfo(IN PVOID Buffer,
58 IN OUT PULONG Length)
59 {
60 PFILE_FS_SIZE_INFORMATION InfoBuffer = Buffer;
61 TRACE("Entered\n");
62
63 *Length -= sizeof(*InfoBuffer);
64
65 InfoBuffer->TotalAllocationUnits.QuadPart = 0;
66 InfoBuffer->AvailableAllocationUnits.QuadPart = 0;
67 InfoBuffer->SectorsPerAllocationUnit = 1;
68 InfoBuffer->BytesPerSector = 1;
69
70 TRACE("Leaving, Status = STATUS_SUCCESS\n");
71 return STATUS_SUCCESS;
72 }
73
74 NTSTATUS
75 NTAPI
76 NpQueryFsDeviceInfo(IN PVOID Buffer,
77 IN OUT PULONG Length)
78 {
79 PFILE_FS_DEVICE_INFORMATION InfoBuffer = Buffer;
80 TRACE("Entered\n");
81
82 InfoBuffer->DeviceType = 0;
83 InfoBuffer->Characteristics = 0;
84 InfoBuffer->DeviceType = FILE_DEVICE_NAMED_PIPE;
85 *Length -= sizeof(*InfoBuffer);
86
87 TRACE("Leaving, Status = STATUS_SUCCESS\n");
88 return STATUS_SUCCESS;
89 }
90
91 NTSTATUS
92 NTAPI
93 NpQueryFsAttributeInfo(IN PVOID Buffer,
94 IN OUT PULONG Length)
95 {
96 PFILE_FS_ATTRIBUTE_INFORMATION InfoBuffer = Buffer;
97 NTSTATUS Status;
98 USHORT NameLength;
99 TRACE("Entered\n");
100
101 NameLength = (USHORT)(*Length - 12);
102 if (NameLength < 8)
103 {
104 *Length = 0;
105 Status = STATUS_BUFFER_OVERFLOW;
106 }
107 else
108 {
109 *Length -= 20;
110 NameLength = 8;
111 Status = STATUS_SUCCESS;
112 }
113
114 InfoBuffer->MaximumComponentNameLength = 0xFFFFFFFF;
115 InfoBuffer->FileSystemNameLength = 8;
116 InfoBuffer->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES;
117 RtlCopyMemory(InfoBuffer->FileSystemName, L"NPFS", NameLength);
118
119 TRACE("Leaving, Status = %lx\n", Status);
120 return Status;
121 }
122
123 NTSTATUS
124 NTAPI
125 NpQueryFsFullSizeInfo(IN PVOID Buffer,
126 IN OUT PULONG Length)
127 {
128 PFILE_FS_FULL_SIZE_INFORMATION InfoBuffer = Buffer;
129 TRACE("Entered\n");
130
131 *Length -= sizeof(*InfoBuffer);
132
133 RtlZeroMemory(InfoBuffer, sizeof(*InfoBuffer));
134
135 TRACE("Leaving, Status = STATUS_SUCCESS\n");
136 return STATUS_SUCCESS;
137 }
138
139 NTSTATUS
140 NTAPI
141 NpCommonQueryVolumeInformation(IN PDEVICE_OBJECT DeviceObject,
142 IN PIRP Irp)
143 {
144 PIO_STACK_LOCATION IoStack;
145 FS_INFORMATION_CLASS InfoClass;
146 ULONG Length;
147 PVOID Buffer;
148 NTSTATUS Status;
149 PAGED_CODE();
150 TRACE("Entered\n");
151
152 IoStack = IoGetCurrentIrpStackLocation(Irp);
153 Buffer = Irp->AssociatedIrp.SystemBuffer;
154 Length = IoStack->Parameters.QueryVolume.Length;
155 InfoClass = IoStack->Parameters.QueryVolume.FsInformationClass;
156
157 switch (InfoClass)
158 {
159 case FileFsVolumeInformation:
160 Status = NpQueryFsVolumeInfo(Buffer, &Length);
161 break;
162 case FileFsSizeInformation:
163 Status = NpQueryFsSizeInfo(Buffer, &Length);
164 break;
165 case FileFsDeviceInformation:
166 Status = NpQueryFsDeviceInfo(Buffer, &Length);
167 break;
168 case FileFsAttributeInformation:
169 Status = NpQueryFsAttributeInfo(Buffer, &Length);
170 break;
171 case FileFsFullSizeInformation:
172 Status = NpQueryFsFullSizeInfo(Buffer, &Length);
173 break;
174 default:
175 Status = STATUS_NOT_SUPPORTED;
176 break;
177 }
178
179 Irp->IoStatus.Information = IoStack->Parameters.QueryVolume.Length - Length;
180 TRACE("Leaving, Status = %lx\n", Status);
181 return Status;
182 }
183
184 NTSTATUS
185 NTAPI
186 NpFsdQueryVolumeInformation(IN PDEVICE_OBJECT DeviceObject,
187 IN PIRP Irp)
188 {
189 NTSTATUS Status;
190 PAGED_CODE();
191 TRACE("Entered\n");
192
193 FsRtlEnterFileSystem();
194 NpAcquireSharedVcb();
195
196 Status = NpCommonQueryVolumeInformation(DeviceObject, Irp);
197
198 NpReleaseVcb();
199 FsRtlExitFileSystem();
200
201 if (Status != STATUS_PENDING)
202 {
203 Irp->IoStatus.Status = Status;
204 IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
205 }
206
207 TRACE("Leaving, Status = %lx\n", Status);
208 return Status;
209 }
210
211 /* EOF */