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: services/fs/vfat/volume.c
23 * PURPOSE: CDROM (ISO 9660) filesystem driver
24 * PROGRAMMER: Art Yerkes
28 /* INCLUDES *****************************************************************/
35 /* FUNCTIONS ****************************************************************/
38 CdfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject
,
39 PFILE_FS_VOLUME_INFORMATION FsVolumeInfo
,
42 DPRINT("CdfsGetFsVolumeInformation() called\n");
43 DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo
);
44 DPRINT("BufferLength %lu\n", *BufferLength
);
46 DPRINT("Vpb %p\n", DeviceObject
->Vpb
);
48 DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
));
49 DPRINT("LabelLength %hu\n", DeviceObject
->Vpb
->VolumeLabelLength
);
50 DPRINT("Label %*.S\n", DeviceObject
->Vpb
->VolumeLabelLength
/ sizeof(WCHAR
), DeviceObject
->Vpb
->VolumeLabel
);
52 if (*BufferLength
< sizeof(FILE_FS_VOLUME_INFORMATION
))
53 return STATUS_INFO_LENGTH_MISMATCH
;
55 if (*BufferLength
< (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
))
56 return STATUS_BUFFER_OVERFLOW
;
59 FsVolumeInfo
->VolumeSerialNumber
= DeviceObject
->Vpb
->SerialNumber
;
60 FsVolumeInfo
->VolumeLabelLength
= DeviceObject
->Vpb
->VolumeLabelLength
;
61 memcpy(FsVolumeInfo
->VolumeLabel
,
62 DeviceObject
->Vpb
->VolumeLabel
,
63 DeviceObject
->Vpb
->VolumeLabelLength
);
66 FsVolumeInfo
->VolumeCreationTime
.QuadPart
= 0;
67 FsVolumeInfo
->SupportsObjects
= FALSE
;
69 DPRINT("Finished FsdGetFsVolumeInformation()\n");
71 *BufferLength
-= (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
);
73 DPRINT("BufferLength %lu\n", *BufferLength
);
75 return(STATUS_SUCCESS
);
80 CdfsGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt
,
81 PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo
,
84 DPRINT("CdfsGetFsAttributeInformation()\n");
85 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo
);
86 DPRINT("BufferLength %lu\n", *BufferLength
);
87 DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8));
89 UNREFERENCED_PARAMETER(DeviceExt
);
91 if (*BufferLength
< sizeof (FILE_FS_ATTRIBUTE_INFORMATION
))
92 return STATUS_INFO_LENGTH_MISMATCH
;
94 if (*BufferLength
< (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8))
95 return STATUS_BUFFER_OVERFLOW
;
97 FsAttributeInfo
->FileSystemAttributes
=
98 FILE_CASE_PRESERVED_NAMES
| FILE_UNICODE_ON_DISK
;
99 FsAttributeInfo
->MaximumComponentNameLength
= 255;
100 FsAttributeInfo
->FileSystemNameLength
= 8;
102 memcpy(FsAttributeInfo
->FileSystemName
, L
"CDFS", 8);
104 DPRINT("Finished FsdGetFsAttributeInformation()\n");
106 *BufferLength
-= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8);
107 DPRINT("BufferLength %lu\n", *BufferLength
);
109 return(STATUS_SUCCESS
);
114 CdfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject
,
115 PFILE_FS_SIZE_INFORMATION FsSizeInfo
,
118 PDEVICE_EXTENSION DeviceExt
;
119 NTSTATUS Status
= STATUS_SUCCESS
;
121 DPRINT("CdfsGetFsSizeInformation()\n");
122 DPRINT("FsSizeInfo = %p\n", FsSizeInfo
);
124 if (*BufferLength
< sizeof(FILE_FS_SIZE_INFORMATION
))
125 return(STATUS_BUFFER_OVERFLOW
);
127 DeviceExt
= DeviceObject
->DeviceExtension
;
129 FsSizeInfo
->AvailableAllocationUnits
.QuadPart
= 0;
130 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= DeviceExt
->CdInfo
.VolumeSpaceSize
;
131 FsSizeInfo
->SectorsPerAllocationUnit
= 1;
132 FsSizeInfo
->BytesPerSector
= BLOCKSIZE
;
134 DPRINT("Finished FsdGetFsSizeInformation()\n");
135 if (NT_SUCCESS(Status
))
136 *BufferLength
-= sizeof(FILE_FS_SIZE_INFORMATION
);
143 CdfsGetFsDeviceInformation
145 PDEVICE_OBJECT DeviceObject
,
146 PFILE_FS_DEVICE_INFORMATION FsDeviceInfo
,
150 DPRINT("CdfsGetFsDeviceInformation()\n");
151 DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo
);
152 DPRINT("BufferLength %lu\n", *BufferLength
);
153 DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION
));
155 if (*BufferLength
< sizeof(FILE_FS_DEVICE_INFORMATION
))
156 return(STATUS_BUFFER_OVERFLOW
);
158 FsDeviceInfo
->DeviceType
= FILE_DEVICE_CD_ROM
;
159 FsDeviceInfo
->Characteristics
= DeviceObject
->Characteristics
;
161 DPRINT("FsdGetFsDeviceInformation() finished.\n");
163 *BufferLength
-= sizeof(FILE_FS_DEVICE_INFORMATION
);
164 DPRINT("BufferLength %lu\n", *BufferLength
);
166 return(STATUS_SUCCESS
);
171 CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject
,
174 FS_INFORMATION_CLASS FsInformationClass
;
175 PIO_STACK_LOCATION Stack
;
176 NTSTATUS Status
= STATUS_SUCCESS
;
180 DPRINT("CdfsQueryVolumeInformation() called\n");
182 Stack
= IoGetCurrentIrpStackLocation(Irp
);
183 FsInformationClass
= Stack
->Parameters
.QueryVolume
.FsInformationClass
;
184 BufferLength
= Stack
->Parameters
.QueryVolume
.Length
;
185 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
187 DPRINT("FsInformationClass %d\n", FsInformationClass
);
188 DPRINT("SystemBuffer %p\n", SystemBuffer
);
190 switch (FsInformationClass
)
192 case FileFsVolumeInformation
:
193 Status
= CdfsGetFsVolumeInformation(DeviceObject
,
198 case FileFsAttributeInformation
:
199 Status
= CdfsGetFsAttributeInformation(DeviceObject
->DeviceExtension
,
204 case FileFsSizeInformation
:
205 Status
= CdfsGetFsSizeInformation(DeviceObject
,
210 case FileFsDeviceInformation
:
211 Status
= CdfsGetFsDeviceInformation(DeviceObject
,
217 Status
= STATUS_NOT_SUPPORTED
;
220 Irp
->IoStatus
.Status
= Status
;
221 if (NT_SUCCESS(Status
))
222 Irp
->IoStatus
.Information
=
223 Stack
->Parameters
.QueryVolume
.Length
- BufferLength
;
225 Irp
->IoStatus
.Information
= 0;
226 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
233 CdfsSetVolumeInformation(PDEVICE_OBJECT DeviceObject
,
236 DPRINT("CdfsSetVolumeInformation() called\n");
238 UNREFERENCED_PARAMETER(DeviceObject
);
240 Irp
->IoStatus
.Status
= STATUS_NOT_SUPPORTED
;
241 Irp
->IoStatus
.Information
= 0;
242 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
244 return(STATUS_NOT_SUPPORTED
);