test: volinfo.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# volinfo.c File Reference

`#include "UdfProcs.h"`

Go to the source code of this file.

## Defines

#define | BugCheckFileId (UDFS_BUG_CHECK_VOLINFO)
#define | Dbg (UDFS_DEBUG_LEVEL_VOLINFO)

## Functions

NTSTATUS | UdfQueryFsVolumeInfo (IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PFILE_FS_VOLUME_INFORMATION Buffer, IN OUT PULONG Length)
NTSTATUS | UdfQueryFsSizeInfo (IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PFILE_FS_SIZE_INFORMATION Buffer, IN OUT PULONG Length)
NTSTATUS | UdfQueryFsDeviceInfo (IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PFILE_FS_DEVICE_INFORMATION Buffer, IN OUT PULONG Length)
NTSTATUS | UdfQueryFsAttributeInfo (IN PIRP_CONTEXT IrpContext, IN PVCB Vcb, IN PFILE_FS_ATTRIBUTE_INFORMATION Buffer, IN OUT PULONG Length)
NTSTATUS | UdfCommonQueryVolInfo (IN PIRP_CONTEXT IrpContext, IN PIRP Irp)

## Define Documentation

#define BugCheckFileId (UDFS_BUG_CHECK_VOLINFO)

| Definition at line 28 of file volinfo.c.

#define Dbg (UDFS_DEBUG_LEVEL_VOLINFO)

| Definition at line 34 of file volinfo.c.

## Function Documentation

NTSTATUS UdfCommonQueryVolInfo | ( | IN PIRP_CONTEXT | IrpContext,
|  | IN PIRP | Irp
| ) |

Definition at line 82 of file volinfo.c.

References _IRP::AssociatedIrp, FALSE, _IO_STACK_LOCATION::FileObject, IoGetCurrentIrpStackLocation, _IRP::IoStatus, Irp, NTSTATUS(), PAGED_CODE, _IO_STACK_LOCATION::Parameters, Status, TYPE_OF_OPEN, UdfAcquireVcbShared, UdfCompleteRequest(), UdfDecodeFileObject(), UdfQueryFsAttributeInfo(), UdfQueryFsDeviceInfo(), UdfQueryFsSizeInfo(), UdfQueryFsVolumeInfo(), UdfReleaseVcb, UdfVerifyVcb(), UnopenedFileObject, and _FCB::Vcb.

Referenced by UdfFsdDispatch(), and UdfFspDispatch().

    00089                    :
    00090
    00091     This is the common routine for querying volume information called by both
    00092     the fsd and fsp threads.
    00093
    00094 Arguments:
    00095
    00096     Irp - Supplies the Irp being processed
    00097
    00098 Return Value:
    00099
    00100     NTSTATUS - The return status for the operation
    00101
    00102 --*/
    00103
    00104 {
    00105     NTSTATUS Status = STATUS_INVALID_PARAMETER;
    00106     PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp );
    00107
    00108     ULONG Length;
    00109
    00110     TYPE_OF_OPEN TypeOfOpen;
    00111     PFCB Fcb;
    00112     PCCB Ccb;
    00113
    00114     PAGED_CODE();
    00115
    00116     //
    00117     //  Reference our input parameters to make things easier
    00118     //
    00119
    00120     Length = IrpSp->Parameters.QueryVolume.Length;
    00121
    00122     //
    00123     //  Decode the file object and fail if this an unopened file object.
    00124     //
    00125
    00126     TypeOfOpen = UdfDecodeFileObject( IrpSp->FileObject, &Fcb, &Ccb );
    00127
    00128     if (TypeOfOpen == UnopenedFileObject) {
    00129
    00130         UdfCompleteRequest( IrpContext, Irp, STATUS_INVALID_PARAMETER );
    00131         return STATUS_INVALID_PARAMETER;
    00132     }
    00133
    00134     //
    00135     //  Acquire the Vcb for this volume.
    00136     //
    00137
    00138     UdfAcquireVcbShared( IrpContext, Fcb->Vcb, FALSE );
    00139
    00140     //
    00141     //  Use a try-finally to facilitate cleanup.
    00142     //
    00143
    00144     try {
    00145
    00146         //
    00147         //  Verify the Vcb.
    00148         //
    00149
    00150         UdfVerifyVcb( IrpContext, Fcb->Vcb );
    00151
    00152         //
    00153         //  Based on the information class we'll do different actions.  Each
    00154         //  of the procedures that we're calling fills up the output buffer
    00155         //  if possible and returns true if it successfully filled the buffer
    00156         //  and false if it couldn't wait for any I/O to complete.
    00157         //
    00158
    00159         switch (IrpSp->Parameters.QueryVolume.FsInformationClass) {
    00160
    00161         case FileFsSizeInformation:
    00162
    00163             Status = UdfQueryFsSizeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
    00164             break;
    00165
    00166         case FileFsVolumeInformation:
    00167
    00168             Status = UdfQueryFsVolumeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
    00169             break;
    00170
    00171         case FileFsDeviceInformation:
    00172
    00173             Status = UdfQueryFsDeviceInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
    00174             break;
    00175
    00176         case FileFsAttributeInformation:
    00177
    00178             Status = UdfQueryFsAttributeInfo( IrpContext, Fcb->Vcb, Irp->AssociatedIrp.SystemBuffer, &Length );
    00179             break;
    00180         }
    00181
    00182         //
    00183         //  Set the information field to the number of bytes actually filled in
    00184         //
    00185
    00186         Irp->IoStatus.Information = IrpSp->Parameters.QueryVolume.Length - Length;
    00187
    00188     } finally {
    00189
    00190         //
    00191         //  Release the Vcb.
    00192         //
    00193
    00194         UdfReleaseVcb( IrpContext, Fcb->Vcb );
    00195     }
    00196
    00197     //
    00198     //  Complete the request if we didn't raise.
    00199     //
    00200
    00201     UdfCompleteRequest( IrpContext, Irp, Status );
    00202
    00203     return Status;
    00204 }

