Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenvolume.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS FAT file system driver 00003 * LICENSE: GNU GPLv3 as published by the Free Software Foundation 00004 * FILE: drivers/filesystems/fastfat/volume.c 00005 * PURPOSE: Volume information 00006 * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org) 00007 */ 00008 00009 /* INCLUDES *****************************************************************/ 00010 00011 #define NDEBUG 00012 #include "fastfat.h" 00013 00014 /* FUNCTIONS ****************************************************************/ 00015 00016 NTSTATUS 00017 NTAPI 00018 FatiQueryFsVolumeInfo(PVCB Vcb, 00019 PFILE_FS_VOLUME_INFORMATION Buffer, 00020 PLONG Length) 00021 { 00022 ULONG ByteSize; 00023 NTSTATUS Status = STATUS_SUCCESS; 00024 00025 /* Deduct the minimum written length */ 00026 *Length -= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel[0]); 00027 00028 /* Zero it */ 00029 RtlZeroMemory(Buffer, sizeof(FILE_FS_VOLUME_INFORMATION)); 00030 00031 DPRINT("Serial number 0x%x, label length %d\n", 00032 Vcb->Vpb->SerialNumber, Vcb->Vpb->VolumeLabelLength); 00033 00034 /* Save serial number */ 00035 Buffer->VolumeSerialNumber = Vcb->Vpb->SerialNumber; 00036 00037 /* Set max byte size */ 00038 ByteSize = Vcb->Vpb->VolumeLabelLength; 00039 00040 /* Check buffer length and reduce byte size if needed */ 00041 if (*Length < Vcb->Vpb->VolumeLabelLength) 00042 { 00043 /* Copy only up to what buffer size was provided */ 00044 ByteSize = *Length; 00045 Status = STATUS_BUFFER_OVERFLOW; 00046 } 00047 00048 /* Copy volume label */ 00049 Buffer->VolumeLabelLength = Vcb->Vpb->VolumeLabelLength; 00050 RtlCopyMemory(Buffer->VolumeLabel, Vcb->Vpb->VolumeLabel, ByteSize); 00051 *Length -= ByteSize; 00052 00053 return Status; 00054 } 00055 00056 NTSTATUS 00057 NTAPI 00058 FatiQueryFsSizeInfo(PVCB Vcb, 00059 PFILE_FS_SIZE_INFORMATION Buffer, 00060 PLONG Length) 00061 { 00062 FF_PARTITION *Partition; 00063 NTSTATUS Status = STATUS_SUCCESS; 00064 00065 /* Deduct the minimum written length */ 00066 *Length -= sizeof(FILE_FS_SIZE_INFORMATION); 00067 00068 /* Zero it */ 00069 RtlZeroMemory(Buffer, sizeof(FILE_FS_SIZE_INFORMATION)); 00070 00071 /* Reference FullFAT's partition */ 00072 Partition = Vcb->Ioman->pPartition; 00073 00074 /* Set values */ 00075 Buffer->AvailableAllocationUnits.LowPart = Partition->FreeClusterCount; 00076 Buffer->TotalAllocationUnits.LowPart = Partition->NumClusters; 00077 Buffer->SectorsPerAllocationUnit = Vcb->Bpb.SectorsPerCluster; 00078 Buffer->BytesPerSector = Vcb->Bpb.BytesPerSector; 00079 00080 DPRINT1("Total %d, free %d, SPC %d, BPS %d\n", Partition->NumClusters, 00081 Partition->FreeClusterCount, Vcb->Bpb.SectorsPerCluster, Vcb->Bpb.BytesPerSector); 00082 00083 return Status; 00084 } 00085 00086 NTSTATUS 00087 NTAPI 00088 FatiQueryFsDeviceInfo(PVCB Vcb, 00089 PFILE_FS_DEVICE_INFORMATION Buffer, 00090 PLONG Length) 00091 { 00092 /* Deduct the minimum written length */ 00093 *Length -= sizeof(FILE_FS_DEVICE_INFORMATION); 00094 00095 /* Zero it */ 00096 RtlZeroMemory(Buffer, sizeof(FILE_FS_DEVICE_INFORMATION)); 00097 00098 /* Set values */ 00099 Buffer->DeviceType = FILE_DEVICE_DISK; 00100 Buffer->Characteristics = Vcb->TargetDeviceObject->Characteristics; 00101 00102 return STATUS_SUCCESS; 00103 } 00104 00105 NTSTATUS 00106 NTAPI 00107 FatiQueryVolumeInfo(PFAT_IRP_CONTEXT IrpContext, PIRP Irp) 00108 { 00109 PFILE_OBJECT FileObject; 00110 PIO_STACK_LOCATION IrpSp; 00111 FILE_INFORMATION_CLASS InfoClass; 00112 TYPE_OF_OPEN FileType; 00113 PVCB Vcb; 00114 PFCB Fcb; 00115 PCCB Ccb; 00116 LONG Length; 00117 PVOID Buffer; 00118 BOOLEAN VcbLocked = FALSE; 00119 NTSTATUS Status = STATUS_SUCCESS; 00120 00121 /* Get IRP stack location */ 00122 IrpSp = IoGetCurrentIrpStackLocation(Irp); 00123 00124 /* Get the file object */ 00125 FileObject = IrpSp->FileObject; 00126 00127 /* Copy variables to something with shorter names */ 00128 InfoClass = IrpSp->Parameters.QueryVolume.FsInformationClass; 00129 Length = IrpSp->Parameters.QueryVolume.Length; 00130 Buffer = Irp->AssociatedIrp.SystemBuffer; 00131 00132 DPRINT("FatiQueryVolumeInfo\n", 0); 00133 DPRINT("\tIrp = %08lx\n", Irp); 00134 DPRINT("\tLength = %08lx\n", Length); 00135 DPRINT("\tFsInformationClass = %08lx\n", InfoClass); 00136 DPRINT("\tBuffer = %08lx\n", Buffer); 00137 00138 FileType = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb); 00139 00140 DPRINT("Vcb %p, Fcb %p, Ccb %p, open type %d\n", Vcb, Fcb, Ccb, FileType); 00141 00142 switch (InfoClass) 00143 { 00144 case FileFsVolumeInformation: 00145 /* Acquired the shared VCB lock */ 00146 if (!FatAcquireSharedVcb(IrpContext, Vcb)) 00147 { 00148 ASSERT(FALSE); 00149 } 00150 00151 /* Remember we locked it */ 00152 VcbLocked = TRUE; 00153 00154 /* Call FsVolumeInfo handler */ 00155 Status = FatiQueryFsVolumeInfo(Vcb, Buffer, &Length); 00156 break; 00157 00158 case FileFsSizeInformation: 00159 /* Call FsVolumeInfo handler */ 00160 Status = FatiQueryFsSizeInfo(Vcb, Buffer, &Length); 00161 break; 00162 00163 case FileFsDeviceInformation: 00164 Status = FatiQueryFsDeviceInfo(Vcb, Buffer, &Length); 00165 break; 00166 00167 case FileFsAttributeInformation: 00168 UNIMPLEMENTED; 00169 //Status = FatiQueryFsAttributeInfo(IrpContext, Vcb, Buffer, &Length); 00170 break; 00171 00172 case FileFsFullSizeInformation: 00173 UNIMPLEMENTED; 00174 //Status = FatiQueryFsFullSizeInfo(IrpContext, Vcb, Buffer, &Length); 00175 break; 00176 00177 default: 00178 Status = STATUS_INVALID_PARAMETER; 00179 } 00180 00181 /* Set IoStatus.Information to amount of filled bytes */ 00182 Irp->IoStatus.Information = IrpSp->Parameters.QueryVolume.Length - Length; 00183 00184 /* Release VCB lock */ 00185 if (VcbLocked) FatReleaseVcb(IrpContext, Vcb); 00186 00187 /* Complete request and return status */ 00188 FatCompleteRequest(IrpContext, Irp, Status); 00189 return Status; 00190 } 00191 00192 NTSTATUS 00193 NTAPI 00194 FatQueryVolumeInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp) 00195 { 00196 NTSTATUS Status; 00197 BOOLEAN TopLevel, CanWait; 00198 PFAT_IRP_CONTEXT IrpContext; 00199 00200 CanWait = TRUE; 00201 TopLevel = FALSE; 00202 Status = STATUS_INVALID_DEVICE_REQUEST; 00203 00204 /* Get CanWait flag */ 00205 if (IoGetCurrentIrpStackLocation(Irp)->FileObject != NULL) 00206 CanWait = IoIsOperationSynchronous(Irp); 00207 00208 /* Enter FsRtl critical region */ 00209 FsRtlEnterFileSystem(); 00210 00211 /* Set Top Level IRP if not set */ 00212 TopLevel = FatIsTopLevelIrp(Irp); 00213 00214 /* Build an irp context */ 00215 IrpContext = FatBuildIrpContext(Irp, CanWait); 00216 00217 /* Call the request handler */ 00218 Status = FatiQueryVolumeInfo(IrpContext, Irp); 00219 00220 /* Restore top level Irp */ 00221 if (TopLevel) 00222 IoSetTopLevelIrp(NULL); 00223 00224 /* Leave FsRtl critical region */ 00225 FsRtlExitFileSystem(); 00226 00227 return Status; 00228 } 00229 00230 NTSTATUS 00231 NTAPI 00232 FatSetVolumeInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp) 00233 { 00234 DPRINT1("FatSetVolumeInfo()\n"); 00235 return STATUS_NOT_IMPLEMENTED; 00236 } 00237 00238 VOID 00239 NTAPI 00240 FatReadStreamFile(PVCB Vcb, 00241 ULONGLONG ByteOffset, 00242 ULONG ByteSize, 00243 PBCB *Bcb, 00244 PVOID *Buffer) 00245 { 00246 LARGE_INTEGER Offset; 00247 00248 Offset.QuadPart = ByteOffset; 00249 00250 if (!CcMapData(Vcb->StreamFileObject, 00251 &Offset, 00252 ByteSize, 00253 TRUE, // FIXME: CanWait 00254 Bcb, 00255 Buffer)) 00256 { 00257 ASSERT(FALSE); 00258 } 00259 } 00260 00261 BOOLEAN 00262 NTAPI 00263 FatCheckForDismount(IN PFAT_IRP_CONTEXT IrpContext, 00264 PVCB Vcb, 00265 IN BOOLEAN Force) 00266 { 00267 /* We never allow deletion of a volume for now */ 00268 return FALSE; 00269 } 00270 00271 /* EOF */ Generated on Sat May 26 2012 04:18:07 for ReactOS by
1.7.6.1
|