ReactOS  0.4.13-dev-482-ge57f103
volinfo.c File Reference
#include "ntifs.h"
#include "ffsdrv.h"
Include dependency graph for volinfo.c:

Go to the source code of this file.

Functions

__drv_mustHoldCriticalRegion NTSTATUS FFSQueryVolumeInformation (IN PFFS_IRP_CONTEXT IrpContext)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSSetVolumeInformation (IN PFFS_IRP_CONTEXT IrpContext)
 

Variables

PFFS_GLOBAL FFSGlobal
 

Function Documentation

◆ FFSQueryVolumeInformation()

__drv_mustHoldCriticalRegion NTSTATUS FFSQueryVolumeInformation ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 32 of file volinfo.c.

34 {
37  PFFS_VCB Vcb = 0;
38  PIRP Irp;
39  PIO_STACK_LOCATION IoStackLocation;
41  ULONG Length;
42  PVOID Buffer;
43  BOOLEAN VcbResourceAcquired = FALSE;
44 
45  PAGED_CODE();
46 
47  _SEH2_TRY
48  {
49  ASSERT(IrpContext != NULL);
50 
51  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
52  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
53 
54  DeviceObject = IrpContext->DeviceObject;
55 
56  //
57  // This request is not allowed on the main device object
58  //
60  {
63  }
64 
66 
67  ASSERT(Vcb != NULL);
68 
69  ASSERT((Vcb->Identifier.Type == FFSVCB) &&
70  (Vcb->Identifier.Size == sizeof(FFS_VCB)));
71 
73 
75  &Vcb->MainResource,
76  IrpContext->IsSynchronous))
77  {
80  }
81 
82  VcbResourceAcquired = TRUE;
83 
84  Irp = IrpContext->Irp;
85 
86  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
87 
89  IoStackLocation->Parameters.QueryVolume.FsInformationClass;
90 
91  Length = IoStackLocation->Parameters.QueryVolume.Length;
92 
93  Buffer = Irp->AssociatedIrp.SystemBuffer;
94 
96 
97  switch (FsInformationClass)
98  {
100  {
101  PFILE_FS_VOLUME_INFORMATION FsVolInfo;
102  ULONG VolumeLabelLength;
104 
105  if (Length < sizeof(FILE_FS_VOLUME_INFORMATION))
106  {
108  _SEH2_LEAVE;
109  }
110 
111  FsVolInfo = (PFILE_FS_VOLUME_INFORMATION)Buffer;
112 
113  FsVolInfo->VolumeCreationTime.QuadPart = 0;
114 
115  FsVolInfo->VolumeSerialNumber = Vcb->Vpb->SerialNumber;
116 
117  VolumeLabelLength = Vcb->Vpb->VolumeLabelLength;
118 
119  FsVolInfo->VolumeLabelLength = VolumeLabelLength;
120 
121  // I don't know what this means
122  FsVolInfo->SupportsObjects = FALSE;
123 
125  + VolumeLabelLength - sizeof(WCHAR);
126 
127  if (Length < RequiredLength)
128  {
129  Irp->IoStatus.Information =
132  _SEH2_LEAVE;
133  }
134 
135  RtlCopyMemory(FsVolInfo->VolumeLabel, Vcb->Vpb->VolumeLabel, Vcb->Vpb->VolumeLabelLength);
136 
137  Irp->IoStatus.Information = RequiredLength;
139  _SEH2_LEAVE;
140  }
141 
143  {
144  PFILE_FS_SIZE_INFORMATION FsSizeInfo;
145 
146  if (Length < sizeof(FILE_FS_SIZE_INFORMATION))
147  {
149  _SEH2_LEAVE;
150  }
151 
152  FsSizeInfo = (PFILE_FS_SIZE_INFORMATION)Buffer;
153 
154  {
155  if (FS_VERSION == 1)
156  {
157  FsSizeInfo->TotalAllocationUnits.QuadPart =
158  (Vcb->ffs_super_block->fs_old_size / 8);
159 
160  FsSizeInfo->AvailableAllocationUnits.QuadPart =
161  (Vcb->ffs_super_block->fs_old_cstotal.cs_nbfree / 8);
162  }
163  else
164  {
165  FsSizeInfo->TotalAllocationUnits.QuadPart =
166  (Vcb->ffs_super_block->fs_size / 8);
167 
168  FsSizeInfo->AvailableAllocationUnits.QuadPart =
169  (Vcb->ffs_super_block->fs_cstotal.cs_nbfree / 8);
170  }
171  }
172 
173  FsSizeInfo->SectorsPerAllocationUnit =
174  Vcb->BlockSize / Vcb->DiskGeometry.BytesPerSector;
175 
176  FsSizeInfo->BytesPerSector =
177  Vcb->DiskGeometry.BytesPerSector;
178 
179  Irp->IoStatus.Information = sizeof(FILE_FS_SIZE_INFORMATION);
181  _SEH2_LEAVE;
182  }
183 
185  {
186  PFILE_FS_DEVICE_INFORMATION FsDevInfo;
187 
188  if (Length < sizeof(FILE_FS_DEVICE_INFORMATION))
189  {
191  _SEH2_LEAVE;
192  }
193 
194  FsDevInfo = (PFILE_FS_DEVICE_INFORMATION)Buffer;
195 
196  FsDevInfo->DeviceType =
197  Vcb->TargetDeviceObject->DeviceType;
198 
199  FsDevInfo->Characteristics =
200  Vcb->TargetDeviceObject->Characteristics;
201 
202  if (FlagOn(Vcb->Flags, VCB_READ_ONLY))
203  {
204  SetFlag(FsDevInfo->Characteristics,
206  }
207 
208  Irp->IoStatus.Information = sizeof(FILE_FS_DEVICE_INFORMATION);
210  _SEH2_LEAVE;
211  }
212 
214  {
217 
219  {
221  _SEH2_LEAVE;
222  }
223 
224  FsAttrInfo =
226 
227  FsAttrInfo->FileSystemAttributes =
229 
231 
232  FsAttrInfo->FileSystemNameLength = 10;
233 
235  10 - sizeof(WCHAR);
236 
237  if (Length < RequiredLength)
238  {
239  Irp->IoStatus.Information =
242  _SEH2_LEAVE;
243  }
244 
246  FsAttrInfo->FileSystemName,
247  L"FFS\0", 8);
248 
249  Irp->IoStatus.Information = RequiredLength;
251  _SEH2_LEAVE;
252  }
253 
254 #if (_WIN32_WINNT >= 0x0500)
255 
257  {
259 
261  {
263  _SEH2_LEAVE;
264  }
265 
267 
268  /*
269  typedef struct _FILE_FS_FULL_SIZE_INFORMATION {
270  LARGE_INTEGER TotalAllocationUnits;
271  LARGE_INTEGER CallerAvailableAllocationUnits;
272  LARGE_INTEGER ActualAvailableAllocationUnits;
273  ULONG SectorsPerAllocationUnit;
274  ULONG BytesPerSector;
275  } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
276  */
277 
278  {
279  if (FS_VERSION == 1)
280  {
282  (Vcb->ffs_super_block->fs_old_size / 8);
283 
285  (Vcb->ffs_super_block->fs_old_cstotal.cs_nbfree / 8);
286 
288  (Vcb->ffs_super_block->fs_old_cstotal.cs_nbfree / 8);
289  }
290  else
291  {
293  (Vcb->ffs_super_block->fs_size / 8);
294 
296  (Vcb->ffs_super_block->fs_cstotal.cs_nbfree / 8);
297 
299  (Vcb->ffs_super_block->fs_cstotal.cs_nbfree / 8);
300  }
301  }
302 
303  PFFFSI->SectorsPerAllocationUnit =
304  Vcb->BlockSize / Vcb->DiskGeometry.BytesPerSector;
305 
306  PFFFSI->BytesPerSector = Vcb->DiskGeometry.BytesPerSector;
307 
308  Irp->IoStatus.Information = sizeof(FILE_FS_FULL_SIZE_INFORMATION);
310  _SEH2_LEAVE;
311  }
312 
313 #endif // (_WIN32_WINNT >= 0x0500)
314 
315  default:
317  }
318  }
319 
321  {
322  if (VcbResourceAcquired)
323  {
325  &Vcb->MainResource,
327  }
328 
329  if (!IrpContext->ExceptionInProgress)
330  {
331  if (Status == STATUS_PENDING)
332  {
333  FFSQueueRequest(IrpContext);
334  }
335  else
336  {
337  FFSCompleteIrpContext(IrpContext, Status);
338  }
339  }
340  } _SEH2_END;
341 
342  return Status;
343 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
NTSTATUS FFSQueueRequest(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dispatch.c:33
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:263
struct _FILE_FS_FULL_SIZE_INFORMATION FILE_FS_FULL_SIZE_INFORMATION
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#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
#define FS_VERSION
Definition: ffsdrv.h:81
#define FFS_NAME_LEN
Definition: ffsdrv.h:202
_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
Definition: ffsdrv.h:283
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
PDEVICE_OBJECT DeviceObject
Definition: ffsdrv.h:371
#define PAGED_CODE()
Definition: video.h:57
_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: bufpool.h:45
struct _FFS_VCB * PFFS_VCB
enum _FSINFOCLASS FS_INFORMATION_CLASS
struct _FILE_FS_SIZE_INFORMATION * PFILE_FS_SIZE_INFORMATION
struct _FILE_FS_VOLUME_INFORMATION * PFILE_FS_VOLUME_INFORMATION
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
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
#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
Definition: ffsdrv.h:280
#define FILE_CASE_PRESERVED_NAMES
Definition: from_kernel.h:234
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
#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:61
_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
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:2771
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777
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 FFSDispatchRequest().

◆ FFSSetVolumeInformation()

__drv_mustHoldCriticalRegion NTSTATUS FFSSetVolumeInformation ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 349 of file volinfo.c.

351 {
354  PFFS_VCB Vcb;
355  PIRP Irp;
356  PIO_STACK_LOCATION IoStackLocation;
358 
359  PAGED_CODE();
360 
361  _SEH2_TRY
362  {
363  ASSERT(IrpContext != NULL);
364 
365  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
366  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
367 
368  DeviceObject = IrpContext->DeviceObject;
369 
370  //
371  // This request is not allowed on the main device object
372  //
374  {
376  _SEH2_LEAVE;
377  }
378 
380 
381  ASSERT(Vcb != NULL);
382 
383  ASSERT((Vcb->Identifier.Type == FFSVCB) &&
384  (Vcb->Identifier.Size == sizeof(FFS_VCB)));
385 
386  ASSERT(IsMounted(Vcb));
387 
388  if (IsFlagOn(Vcb->Flags, VCB_READ_ONLY))
389  {
391  _SEH2_LEAVE;
392  }
393 
394  Irp = IrpContext->Irp;
395 
396  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
397 
398  //Notes: SetVolume is not defined in ntddk.h of win2k ddk,
399  // But it's same to QueryVolume ....
401  IoStackLocation->Parameters./*SetVolume*/QueryVolume.FsInformationClass;
402 
403  switch (FsInformationClass)
404  {
406  {
407  PFILE_FS_LABEL_INFORMATION VolLabelInfo = NULL;
408  ULONG VolLabelLen;
409  UNICODE_STRING LabelName ;
410 
412 
413  VolLabelInfo = (PFILE_FS_LABEL_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
414 
415  VolLabelLen = VolLabelInfo->VolumeLabelLength;
416 
417  if(VolLabelLen > (16 * sizeof(WCHAR)))
418  {
420  _SEH2_LEAVE;
421  }
422 
423  RtlCopyMemory(Vcb->Vpb->VolumeLabel,
424  VolLabelInfo->VolumeLabel,
425  VolLabelLen);
426 
427  RtlZeroMemory(Vcb->ffs_super_block->fs_volname, 16);
428 
429  LabelName.Buffer = VolLabelInfo->VolumeLabel;
430  LabelName.MaximumLength = (USHORT)16 * sizeof(WCHAR);
431  LabelName.Length = (USHORT)VolLabelLen;
432 
433  OemName.Buffer = SUPER_BLOCK->fs_volname;
434  OemName.Length = 0;
435  OemName.MaximumLength = 16;
436 
438  &LabelName);
439 
440  Vcb->Vpb->VolumeLabelLength =
441  (USHORT)VolLabelLen;
442 
443  if (FFSSaveSuper(IrpContext, Vcb))
444  {
446  }
447 
448  Irp->IoStatus.Information = 0;
449 
450  }
451  break;
452 
453  default:
455  }
456  }
457 
459  {
460 
461  if (!IrpContext->ExceptionInProgress)
462  {
463  if (Status == STATUS_PENDING)
464  {
465  FFSQueueRequest(IrpContext);
466  }
467  else
468  {
469  FFSCompleteIrpContext(IrpContext, Status);
470  }
471  }
472  } _SEH2_END;
473 
474  return Status;
475 
476 }
NTSTATUS FFSQueueRequest(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dispatch.c:33
#define IsMounted(Vcb)
Definition: ext2fs.h:803
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
Definition: ffsdrv.h:283
#define STATUS_INVALID_VOLUME_LABEL
Definition: udferr_usr.h:156
STRING OEM_STRING
Definition: umtypes.h:203
PDEVICE_OBJECT DeviceObject
Definition: ffsdrv.h:371
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
NTSTATUS FFSUnicodeToOEM(IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:106
#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
struct _FFS_VCB * PFFS_VCB
#define SUPER_BLOCK
Definition: ext2fs.h:90
enum _FSINFOCLASS FS_INFORMATION_CLASS
__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
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:226
Definition: ffsdrv.h:280
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
#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
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveSuper(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
Definition: ffs.c:112
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:2771
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by FFSDispatchRequest().

Variable Documentation

◆ FFSGlobal

PFFS_GLOBAL FFSGlobal

Definition at line 22 of file init.c.

Referenced by FFSQueryVolumeInformation(), and FFSSetVolumeInformation().