NTSTATUS UdfQueryFsAttributeInfo | ( | IN PIRP_CONTEXT | IrpContext,
|  | IN PVCB | Vcb,
|  | IN PFILE_FS_ATTRIBUTE_INFORMATION | Buffer,
|  | IN OUT PULONG | Length
| ) |

Definition at line 421 of file volinfo.c.

References Buffer, ClearFlag, L, NTSTATUS(), PAGED_CODE, and Status.

Referenced by UdfCommonQueryVolInfo().

    00430                    :
    00431
    00432     This routine implements the query volume attribute call.
    00433
    00434 Arguments:
    00435
    00436     Vcb - Vcb for this volume.
    00437
    00438     Buffer - Supplies a pointer to the output buffer where the information
    00439         is to be returned
    00440
    00441     Length - Supplies the length of the buffer in byte.  This variable
    00442         upon return recieves the remaining bytes free in the buffer
    00443
    00444 Return Value:
    00445
    00446     NTSTATUS - Returns the status for the query
    00447
    00448 --*/
    00449
    00450 {
    00451     ULONG BytesToCopy;
    00452
    00453     NTSTATUS Status = STATUS_SUCCESS;
    00454
    00455     PAGED_CODE();
    00456
    00457     //
    00458     //  Fill out the fixed portion of the buffer.
    00459     //
    00460
    00461     Buffer->FileSystemAttributes = FILE_CASE_SENSITIVE_SEARCH |
    00462                                    FILE_UNICODE_ON_DISK;
    00463
    00464     Buffer->MaximumComponentNameLength = 255;
    00465
    00466     *Length -= FIELD_OFFSET( FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName );
    00467
    00468     //
    00469     //  Make sure we can copy full unicode characters.
    00470     //
    00471
    00472     ClearFlag( *Length, 1 );
    00473
    00474     //
    00475     //  Determine how much of the file system name will fit.
    00476     //
    00477
    00478     if (*Length >= 6) {
    00479
    00480         BytesToCopy = 6;
    00481
    00482     } else {
    00483
    00484         BytesToCopy = *Length;
    00485         Status = STATUS_BUFFER_OVERFLOW;
    00486     }
    00487
    00488     *Length -= BytesToCopy;
    00489
    00490     //
    00491     //  Do the file system name.  We explicitly share this designation with all
    00492     //  Microsoft implementations of the UDF filesystem - DO NOT CHANGE!
    00493     //
    00494
    00495     Buffer->FileSystemNameLength = BytesToCopy;
    00496
    00497     RtlCopyMemory( &Buffer->FileSystemName[0], L"UDF", BytesToCopy );
    00498
    00499     //
    00500     //  And return to our caller
    00501     //
    00502
    00503     return Status;
    00504 }
    }

NTSTATUS UdfQueryFsDeviceInfo | ( | IN PIRP_CONTEXT | IrpContext,
|  | IN PVCB | Vcb,
|  | IN PFILE_FS_DEVICE_INFORMATION | Buffer,
|  | IN OUT PULONG | Length
| ) |

Definition at line 363 of file volinfo.c.

References Buffer, and PAGED_CODE.

Referenced by UdfCommonQueryVolInfo().

    00372                    :
    00373
    00374     This routine implements the query volume device call.
    00375
    00376 Arguments:
    00377
    00378     Vcb - Vcb for this volume.
    00379
    00380     Buffer - Supplies a pointer to the output buffer where the information
    00381         is to be returned
    00382
    00383     Length - Supplies the length of the buffer in byte.  This variable
    00384         upon return recieves the remaining bytes free in the buffer
    00385
    00386 Return Value:
    00387
    00388     NTSTATUS - Returns the status for the query
    00389
    00390 --*/
    00391
    00392 {
    00393     PAGED_CODE();
    00394
    00395     //
    00396     //  Update the output buffer.
    00397     //
    00398
    00399     Buffer->Characteristics = Vcb->TargetDeviceObject->Characteristics;
    00400     Buffer->DeviceType = FILE_DEVICE_CD_ROM;
    00401
    00402     //
    00403     //  Adjust the length variable
    00404     //
    00405
    00406     *Length -= sizeof( FILE_FS_DEVICE_INFORMATION );
    00407
    00408     //
    00409     //  And return success to our caller
    00410     //
    00411
    00412     return STATUS_SUCCESS;
    00413 }

