2 * PROJECT: ReactOS FAT file system driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/filesystems/fastfat/volume.c
5 * PURPOSE: Volume information
6 * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
9 /* INCLUDES *****************************************************************/
14 /* FUNCTIONS ****************************************************************/
18 FatiQueryFsVolumeInfo(PVCB Vcb
,
19 PFILE_FS_VOLUME_INFORMATION Buffer
,
23 NTSTATUS Status
= STATUS_SUCCESS
;
25 /* Deduct the minimum written length */
26 *Length
-= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION
, VolumeLabel
[0]);
29 RtlZeroMemory(Buffer
, sizeof(FILE_FS_VOLUME_INFORMATION
));
31 DPRINT("Serial number 0x%x, label length %d\n",
32 Vcb
->Vpb
->SerialNumber
, Vcb
->Vpb
->VolumeLabelLength
);
34 /* Save serial number */
35 Buffer
->VolumeSerialNumber
= Vcb
->Vpb
->SerialNumber
;
37 /* Set max byte size */
38 ByteSize
= Vcb
->Vpb
->VolumeLabelLength
;
40 /* Check buffer length and reduce byte size if needed */
41 if (*Length
< Vcb
->Vpb
->VolumeLabelLength
)
43 /* Copy only up to what buffer size was provided */
45 Status
= STATUS_BUFFER_OVERFLOW
;
48 /* Copy volume label */
49 Buffer
->VolumeLabelLength
= Vcb
->Vpb
->VolumeLabelLength
;
50 RtlCopyMemory(Buffer
->VolumeLabel
, Vcb
->Vpb
->VolumeLabel
, ByteSize
);
58 FatiQueryVolumeInfo(PFAT_IRP_CONTEXT IrpContext
, PIRP Irp
)
60 PFILE_OBJECT FileObject
;
61 PIO_STACK_LOCATION IrpSp
;
62 FILE_INFORMATION_CLASS InfoClass
;
63 TYPE_OF_OPEN FileType
;
69 BOOLEAN VcbLocked
= FALSE
;
70 NTSTATUS Status
= STATUS_SUCCESS
;
72 /* Get IRP stack location */
73 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
75 /* Get the file object */
76 FileObject
= IrpSp
->FileObject
;
78 /* Copy variables to something with shorter names */
79 InfoClass
= IrpSp
->Parameters
.QueryVolume
.FsInformationClass
;
80 Length
= IrpSp
->Parameters
.QueryVolume
.Length
;
81 Buffer
= Irp
->AssociatedIrp
.SystemBuffer
;
83 DPRINT("FatiQueryVolumeInfo\n", 0);
84 DPRINT("\tIrp = %08lx\n", Irp
);
85 DPRINT("\tLength = %08lx\n", Length
);
86 DPRINT("\tFsInformationClass = %08lx\n", InfoClass
);
87 DPRINT("\tBuffer = %08lx\n", Buffer
);
89 FileType
= FatDecodeFileObject(FileObject
, &Vcb
, &Fcb
, &Ccb
);
91 DPRINT("Vcb %p, Fcb %p, Ccb %p, open type %d\n", Vcb
, Fcb
, Ccb
, FileType
);
95 case FileFsVolumeInformation
:
96 /* Acquired the shared VCB lock */
97 if (!FatAcquireSharedVcb(IrpContext
, Vcb
))
102 /* Remember we locked it */
105 /* Call FsVolumeInfo handler */
106 Status
= FatiQueryFsVolumeInfo(Vcb
, Buffer
, &Length
);
109 DPRINT1("Volume information class %d is not supported!\n", InfoClass
);
113 /* Set IoStatus.Information to amount of filled bytes */
114 Irp
->IoStatus
.Information
= IrpSp
->Parameters
.QueryVolume
.Length
- Length
;
116 /* Release VCB lock */
117 if (VcbLocked
) FatReleaseVcb(IrpContext
, Vcb
);
119 /* Complete request and return status */
120 FatCompleteRequest(IrpContext
, Irp
, Status
);
126 FatQueryVolumeInfo(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
129 BOOLEAN TopLevel
, CanWait
;
130 PFAT_IRP_CONTEXT IrpContext
;
134 Status
= STATUS_INVALID_DEVICE_REQUEST
;
136 /* Get CanWait flag */
137 if (IoGetCurrentIrpStackLocation(Irp
)->FileObject
!= NULL
)
138 CanWait
= IoIsOperationSynchronous(Irp
);
140 /* Enter FsRtl critical region */
141 FsRtlEnterFileSystem();
143 /* Set Top Level IRP if not set */
144 if (IoGetTopLevelIrp() == NULL
)
146 IoSetTopLevelIrp(Irp
);
150 /* Build an irp context */
151 IrpContext
= FatBuildIrpContext(Irp
, CanWait
);
153 /* Call the request handler */
154 Status
= FatiQueryVolumeInfo(IrpContext
, Irp
);
156 /* Restore top level Irp */
158 IoSetTopLevelIrp(NULL
);
160 /* Leave FsRtl critical region */
161 FsRtlExitFileSystem();
168 FatSetVolumeInfo(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
170 DPRINT1("FatSetVolumeInfo()\n");
171 return STATUS_NOT_IMPLEMENTED
;