ReactOS  0.4.13-dev-544-gede3fdd
volinfo.c File Reference
#include "cdprocs.h"
Include dependency graph for volinfo.c:

Go to the source code of this file.

Macros

#define BugCheckFileId   (CDFS_BUG_CHECK_VOLINFO)
 

Functions

 _Requires_lock_held_ (_Global_critical_region_)
 
NTSTATUS CdQueryFsSizeInfo (_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_SIZE_INFORMATION Buffer, _Inout_ PULONG Length)
 
NTSTATUS CdQueryFsDeviceInfo (_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_DEVICE_INFORMATION Buffer, _Inout_ PULONG Length)
 
NTSTATUS CdQueryFsAttributeInfo (_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_ATTRIBUTE_INFORMATION Buffer, _Inout_ PULONG Length)
 
NTSTATUS CdQueryFsSectorSizeInfo (_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_writes_bytes_(*Length) PFILE_FS_SECTOR_SIZE_INFORMATION Buffer, _Inout_ PULONG Length)
 

Macro Definition Documentation

◆ BugCheckFileId

#define BugCheckFileId   (CDFS_BUG_CHECK_VOLINFO)

Definition at line 23 of file volinfo.c.

Function Documentation

◆ _Requires_lock_held_()

_Requires_lock_held_ ( _Global_critical_region_  )

Definition at line 29 of file volinfo.c.

108 {
111 
112  ULONG Length;
113 
115  PFCB Fcb;
116  PCCB Ccb;
117 
118  PAGED_CODE();
119 
120  //
121  // Reference our input parameters to make things easier
122  //
123 
124  Length = IrpSp->Parameters.QueryVolume.Length;
125 
126  //
127  // Decode the file object and fail if this an unopened file object.
128  //
129 
130  TypeOfOpen = CdDecodeFileObject( IrpContext, IrpSp->FileObject, &Fcb, &Ccb );
131 
133 
136  }
137 
138  //
139  // Acquire the Vcb for this volume.
140  //
141 
142  CdAcquireVcbShared( IrpContext, Fcb->Vcb, FALSE );
143 
144  //
145  // Use a try-finally to facilitate cleanup.
146  //
147 
148  _SEH2_TRY {
149 
150  //
151  // Verify the Vcb.
152  //
153 
154  CdVerifyVcb( IrpContext, Fcb->Vcb );
155 
156  //
157  // Based on the information class we'll do different actions. Each
158  // of the procedures that we're calling fills up the output buffer
159  // if possible and returns true if it successfully filled the buffer
160  // and false if it couldn't wait for any I/O to complete.
161  //
162 
163  switch (IrpSp->Parameters.QueryVolume.FsInformationClass) {
164 
166 
167  Status = CdQueryFsSizeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
168  break;
169 
171 
172  Status = CdQueryFsVolumeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
173  break;
174 
176 
177  Status = CdQueryFsDeviceInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
178  break;
179 
181 
182  Status = CdQueryFsAttributeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
183  break;
184 
185 #if (NTDDI_VERSION >= NTDDI_WIN8)
186  case FileFsSectorSizeInformation:
187 
188  Status = CdQueryFsSectorSizeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
189  break;
190 #endif
191 
192  /* ReactOS Change: GCC "enumeration value not handled in switch" */
193  default: break;
194  }
195 
196  //
197  // Set the information field to the number of bytes actually filled in
198  //
199 
200  Irp->IoStatus.Information = IrpSp->Parameters.QueryVolume.Length - Length;
201 
202  } _SEH2_FINALLY {
203 
204  //
205  // Release the Vcb.
206  //
207 
208  CdReleaseVcb( IrpContext, Fcb->Vcb );
209  } _SEH2_END;
210 
211  //
212  // Complete the request if we didn't raise.
213  //
214 
215  CdCompleteRequest( IrpContext, Irp, Status );
216 
217  return Status;
218 }
#define CdAcquireVcbShared(IC, V, I)
Definition: cdprocs.h:987
NTSTATUS CdQueryFsSizeInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_SIZE_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: volinfo.c:319
_In_ PIRP Irp
Definition: csq.h:116
Definition: cdstruc.h:908
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
Definition: cdstruc.h:1073
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
Definition: cdprocs.h:593
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
NTSTATUS CdQueryFsAttributeInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_ATTRIBUTE_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: volinfo.c:446
#define CdReleaseVcb(IC, V)
Definition: cdprocs.h:990
NTSTATUS CdQueryFsDeviceInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_DEVICE_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: volinfo.c:382
NTSTATUS CdQueryFsSectorSizeInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_writes_bytes_(*Length) PFILE_FS_SECTOR_SIZE_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: volinfo.c:545
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
enum _TYPE_OF_OPEN TYPE_OF_OPEN
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
Status
Definition: gdiplustypes.h:24
VOID CdVerifyVcb(_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb)
Definition: verfysup.c:411
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
_SEH2_END
Definition: create.c:4424
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
PVCB Vcb
Definition: cdstruc.h:939
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
_In_ PFCB Fcb
Definition: cdprocs.h:151

◆ CdQueryFsAttributeInfo()

NTSTATUS CdQueryFsAttributeInfo ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PVCB  Vcb,
_Out_ PFILE_FS_ATTRIBUTE_INFORMATION  Buffer,
_Inout_ PULONG  Length 
)

Definition at line 446 of file volinfo.c.

