3 * Copyright (C) 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: drivers/filesystems/cdfs/volume.c
23 * PURPOSE: CDROM (ISO 9660) filesystem driver
24 * PROGRAMMER: Art Yerkes
28 /* INCLUDES *****************************************************************/
35 /* FUNCTIONS ****************************************************************/
39 CdfsGetFsVolumeInformation(
40 PDEVICE_OBJECT DeviceObject
,
41 PFILE_FS_VOLUME_INFORMATION FsVolumeInfo
,
44 DPRINT("CdfsGetFsVolumeInformation() called\n");
45 DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo
);
46 DPRINT("BufferLength %lu\n", *BufferLength
);
48 DPRINT("Vpb %p\n", DeviceObject
->Vpb
);
50 DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
));
51 DPRINT("LabelLength %hu\n", DeviceObject
->Vpb
->VolumeLabelLength
);
52 DPRINT("Label %.*S\n", DeviceObject
->Vpb
->VolumeLabelLength
/ sizeof(WCHAR
), DeviceObject
->Vpb
->VolumeLabel
);
54 if (*BufferLength
< sizeof(FILE_FS_VOLUME_INFORMATION
))
55 return STATUS_INFO_LENGTH_MISMATCH
;
57 if (*BufferLength
< (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
))
58 return STATUS_BUFFER_OVERFLOW
;
61 FsVolumeInfo
->VolumeSerialNumber
= DeviceObject
->Vpb
->SerialNumber
;
62 FsVolumeInfo
->VolumeLabelLength
= DeviceObject
->Vpb
->VolumeLabelLength
;
63 memcpy(FsVolumeInfo
->VolumeLabel
,
64 DeviceObject
->Vpb
->VolumeLabel
,
65 DeviceObject
->Vpb
->VolumeLabelLength
);
68 FsVolumeInfo
->VolumeCreationTime
.QuadPart
= 0;
69 FsVolumeInfo
->SupportsObjects
= FALSE
;
71 DPRINT("Finished FsdGetFsVolumeInformation()\n");
73 *BufferLength
-= (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
);
75 DPRINT("BufferLength %lu\n", *BufferLength
);
77 return STATUS_SUCCESS
;
83 CdfsGetFsAttributeInformation(
84 PDEVICE_EXTENSION DeviceExt
,
85 PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo
,
88 DPRINT("CdfsGetFsAttributeInformation()\n");
89 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo
);
90 DPRINT("BufferLength %lu\n", *BufferLength
);
91 DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8));
93 UNREFERENCED_PARAMETER(DeviceExt
);
95 if (*BufferLength
< sizeof (FILE_FS_ATTRIBUTE_INFORMATION
))
96 return STATUS_INFO_LENGTH_MISMATCH
;
98 if (*BufferLength
< (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8))
99 return STATUS_BUFFER_OVERFLOW
;
101 FsAttributeInfo
->FileSystemAttributes
=
102 FILE_CASE_PRESERVED_NAMES
| FILE_UNICODE_ON_DISK
| FILE_READ_ONLY_VOLUME
;
103 FsAttributeInfo
->MaximumComponentNameLength
= 255;
104 FsAttributeInfo
->FileSystemNameLength
= 8;
106 memcpy(FsAttributeInfo
->FileSystemName
, L
"CDFS", 8);
108 DPRINT("Finished FsdGetFsAttributeInformation()\n");
110 *BufferLength
-= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8);
111 DPRINT("BufferLength %lu\n", *BufferLength
);
113 return STATUS_SUCCESS
;
118 CdfsGetFsSizeInformation(
119 PDEVICE_OBJECT DeviceObject
,
120 PFILE_FS_SIZE_INFORMATION FsSizeInfo
,
123 PDEVICE_EXTENSION DeviceExt
;
124 NTSTATUS Status
= STATUS_SUCCESS
;
126 DPRINT("CdfsGetFsSizeInformation()\n");
127 DPRINT("FsSizeInfo = %p\n", FsSizeInfo
);
129 if (*BufferLength
< sizeof(FILE_FS_SIZE_INFORMATION
))
130 return STATUS_BUFFER_OVERFLOW
;
132 DeviceExt
= DeviceObject
->DeviceExtension
;
134 FsSizeInfo
->AvailableAllocationUnits
.QuadPart
= 0;
135 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= DeviceExt
->CdInfo
.VolumeSpaceSize
;
136 FsSizeInfo
->SectorsPerAllocationUnit
= 1;
137 FsSizeInfo
->BytesPerSector
= BLOCKSIZE
;
139 DPRINT("Finished FsdGetFsSizeInformation()\n");
140 if (NT_SUCCESS(Status
))
141 *BufferLength
-= sizeof(FILE_FS_SIZE_INFORMATION
);
149 CdfsGetFsDeviceInformation(
150 PDEVICE_OBJECT DeviceObject
,
151 PFILE_FS_DEVICE_INFORMATION FsDeviceInfo
,
154 DPRINT("CdfsGetFsDeviceInformation()\n");
155 DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo
);
156 DPRINT("BufferLength %lu\n", *BufferLength
);
157 DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION
));
159 if (*BufferLength
< sizeof(FILE_FS_DEVICE_INFORMATION
))
160 return STATUS_BUFFER_OVERFLOW
;
162 FsDeviceInfo
->DeviceType
= FILE_DEVICE_CD_ROM
;
163 FsDeviceInfo
->Characteristics
= DeviceObject
->Characteristics
;
165 DPRINT("FsdGetFsDeviceInformation() finished.\n");
167 *BufferLength
-= sizeof(FILE_FS_DEVICE_INFORMATION
);
168 DPRINT("BufferLength %lu\n", *BufferLength
);
170 return STATUS_SUCCESS
;
176 CdfsGetFsFullSizeInformation(
177 PDEVICE_OBJECT DeviceObject
,
178 PFILE_FS_FULL_SIZE_INFORMATION FsSizeInfo
,
181 PDEVICE_EXTENSION DeviceExt
;
182 NTSTATUS Status
= STATUS_SUCCESS
;
184 DPRINT("CdfsGetFsFullSizeInformation()\n");
185 DPRINT("FsSizeInfo = %p\n", FsSizeInfo
);
187 if (*BufferLength
< sizeof(FILE_FS_FULL_SIZE_INFORMATION
))
188 return STATUS_BUFFER_OVERFLOW
;
190 DeviceExt
= DeviceObject
->DeviceExtension
;
192 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= DeviceExt
->CdInfo
.VolumeSpaceSize
;
193 FsSizeInfo
->CallerAvailableAllocationUnits
.QuadPart
= 0;
194 FsSizeInfo
->ActualAvailableAllocationUnits
.QuadPart
= 0;
195 FsSizeInfo
->SectorsPerAllocationUnit
= 1;
196 FsSizeInfo
->BytesPerSector
= BLOCKSIZE
;
198 DPRINT("Finished CdfsGetFsFullSizeInformation()\n");
199 if (NT_SUCCESS(Status
))
200 *BufferLength
-= sizeof(FILE_FS_FULL_SIZE_INFORMATION
);
208 CdfsQueryVolumeInformation(
209 PCDFS_IRP_CONTEXT IrpContext
)
212 PDEVICE_OBJECT DeviceObject
;
213 FS_INFORMATION_CLASS FsInformationClass
;
214 PIO_STACK_LOCATION Stack
;
215 NTSTATUS Status
= STATUS_SUCCESS
;
219 DPRINT("CdfsQueryVolumeInformation() called\n");
223 Irp
= IrpContext
->Irp
;
224 DeviceObject
= IrpContext
->DeviceObject
;
225 Stack
= IrpContext
->Stack
;
226 FsInformationClass
= Stack
->Parameters
.QueryVolume
.FsInformationClass
;
227 BufferLength
= Stack
->Parameters
.QueryVolume
.Length
;
228 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
230 DPRINT("FsInformationClass %d\n", FsInformationClass
);
231 DPRINT("SystemBuffer %p\n", SystemBuffer
);
233 switch (FsInformationClass
)
235 case FileFsVolumeInformation
:
236 Status
= CdfsGetFsVolumeInformation(DeviceObject
,
241 case FileFsAttributeInformation
:
242 Status
= CdfsGetFsAttributeInformation(DeviceObject
->DeviceExtension
,
247 case FileFsSizeInformation
:
248 Status
= CdfsGetFsSizeInformation(DeviceObject
,
253 case FileFsDeviceInformation
:
254 Status
= CdfsGetFsDeviceInformation(DeviceObject
,
259 case FileFsFullSizeInformation
:
260 Status
= CdfsGetFsFullSizeInformation(DeviceObject
,
266 Status
= STATUS_NOT_SUPPORTED
;
269 if (NT_SUCCESS(Status
))
270 Irp
->IoStatus
.Information
=
271 Stack
->Parameters
.QueryVolume
.Length
- BufferLength
;
273 Irp
->IoStatus
.Information
= 0;
281 CdfsSetVolumeInformation(
282 PCDFS_IRP_CONTEXT IrpContext
)
284 DPRINT("CdfsSetVolumeInformation() called\n");
288 IrpContext
->Irp
->IoStatus
.Information
= 0;
290 return STATUS_NOT_SUPPORTED
;