NTSTATUS UdfQueryFsSizeInfo | ( | IN PIRP_CONTEXT | IrpContext,
|  | IN PVCB | Vcb,
|  | IN PFILE_FS_SIZE_INFORMATION | Buffer,
|  | IN OUT PULONG | Length
| ) |

Definition at line 302 of file volinfo.c.

References BlockSize, Buffer, LlBlocksFromBytes, PAGED_CODE, SectorsFromBytes, and SectorSize.

Referenced by UdfCommonQueryVolInfo().

    00311                    :
    00312
    00313     This routine implements the query volume size call.
    00314
    00315 Arguments:
    00316
    00317     Vcb - Vcb for this volume.
    00318
    00319     Buffer - Supplies a pointer to the output buffer where the information
    00320         is to be returned
    00321
    00322     Length - Supplies the length of the buffer in byte.  This variable
    00323         upon return recieves the remaining bytes free in the buffer
    00324
    00325 Return Value:
    00326
    00327     NTSTATUS - Returns the status for the query
    00328
    00329 --*/
    00330
    00331 {
    00332     PAGED_CODE();
    00333
    00334     //
    00335     //  Fill in the output buffer.
    00336     //
    00337
    00338     Buffer->TotalAllocationUnits.QuadPart = LlBlocksFromBytes( Vcb, Vcb->VolumeDasdFcb->AllocationSize.QuadPart );
    00339
    00340     Buffer->AvailableAllocationUnits.QuadPart = 0;
    00341     Buffer->SectorsPerAllocationUnit = SectorsFromBytes( Vcb, BlockSize( Vcb ));
    00342     Buffer->BytesPerSector = SectorSize( Vcb );
    00343
    00344     //
    00345     //  Adjust the length variable
    00346     //
    00347
    00348     *Length -= sizeof( FILE_FS_SIZE_INFORMATION );
    00349
    00350     //
    00351     //  And return success to our caller
    00352     //
    00353
    00354     return STATUS_SUCCESS;
    00355 }

NTSTATUS UdfQueryFsVolumeInfo | ( | IN PIRP_CONTEXT | IrpContext,
|  | IN PVCB | Vcb,
|  | IN PFILE_FS_VOLUME_INFORMATION | Buffer,
|  | IN OUT PULONG | Length
| ) |

Definition at line 212 of file volinfo.c.

References Buffer, FALSE, NTSTATUS(), PAGED_CODE, and Status.

Referenced by UdfCommonQueryVolInfo().

    00221                    :
    00222
    00223     This routine implements the query volume info call
    00224
    00225 Arguments:
    00226
    00227     Vcb - Vcb for this volume.
    00228
    00229     Buffer - Supplies a pointer to the output buffer where the information
    00230         is to be returned
    00231
    00232     Length - Supplies the length of the buffer in byte.  This variable
    00233         upon return recieves the remaining bytes free in the buffer
    00234
    00235 Return Value:
    00236
    00237     NTSTATUS - Returns the status for the query
    00238
    00239 --*/
    00240
    00241 {
    00242     ULONG BytesToCopy;
    00243
    00244     NTSTATUS Status = STATUS_SUCCESS;
    00245
    00246     PAGED_CODE();
    00247
    00248     //
    00249     //  Fill in the data from the Vcb.
    00250     //
    00251
    00252     Buffer->VolumeCreationTime = Vcb->VolumeDasdFcb->Timestamps.CreationTime;
    00253     Buffer->VolumeSerialNumber = Vcb->Vpb->SerialNumber;
    00254
    00255     Buffer->SupportsObjects = FALSE;
    00256
    00257     *Length -= FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION, VolumeLabel[0] );
    00258
    00259     //
    00260     //  Check if the buffer we're given is long enough
    00261     //
    00262
    00263     if (*Length >= (ULONG) Vcb->Vpb->VolumeLabelLength) {
    00264
    00265         BytesToCopy = Vcb->Vpb->VolumeLabelLength;
    00266
    00267     } else {
    00268
    00269         BytesToCopy = *Length;
    00270
    00271         Status = STATUS_BUFFER_OVERFLOW;
    00272     }
    00273
    00274     //
    00275     //  Copy over what we can of the volume label, and adjust *Length
    00276     //
    00277
    00278     Buffer->VolumeLabelLength = BytesToCopy;
    00279
    00280     if (BytesToCopy) {
    00281
    00282         RtlCopyMemory( &Buffer->VolumeLabel[0],
    00283                        &Vcb->Vpb->VolumeLabel[0],
    00284                        BytesToCopy );
    00285     }
    00286
    00287     *Length -= BytesToCopy;
    00288
    00289     //
    00290     //  Set our status and return to our caller
    00291     //
    00292
    00293     return Status;
    00294 }