475 {
477 
479 
480  PAGED_CODE();
481 
483 
484  //
485  // Fill out the fixed portion of the buffer.
486  //
487 
488  Buffer->FileSystemAttributes = FILE_CASE_SENSITIVE_SEARCH |
491 
492  if (FlagOn( IrpContext->Vcb->VcbState, VCB_STATE_JOLIET )) {
493 
494  SetFlag( Buffer->FileSystemAttributes, FILE_UNICODE_ON_DISK );
495 
496  Buffer->MaximumComponentNameLength = 110;
497 
498  } else {
499 
500  Buffer->MaximumComponentNameLength = 221;
501  }
502 
503  *Length -= FIELD_OFFSET( FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName );
504 
505  //
506  // Make sure we can copy full unicode characters.
507  //
508 
509  ClearFlag( *Length, 1 );
510 
511  //
512  // Determine how much of the file system name will fit.
513  //
514 
515  if (*Length >= 8) {
516 
517  BytesToCopy = 8;
518 
519  } else {
520 
521  BytesToCopy = *Length;
523  }
524 
525  *Length -= BytesToCopy;
526 
527  //
528  // Do the file system name.
529  //
530 
531  Buffer->FileSystemNameLength = BytesToCopy;
532 
533  RtlCopyMemory( &Buffer->FileSystemName[0], L"CDFS", BytesToCopy );
534 
535  //
536  // And return to our caller
537  //
538 
539  return Status;
540 }
#define VCB_STATE_JOLIET
Definition: cdstruc.h:714
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3167
Definition: bufpool.h:45
#define FILE_UNICODE_ON_DISK
Definition: from_kernel.h:235
#define FILE_CASE_SENSITIVE_SEARCH
Definition: from_kernel.h:233
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define FILE_SUPPORTS_OPEN_BY_FILE_ID
Definition: from_kernel.h:251
static const WCHAR L[]
Definition: oid.c:1250
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
#define FILE_READ_ONLY_VOLUME
Definition: from_kernel.h:246
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ CdQueryFsDeviceInfo()

NTSTATUS CdQueryFsDeviceInfo ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PVCB  Vcb,
_Out_ PFILE_FS_DEVICE_INFORMATION  Buffer,
_Inout_ PULONG  Length 
)

Definition at line 382 of file volinfo.c.

411 {
412  PAGED_CODE();
413 
414  UNREFERENCED_PARAMETER( IrpContext );
415 
416  //
417  // Update the output buffer.
418  //
419 
420  Buffer->Characteristics = Vcb->TargetDeviceObject->Characteristics;
421 #ifndef __REACTOS__
422  Buffer->DeviceType = FILE_DEVICE_CD_ROM;
423 #else
424  Buffer->DeviceType = Vcb->TargetDeviceObject->DeviceType;
425 #endif
426 
427  //
428  // Adjust the length variable
429  //
430 
431  *Length -= sizeof( FILE_FS_DEVICE_INFORMATION );
432 
433  //
434  // And return success to our caller
435  //
436 
437  return STATUS_SUCCESS;
438 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
#define FILE_DEVICE_CD_ROM
Definition: winioctl.h:107
Definition: bufpool.h:45
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ CdQueryFsSectorSizeInfo()

NTSTATUS CdQueryFsSectorSizeInfo ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PVCB  Vcb,
_Out_writes_bytes_ *Length PFILE_FS_SECTOR_SIZE_INFORMATION  Buffer,
_Inout_ PULONG  Length 
)

Definition at line 545 of file volinfo.c.

575 {
577 
578  PAGED_CODE();
579  UNREFERENCED_PARAMETER( IrpContext );
580 
581  //
582  // Sufficient buffer size is guaranteed by the I/O manager or the
583  // originating kernel mode driver.
584  //
585 
586  ASSERT( *Length >= sizeof( FILE_FS_SECTOR_SIZE_INFORMATION ));
587  _Analysis_assume_( *Length >= sizeof( FILE_FS_SECTOR_SIZE_INFORMATION ));
588 
589  //
590  // Retrieve the sector size information
591  //
592 
593  Status = FsRtlGetSectorSizeInformation( Vcb->Vpb->RealDevice,
594  Buffer );
595 
596  //
597  // Adjust the length variable
598  //
599 
600  if (NT_SUCCESS( Status )) {
601 
602  *Length -= sizeof( FILE_FS_SECTOR_SIZE_INFORMATION );
603  }
604 
605  return Status;
606 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
#define _Analysis_assume_(expr)
Definition: no_sal2.h:10

◆ CdQueryFsSizeInfo()

NTSTATUS CdQueryFsSizeInfo ( _In_ PIRP_CONTEXT  IrpContext,
_In_ PVCB  Vcb,
_Out_ PFILE_FS_SIZE_INFORMATION  Buffer,
_Inout_ PULONG  Length 
)

Definition at line 319 of file volinfo.c.

348 {
349  PAGED_CODE();
350 
351  UNREFERENCED_PARAMETER( IrpContext );
352 
353  //
354  // Fill in the output buffer.
355  //
356 
357  Buffer->TotalAllocationUnits.QuadPart = LlSectorsFromBytes( Vcb->VolumeDasdFcb->AllocationSize.QuadPart );
358 
359  Buffer->AvailableAllocationUnits.QuadPart = 0;
360  Buffer->SectorsPerAllocationUnit = 1;
361  Buffer->BytesPerSector = SECTOR_SIZE;
362 
363  //
364  // Adjust the length variable
365  //
366 
367  *Length -= sizeof( FILE_FS_SIZE_INFORMATION );
368 
369  //
370  // And return success to our caller
371  //
372 
373  return STATUS_SUCCESS;
374 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PAGED_CODE()
Definition: video.h:57
#define LlSectorsFromBytes(L)
Definition: cdprocs.h:1628
#define SECTOR_SIZE
Definition: winldr.h:34
Definition: bufpool.h:45
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct _FILE_FS_SIZE_INFORMATION FILE_FS_SIZE_INFORMATION
return STATUS_SUCCESS
Definition: btrfs.c:2777