3 Copyright (c) 1989-2000 Microsoft Corporation
11 This module implements the volume information routines for Cdfs called by
20 // The Bug check file id for this module
23 #define BugCheckFileId (CDFS_BUG_CHECK_VOLINFO)
26 // Local support routines
31 IN PIRP_CONTEXT IrpContext
,
33 IN PFILE_FS_VOLUME_INFORMATION Buffer
,
39 IN PIRP_CONTEXT IrpContext
,
41 IN PFILE_FS_SIZE_INFORMATION Buffer
,
47 IN PIRP_CONTEXT IrpContext
,
49 IN PFILE_FS_DEVICE_INFORMATION Buffer
,
54 CdQueryFsAttributeInfo (
55 IN PIRP_CONTEXT IrpContext
,
57 IN PFILE_FS_ATTRIBUTE_INFORMATION Buffer
,
62 #pragma alloc_text(PAGE, CdCommonQueryVolInfo)
63 #pragma alloc_text(PAGE, CdQueryFsAttributeInfo)
64 #pragma alloc_text(PAGE, CdQueryFsDeviceInfo)
65 #pragma alloc_text(PAGE, CdQueryFsSizeInfo)
66 #pragma alloc_text(PAGE, CdQueryFsVolumeInfo)
71 CdCommonQueryVolInfo (
72 IN PIRP_CONTEXT IrpContext
,
80 This is the common routine for querying volume information called by both
81 the fsd and fsp threads.
85 Irp - Supplies the Irp being processed
89 NTSTATUS - The return status for the operation
94 NTSTATUS Status
= STATUS_INVALID_PARAMETER
;
95 PIO_STACK_LOCATION IrpSp
= IoGetCurrentIrpStackLocation( Irp
);
99 TYPE_OF_OPEN TypeOfOpen
;
106 // Reference our input parameters to make things easier
109 Length
= IrpSp
->Parameters
.QueryVolume
.Length
;
112 // Decode the file object and fail if this an unopened file object.
115 TypeOfOpen
= CdDecodeFileObject( IrpContext
, IrpSp
->FileObject
, &Fcb
, &Ccb
);
117 if (TypeOfOpen
== UnopenedFileObject
) {
119 CdCompleteRequest( IrpContext
, Irp
, STATUS_INVALID_PARAMETER
);
120 return STATUS_INVALID_PARAMETER
;
124 // Acquire the Vcb for this volume.
127 CdAcquireVcbShared( IrpContext
, Fcb
->Vcb
, FALSE
);
130 // Use a try-finally to facilitate cleanup.
139 CdVerifyVcb( IrpContext
, Fcb
->Vcb
);
142 // Based on the information class we'll do different actions. Each
143 // of the procedures that we're calling fills up the output buffer
144 // if possible and returns true if it successfully filled the buffer
145 // and false if it couldn't wait for any I/O to complete.
148 switch (IrpSp
->Parameters
.QueryVolume
.FsInformationClass
) {
150 case FileFsSizeInformation
:
152 Status
= CdQueryFsSizeInfo( IrpContext
, Fcb
->Vcb
, Irp
->AssociatedIrp
.SystemBuffer
, &Length
);
155 case FileFsVolumeInformation
:
157 Status
= CdQueryFsVolumeInfo( IrpContext
, Fcb
->Vcb
, Irp
->AssociatedIrp
.SystemBuffer
, &Length
);
160 case FileFsDeviceInformation
:
162 Status
= CdQueryFsDeviceInfo( IrpContext
, Fcb
->Vcb
, Irp
->AssociatedIrp
.SystemBuffer
, &Length
);
165 case FileFsAttributeInformation
:
167 Status
= CdQueryFsAttributeInfo( IrpContext
, Fcb
->Vcb
, Irp
->AssociatedIrp
.SystemBuffer
, &Length
);
170 /* ReactOS Change: GCC "enumeration value not handled in switch" */
175 // Set the information field to the number of bytes actually filled in
178 Irp
->IoStatus
.Information
= IrpSp
->Parameters
.QueryVolume
.Length
- Length
;
186 CdReleaseVcb( IrpContext
, Fcb
->Vcb
);
190 // Complete the request if we didn't raise.
193 CdCompleteRequest( IrpContext
, Irp
, Status
);
200 // Local support routine
204 CdQueryFsVolumeInfo (
205 IN PIRP_CONTEXT IrpContext
,
207 IN PFILE_FS_VOLUME_INFORMATION Buffer
,
215 This routine implements the query volume info call
219 Vcb - Vcb for this volume.
221 Buffer - Supplies a pointer to the output buffer where the information
224 Length - Supplies the length of the buffer in byte. This variable
225 upon return receives the remaining bytes free in the buffer
229 NTSTATUS - Returns the status for the query
236 NTSTATUS Status
= STATUS_SUCCESS
;
241 // Fill in the data from the Vcb.
244 Buffer
->VolumeCreationTime
= *((PLARGE_INTEGER
) &Vcb
->VolumeDasdFcb
->CreationTime
);
245 Buffer
->VolumeSerialNumber
= Vcb
->Vpb
->SerialNumber
;
247 Buffer
->SupportsObjects
= FALSE
;
249 *Length
-= FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION
, VolumeLabel
[0] );
252 // Check if the buffer we're given is long enough
255 if (*Length
>= (ULONG
) Vcb
->Vpb
->VolumeLabelLength
) {
257 BytesToCopy
= Vcb
->Vpb
->VolumeLabelLength
;
261 BytesToCopy
= *Length
;
263 Status
= STATUS_BUFFER_OVERFLOW
;
267 // Copy over what we can of the volume label, and adjust *Length
270 Buffer
->VolumeLabelLength
= BytesToCopy
;
274 RtlCopyMemory( &Buffer
->VolumeLabel
[0],
275 &Vcb
->Vpb
->VolumeLabel
[0],
279 *Length
-= BytesToCopy
;
282 // Set our status and return to our caller
290 // Local support routine
295 IN PIRP_CONTEXT IrpContext
,
297 IN PFILE_FS_SIZE_INFORMATION Buffer
,
305 This routine implements the query volume size call.
309 Vcb - Vcb for this volume.
311 Buffer - Supplies a pointer to the output buffer where the information
314 Length - Supplies the length of the buffer in byte. This variable
315 upon return receives the remaining bytes free in the buffer
319 NTSTATUS - Returns the status for the query
327 // Fill in the output buffer.
330 Buffer
->TotalAllocationUnits
.QuadPart
= LlSectorsFromBytes( Vcb
->VolumeDasdFcb
->AllocationSize
.QuadPart
);
332 Buffer
->AvailableAllocationUnits
.QuadPart
= 0;
333 Buffer
->SectorsPerAllocationUnit
= 1;
334 Buffer
->BytesPerSector
= SECTOR_SIZE
;
337 // Adjust the length variable
340 *Length
-= sizeof( FILE_FS_SIZE_INFORMATION
);
343 // And return success to our caller
346 return STATUS_SUCCESS
;
351 // Local support routine
355 CdQueryFsDeviceInfo (
356 IN PIRP_CONTEXT IrpContext
,
358 IN PFILE_FS_DEVICE_INFORMATION Buffer
,
366 This routine implements the query volume device call.
370 Vcb - Vcb for this volume.
372 Buffer - Supplies a pointer to the output buffer where the information
375 Length - Supplies the length of the buffer in byte. This variable
376 upon return receives the remaining bytes free in the buffer
380 NTSTATUS - Returns the status for the query
388 // Update the output buffer.
391 Buffer
->Characteristics
= Vcb
->TargetDeviceObject
->Characteristics
;
392 Buffer
->DeviceType
= FILE_DEVICE_CD_ROM
;
395 // Adjust the length variable
398 *Length
-= sizeof( FILE_FS_DEVICE_INFORMATION
);
401 // And return success to our caller
404 return STATUS_SUCCESS
;
409 // Local support routine
413 CdQueryFsAttributeInfo (
414 IN PIRP_CONTEXT IrpContext
,
416 IN PFILE_FS_ATTRIBUTE_INFORMATION Buffer
,
424 This routine implements the query volume attribute call.
428 Vcb - Vcb for this volume.
430 Buffer - Supplies a pointer to the output buffer where the information
433 Length - Supplies the length of the buffer in byte. This variable
434 upon return receives the remaining bytes free in the buffer
438 NTSTATUS - Returns the status for the query
445 NTSTATUS Status
= STATUS_SUCCESS
;
450 // Fill out the fixed portion of the buffer.
453 Buffer
->FileSystemAttributes
= FILE_CASE_SENSITIVE_SEARCH
|
454 FILE_READ_ONLY_VOLUME
;
456 if (FlagOn( IrpContext
->Vcb
->VcbState
, VCB_STATE_JOLIET
)) {
458 SetFlag( Buffer
->FileSystemAttributes
, FILE_UNICODE_ON_DISK
);
460 Buffer
->MaximumComponentNameLength
= 110;
464 Buffer
->MaximumComponentNameLength
= 221;
467 *Length
-= FIELD_OFFSET( FILE_FS_ATTRIBUTE_INFORMATION
, FileSystemName
);
470 // Make sure we can copy full unicode characters.
473 ClearFlag( *Length
, 1 );
476 // Determine how much of the file system name will fit.
485 BytesToCopy
= *Length
;
486 Status
= STATUS_BUFFER_OVERFLOW
;
489 *Length
-= BytesToCopy
;
492 // Do the file system name.
495 Buffer
->FileSystemNameLength
= BytesToCopy
;
497 RtlCopyMemory( &Buffer
->FileSystemName
[0], L
"CDFS", BytesToCopy
);
500 // And return to our caller