ReactOS 0.4.15-dev-7924-g5949c20
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
113
115 PFCB Fcb;
116 PCCB Ccb;
117
118 PAGED_CODE();
119
120 //
121 // Reference our input parameters to make things easier
122 //
123
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#ifdef __REACTOS__
164 RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, Length);
165#endif // __REACTOS__
166
167 switch (IrpSp->Parameters.QueryVolume.FsInformationClass) {
168
170
171 Status = CdQueryFsSizeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
172 break;
173
175
176 Status = CdQueryFsVolumeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
177 break;
178
180
181 Status = CdQueryFsDeviceInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
182 break;
183
185
186 Status = CdQueryFsAttributeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
187 break;
188
189#if (NTDDI_VERSION >= NTDDI_WIN8)
190 case FileFsSectorSizeInformation:
191
192 Status = CdQueryFsSectorSizeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
193 break;
194#endif
195
196 /* ReactOS Change: GCC "enumeration value not handled in switch" */
197 default: break;
198 }
199
200 //
201 // Set the information field to the number of bytes actually filled in
202 //
203
204 Irp->IoStatus.Information = IrpSp->Parameters.QueryVolume.Length - Length;
205
206 } _SEH2_FINALLY {
207
208 //
209 // Release the Vcb.
210 //
211
212 CdReleaseVcb( IrpContext, Fcb->Vcb );
213 } _SEH2_END;
214
215 //
216 // Complete the request if we didn't raise.
217 //
218
219 CdCompleteRequest( IrpContext, Irp, Status );
220
221 return Status;
222}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
NTSTATUS CdQueryFsSizeInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_SIZE_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: volinfo.c:323
NTSTATUS CdQueryFsAttributeInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_ATTRIBUTE_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: volinfo.c:450
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:549
NTSTATUS CdQueryFsDeviceInfo(_In_ PIRP_CONTEXT IrpContext, _In_ PVCB Vcb, _Out_ PFILE_FS_DEVICE_INFORMATION Buffer, _Inout_ PULONG Length)
Definition: volinfo.c:386
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN TypeOfOpen
Definition: cdprocs.h:589
#define CdReleaseVcb(IC, V)
Definition: cdprocs.h:985
VOID CdVerifyVcb(_In_ PIRP_CONTEXT IrpContext, _Inout_ PVCB Vcb)
Definition: verfysup.c:411
@ UnopenedFileObject
Definition: cdprocs.h:573
#define CdAcquireVcbShared(IC, V, I)
Definition: cdprocs.h:982
_In_ PFCB Fcb
Definition: cdprocs.h:159
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
enum _TYPE_OF_OPEN TYPE_OF_OPEN
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
@ FileFsDeviceInformation
Definition: from_kernel.h:222
@ FileFsAttributeInformation
Definition: from_kernel.h:223
@ FileFsVolumeInformation
Definition: from_kernel.h:219
@ FileFsSizeInformation
Definition: from_kernel.h:221
Status
Definition: gdiplustypes.h:25
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
Definition: cdstruc.h:1067
Definition: cdstruc.h:902
PVCB Vcb
Definition: cdstruc.h:933
struct _IO_STACK_LOCATION::@3978::@3991 QueryVolume
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
union _IO_STACK_LOCATION::@1564 Parameters
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

◆ CdQueryFsAttributeInfo()

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

Definition at line 450 of file volinfo.c.

