ReactOS  0.4.14-dev-552-g2fad488
volinfo.c File Reference
#include "rfsd.h"
Include dependency graph for volinfo.c:

Go to the source code of this file.

Functions

__drv_mustHoldCriticalRegion NTSTATUS RfsdQueryVolumeInformation (IN PRFSD_IRP_CONTEXT IrpContext)
 
__drv_mustHoldCriticalRegion NTSTATUS RfsdSetVolumeInformation (IN PRFSD_IRP_CONTEXT IrpContext)
 

Variables

PRFSD_GLOBAL RfsdGlobal
 

Function Documentation

◆ RfsdQueryVolumeInformation()

__drv_mustHoldCriticalRegion NTSTATUS RfsdQueryVolumeInformation ( IN PRFSD_IRP_CONTEXT  IrpContext)

Definition at line 30 of file volinfo.c.

31 {
34  PRFSD_VCB Vcb = 0;
35  PIRP Irp;
36  PIO_STACK_LOCATION IoStackLocation;
38  ULONG Length;
39  PVOID Buffer;
40  BOOLEAN VcbResourceAcquired = FALSE;
41 
42  PAGED_CODE();
43 
44  _SEH2_TRY {
45 
46  ASSERT(IrpContext != NULL);
47 
48  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
49  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
50 
51  DeviceObject = IrpContext->DeviceObject;
52 
53  //
54  // This request is not allowed on the main device object
55  //
59  }
60 
62 
63  ASSERT(Vcb != NULL);
64 
65  ASSERT((Vcb->Identifier.Type == RFSDVCB) &&
66  (Vcb->Identifier.Size == sizeof(RFSD_VCB)));
67 
69 
71  &Vcb->MainResource,
72  IrpContext->IsSynchronous
73  )) {
74 
77  }
78 
79  VcbResourceAcquired = TRUE;
80 
81  Irp = IrpContext->Irp;
82 
83  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
84 
86  IoStackLocation->Parameters.QueryVolume.FsInformationClass;
87 
88  Length = IoStackLocation->Parameters.QueryVolume.Length;
89 
90  Buffer = Irp->AssociatedIrp.SystemBuffer;
91 
93 
94  switch (FsInformationClass) {
95 
97  {
99  ULONG VolumeLabelLength;
101 
102  if (Length < sizeof(FILE_FS_VOLUME_INFORMATION)) {
104  _SEH2_LEAVE;
105  }
106 
107  FsVolInfo = (PFILE_FS_VOLUME_INFORMATION) Buffer;
108 
109  FsVolInfo->VolumeCreationTime.QuadPart = 0;
110 
111  FsVolInfo->VolumeSerialNumber = Vcb->Vpb->SerialNumber;
112 
113  VolumeLabelLength = Vcb->Vpb->VolumeLabelLength;
114 
115  FsVolInfo->VolumeLabelLength = VolumeLabelLength;
116 
117  // I don't know what this means
118  FsVolInfo->SupportsObjects = FALSE;
119 
121  + VolumeLabelLength - sizeof(WCHAR);
122 
123  if (Length < RequiredLength) {
124  Irp->IoStatus.Information =
127  _SEH2_LEAVE;
128  }
129 
130  RtlCopyMemory(FsVolInfo->VolumeLabel, Vcb->Vpb->VolumeLabel, Vcb->Vpb->VolumeLabelLength);
131 
132  Irp->IoStatus.Information = RequiredLength;
134  _SEH2_LEAVE;
135  }
136 
138  {
139  PFILE_FS_SIZE_INFORMATION FsSizeInfo;
140 
141  if (Length < sizeof(FILE_FS_SIZE_INFORMATION)) {
143  _SEH2_LEAVE;
144  }
145 
146  FsSizeInfo = (PFILE_FS_SIZE_INFORMATION) Buffer;
147 
148  FsSizeInfo->TotalAllocationUnits.QuadPart =
149  Vcb->SuperBlock->s_blocks_count;
150 
151  FsSizeInfo->AvailableAllocationUnits.QuadPart =
152  Vcb->SuperBlock->s_free_blocks_count;
153 
154  FsSizeInfo->SectorsPerAllocationUnit =
155  Vcb->BlockSize / Vcb->DiskGeometry.BytesPerSector;
156 
157  FsSizeInfo->BytesPerSector =
158  Vcb->DiskGeometry.BytesPerSector;
159 
160  Irp->IoStatus.Information = sizeof(FILE_FS_SIZE_INFORMATION);
162  _SEH2_LEAVE;
163  }
164 
166  {
167  PFILE_FS_DEVICE_INFORMATION FsDevInfo;
168 
169  if (Length < sizeof(FILE_FS_DEVICE_INFORMATION)) {
171  _SEH2_LEAVE;
172  }
173 
174  FsDevInfo = (PFILE_FS_DEVICE_INFORMATION) Buffer;
175 
176  FsDevInfo->DeviceType =
177  Vcb->TargetDeviceObject->DeviceType;
178 
179  if (FsDevInfo->DeviceType != FILE_DEVICE_DISK) {
180  DbgBreak();
181  }
182 
183  FsDevInfo->Characteristics =
184  Vcb->TargetDeviceObject->Characteristics;
185 
186  if (FlagOn(Vcb->Flags, VCB_READ_ONLY)) {
187 
188  SetFlag( FsDevInfo->Characteristics,
190  }
191 
192  Irp->IoStatus.Information = sizeof(FILE_FS_DEVICE_INFORMATION);
194  _SEH2_LEAVE;
195  }
196 
198  {
201 
202  if (Length < sizeof(FILE_FS_ATTRIBUTE_INFORMATION)) {
204  _SEH2_LEAVE;
205  }
206 
207  FsAttrInfo =
209 
210  FsAttrInfo->FileSystemAttributes =
212 
214 
215  FsAttrInfo->FileSystemNameLength = 10;
216 
218  10 - sizeof(WCHAR);
219 
220  if (Length < RequiredLength) {
221  Irp->IoStatus.Information =
224  _SEH2_LEAVE;
225  }
226 
228  FsAttrInfo->FileSystemName,
229  L"RFSD\0", 10);
230 
231  Irp->IoStatus.Information = RequiredLength;
233  _SEH2_LEAVE;
234  }
235 
236 #if (_WIN32_WINNT >= 0x0500)
237 
239  {
241 
242  if (Length < sizeof(FILE_FS_FULL_SIZE_INFORMATION)) {
244  _SEH2_LEAVE;
245  }
246 
248 
249 /*
250  typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
251  LARGE_INTEGER TotalAllocationUnits;
252  LARGE_INTEGER CallerAvailableAllocationUnits;
253  LARGE_INTEGER ActualAvailableAllocationUnits;
254  ULONG SectorsPerAllocationUnit;
255  ULONG BytesPerSector;
256  } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
257 */
258 
259  {
260  PFFFSI->TotalAllocationUnits.QuadPart =
261  Vcb->SuperBlock->s_blocks_count;
262 
264  Vcb->SuperBlock->s_free_blocks_count;
265 
266  /* - Vcb->SuperBlock->s_r_blocks_count; */
267 
269  Vcb->SuperBlock->s_free_blocks_count;
270  }
271 
272  PFFFSI->SectorsPerAllocationUnit =
273  Vcb->BlockSize / Vcb->DiskGeometry.BytesPerSector;
274 
275  PFFFSI->BytesPerSector = Vcb->DiskGeometry.BytesPerSector;
276 
277  Irp->IoStatus.Information = sizeof(FILE_FS_FULL_SIZE_INFORMATION);
279  _SEH2_LEAVE;
280  }
281 
282 #endif // (_WIN32_WINNT >= 0x0500)
283 
284  default:
286  }
287 
288  } _SEH2_FINALLY {
289 
290  if (VcbResourceAcquired) {
292  &Vcb->MainResource,
294  }
295 
296  if (!IrpContext->ExceptionInProgress) {
297  if (Status == STATUS_PENDING) {
298  RfsdQueueRequest(IrpContext);
299  } else {
300  RfsdCompleteIrpContext(IrpContext, Status);
301  }
302  }
303  } _SEH2_END;
304 
305  return Status;
306 }
#define RFSD_NAME_LEN
Definition: rfsd.h:45
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:263
#define FILE_DEVICE_DISK
Definition: winioctl.h:112
struct _FILE_FS_FULL_SIZE_INFORMATION FILE_FS_FULL_SIZE_INFORMATION
#define IsMounted(Vcb)
Definition: ext2fs.h:803
NTSTATUS RfsdCompleteIrpContext(IN PRFSD_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: memory.c:160
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FS_INFORMATION_CLASS FsInformationClass
Definition: fltkernel.h:1329
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_In_ PIRP Irp
Definition: csq.h:116
#define FileFsFullSizeInformation
Definition: ntifs_ex.h:389
LONG NTSTATUS
Definition: precomp.h:26
struct _FILE_FS_FULL_SIZE_INFORMATION * PFILE_FS_FULL_SIZE_INFORMATION
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS RfsdQueueRequest(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: dispatch.c:29
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
Definition: rfsd.h:323
PRFSD_GLOBAL RfsdGlobal
Definition: init.c:17
#define PAGED_CODE()
Definition: video.h:57
PDEVICE_OBJECT DeviceObject
Definition: rfsd.h:407
_SEH2_TRY
Definition: create.c:4250
LARGE_INTEGER ActualAvailableAllocationUnits
Definition: from_kernel.h:272
LARGE_INTEGER AvailableAllocationUnits
Definition: from_kernel.h:264
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: rfsd.h:326
Definition: bufpool.h:45
enum _FSINFOCLASS FS_INFORMATION_CLASS
struct _FILE_FS_SIZE_INFORMATION * PFILE_FS_SIZE_INFORMATION
struct _FILE_FS_VOLUME_INFORMATION * PFILE_FS_VOLUME_INFORMATION
struct _RFSD_VCB * PRFSD_VCB
LARGE_INTEGER VolumeCreationTime
Definition: winioctl.h:408
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STATUS_PENDING
Definition: ntstatus.h:82
#define FILE_CASE_SENSITIVE_SEARCH
Definition: from_kernel.h:233
#define Vcb
Definition: cdprocs.h:1425
struct _FILE_FS_ATTRIBUTE_INFORMATION * PFILE_FS_ATTRIBUTE_INFORMATION
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:226
static const WCHAR L[]
Definition: oid.c:1250
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
#define FILE_CASE_PRESERVED_NAMES
Definition: from_kernel.h:234
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define VCB_READ_ONLY
Definition: ext2fs.h:795
Status
Definition: gdiplustypes.h:24
struct _FILE_FS_SIZE_INFORMATION FILE_FS_SIZE_INFORMATION
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:29
_SEH2_FINALLY
Definition: create.c:4395
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
struct _FILE_FS_DEVICE_INFORMATION * PFILE_FS_DEVICE_INFORMATION
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DbgBreak()
Definition: ext2fs.h:46
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
LARGE_INTEGER CallerAvailableAllocationUnits
Definition: from_kernel.h:271
#define FILE_READ_ONLY_DEVICE
Definition: nt_native.h:808
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:270
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by RfsdDispatchRequest().

◆ RfsdSetVolumeInformation()

__drv_mustHoldCriticalRegion NTSTATUS RfsdSetVolumeInformation ( IN PRFSD_IRP_CONTEXT  IrpContext)

Definition at line 312 of file volinfo.c.

313 {
316  PRFSD_VCB Vcb;
317  PIRP Irp;
318  PIO_STACK_LOCATION IoStackLocation;
320 
321  PAGED_CODE();
322 
323  _SEH2_TRY {
324 
325  ASSERT(IrpContext != NULL);
326 
327  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
328  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
329 
330  DeviceObject = IrpContext->DeviceObject;
331 
332  //
333  // This request is not allowed on the main device object
334  //
337  _SEH2_LEAVE;
338  }
339 
341 
342  ASSERT(Vcb != NULL);
343 
344  ASSERT((Vcb->Identifier.Type == RFSDVCB) &&
345  (Vcb->Identifier.Size == sizeof(RFSD_VCB)));
346 
347  ASSERT(IsMounted(Vcb));
348 
349  if (IsFlagOn(Vcb->Flags, VCB_READ_ONLY)) {
351  _SEH2_LEAVE;
352  }
353 
354  Irp = IrpContext->Irp;
355 
356  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
357 
358  //Notes: SetVolume is not defined in ntddk.h of win2k ddk,
359  // But it's same to QueryVolume ....
361  IoStackLocation->Parameters./*SetVolume*/QueryVolume.FsInformationClass;
362 
363  switch (FsInformationClass) {
364 #if 0
366  {
367  PFILE_FS_LABEL_INFORMATION VolLabelInfo = NULL;
368  ULONG VolLabelLen;
369  UNICODE_STRING LabelName ;
370 
372 
373  VolLabelInfo = (PFILE_FS_LABEL_INFORMATION) Irp->AssociatedIrp.SystemBuffer;
374 
375  VolLabelLen = VolLabelInfo->VolumeLabelLength;
376 
377  if(VolLabelLen > (16 * sizeof(WCHAR))) {
379  _SEH2_LEAVE;
380  }
381 
382  RtlCopyMemory( Vcb->Vpb->VolumeLabel,
383  VolLabelInfo->VolumeLabel,
384  VolLabelLen );
385 
386  RtlZeroMemory(Vcb->SuperBlock->s_volume_name, 16);
387 
388  LabelName.Buffer = VolLabelInfo->VolumeLabel;
389  LabelName.MaximumLength = (USHORT)16 * sizeof(WCHAR);
390  LabelName.Length = (USHORT)VolLabelLen;
391 
392  OemName.Buffer = SUPER_BLOCK->s_volume_name;
393  OemName.Length = 0;
394  OemName.MaximumLength = 16;
395 
397  &LabelName);
398 
399  Vcb->Vpb->VolumeLabelLength =
400  (USHORT) VolLabelLen;
401 
402  if (RfsdSaveSuper(IrpContext, Vcb)) {
404  }
405 
406  Irp->IoStatus.Information = 0;
407 
408  }
409  break;
410 #endif // 0
411  default:
413  }
414 
415  } _SEH2_FINALLY {
416 
417  if (!IrpContext->ExceptionInProgress) {
418  if (Status == STATUS_PENDING) {
419  RfsdQueueRequest(IrpContext);
420  } else {
421  RfsdCompleteIrpContext(IrpContext, Status);
422  }
423  }
424  } _SEH2_END;
425 
426  return Status;
427 }
NTSTATUS RfsdUnicodeToOEM(IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:246
#define IsMounted(Vcb)
Definition: ext2fs.h:803
NTSTATUS RfsdCompleteIrpContext(IN PRFSD_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: memory.c:160
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FS_INFORMATION_CLASS FsInformationClass
Definition: fltkernel.h:1329
struct _FILE_FS_LABEL_INFORMATION * PFILE_FS_LABEL_INFORMATION
USHORT MaximumLength
Definition: env_spec_w32.h:370
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS RfsdQueueRequest(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: dispatch.c:29
#define STATUS_INVALID_VOLUME_LABEL
Definition: udferr_usr.h:156
STRING OEM_STRING
Definition: umtypes.h:203
Definition: rfsd.h:323
PRFSD_GLOBAL RfsdGlobal
Definition: init.c:17
#define PAGED_CODE()
Definition: video.h:57
PDEVICE_OBJECT DeviceObject
Definition: rfsd.h:407
_SEH2_TRY
Definition: create.c:4250
BOOLEAN RfsdSaveSuper(IN PRFSD_IRP_CONTEXT IrpContext, IN PRFSD_VCB Vcb)
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
Definition: rfsd.h:326
#define SUPER_BLOCK
Definition: ext2fs.h:90
enum _FSINFOCLASS FS_INFORMATION_CLASS
struct _RFSD_VCB * PRFSD_VCB
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:226
#define VCB_READ_ONLY
Definition: ext2fs.h:795
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define _SEH2_LEAVE
Definition: filesup.c:20
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1294
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by RfsdDispatchRequest().

Variable Documentation

◆ RfsdGlobal

PRFSD_GLOBAL RfsdGlobal

Definition at line 17 of file init.c.

Referenced by RfsdQueryVolumeInformation(), and RfsdSetVolumeInformation().