479{
481
483
484 PAGED_CODE();
485
487
488 //
489 // Fill out the fixed portion of the buffer.
490 //
491
492 Buffer->FileSystemAttributes = FILE_CASE_SENSITIVE_SEARCH |
495
496 if (FlagOn( IrpContext->Vcb->VcbState, VCB_STATE_JOLIET )) {
497
498 SetFlag( Buffer->FileSystemAttributes, FILE_UNICODE_ON_DISK );
499
500 Buffer->MaximumComponentNameLength = 110;
501
502 } else {
503
504 Buffer->MaximumComponentNameLength = 221;
505 }
506
508
509 //
510 // Make sure we can copy full unicode characters.
511 //
512
513 ClearFlag( *Length, 1 );
514
515 //
516 // Determine how much of the file system name will fit.
517 //
518
519 if (*Length >= 8) {
520
521 BytesToCopy = 8;
522
523 } else {
524
527 }
528
530
531 //
532 // Do the file system name.
533 //
534
535 Buffer->FileSystemNameLength = BytesToCopy;
536
537 RtlCopyMemory( &Buffer->FileSystemName[0], L"CDFS", BytesToCopy );
538
539 //
540 // And return to our caller
541 //
542
543 return Status;
544}
#define VCB_STATE_JOLIET
Definition: cdstruc.h:708
Definition: bufpool.h:45
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FILE_READ_ONLY_VOLUME
Definition: from_kernel.h:246
#define FILE_CASE_SENSITIVE_SEARCH
Definition: from_kernel.h:233
#define FILE_SUPPORTS_OPEN_BY_FILE_ID
Definition: from_kernel.h:251
#define FILE_UNICODE_ON_DISK
Definition: from_kernel.h:235
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3168
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define Vcb
Definition: cdprocs.h:1415
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

◆ CdQueryFsDeviceInfo()

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

Definition at line 386 of file volinfo.c.

415{
416 PAGED_CODE();
417
418 UNREFERENCED_PARAMETER( IrpContext );
419
420 //
421 // Update the output buffer.
422 //
423
424 Buffer->Characteristics = Vcb->TargetDeviceObject->Characteristics;
425#ifndef __REACTOS__
426 Buffer->DeviceType = FILE_DEVICE_CD_ROM;
427#else
428 Buffer->DeviceType = Vcb->TargetDeviceObject->DeviceType;
429#endif
430
431 //
432 // Adjust the length variable
433 //
434
436
437 //
438 // And return success to our caller
439 //
440
441 return STATUS_SUCCESS;
442}
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
#define FILE_DEVICE_CD_ROM
Definition: winioctl.h:108

◆ 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 549 of file volinfo.c.

579{
581
582 PAGED_CODE();
583 UNREFERENCED_PARAMETER( IrpContext );
584
585 //
586 // Sufficient buffer size is guaranteed by the I/O manager or the
587 // originating kernel mode driver.
588 //
589
590 ASSERT( *Length >= sizeof( FILE_FS_SECTOR_SIZE_INFORMATION ));
591 _Analysis_assume_( *Length >= sizeof( FILE_FS_SECTOR_SIZE_INFORMATION ));
592
593 //
594 // Retrieve the sector size information
595 //
596
597 Status = FsRtlGetSectorSizeInformation( Vcb->Vpb->RealDevice,
598 Buffer );
599
600 //
601 // Adjust the length variable
602 //
603
604 if (NT_SUCCESS( Status )) {
605
606 *Length -= sizeof( FILE_FS_SECTOR_SIZE_INFORMATION );
607 }
608
609 return Status;
610}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ASSERT(a)
Definition: mode.c:44
#define _Analysis_assume_(expr)
Definition: ms_sal.h:2901

◆ CdQueryFsSizeInfo()

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

Definition at line 323 of file volinfo.c.

352{
353 PAGED_CODE();
354
355 UNREFERENCED_PARAMETER( IrpContext );
356
357 //
358 // Fill in the output buffer.
359 //
360
361 Buffer->TotalAllocationUnits.QuadPart = LlSectorsFromBytes( Vcb->VolumeDasdFcb->AllocationSize.QuadPart );
362
363 Buffer->AvailableAllocationUnits.QuadPart = 0;
364 Buffer->SectorsPerAllocationUnit = 1;
365 Buffer->BytesPerSector = SECTOR_SIZE;
366
367 //
368 // Adjust the length variable
369 //
370
371 *Length -= sizeof( FILE_FS_SIZE_INFORMATION );
372
373 //
374 // And return success to our caller
375 //
376
377 return STATUS_SUCCESS;
378}
#define SECTOR_SIZE
Definition: fs.h:22
#define LlSectorsFromBytes(L)
Definition: cdprocs.h:1618
struct _FILE_FS_SIZE_INFORMATION FILE_FS_SIZE_INFORMATION