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 if (*BufferLength
< sizeof (FILE_FS_ATTRIBUTE_INFORMATION
))
90 return STATUS_INFO_LENGTH_MISMATCH
;
92 if (*BufferLength
< (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8))
93 return STATUS_BUFFER_OVERFLOW
;
95 FsAttributeInfo
->FileSystemAttributes
=
96 FILE_CASE_PRESERVED_NAMES
| FILE_UNICODE_ON_DISK
;
97 FsAttributeInfo
->MaximumComponentNameLength
= 255;
98 FsAttributeInfo
->FileSystemNameLength
= 8;
100 memcpy(FsAttributeInfo
->FileSystemName
, L
"CDFS", 8);
102 DPRINT("Finished FsdGetFsAttributeInformation()\n");
104 *BufferLength
-= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8);
105 DPRINT("BufferLength %lu\n", *BufferLength
);
107 return(STATUS_SUCCESS
);
112 CdfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject
,
113 PFILE_FS_SIZE_INFORMATION FsSizeInfo
,
116 PDEVICE_EXTENSION DeviceExt
;
117 NTSTATUS Status
= STATUS_SUCCESS
;
119 DPRINT("CdfsGetFsSizeInformation()\n");
120 DPRINT("FsSizeInfo = %p\n", FsSizeInfo
);
122 if (*BufferLength
< sizeof(FILE_FS_SIZE_INFORMATION
))
123 return(STATUS_BUFFER_OVERFLOW
);
125 DeviceExt
= DeviceObject
->DeviceExtension
;
127 FsSizeInfo
->AvailableAllocationUnits
.QuadPart
= 0;
128 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= DeviceExt
->CdInfo
.VolumeSpaceSize
;
129 FsSizeInfo
->SectorsPerAllocationUnit
= 1;
130 FsSizeInfo
->BytesPerSector
= BLOCKSIZE
;
132 DPRINT("Finished FsdGetFsSizeInformation()\n");
133 if (NT_SUCCESS(Status
))
134 *BufferLength
-= sizeof(FILE_FS_SIZE_INFORMATION
);
141 CdfsGetFsDeviceInformation
143 PDEVICE_OBJECT DeviceObject
,
144 PFILE_FS_DEVICE_INFORMATION FsDeviceInfo
,
148 DPRINT("CdfsGetFsDeviceInformation()\n");
149 DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo
);
150 DPRINT("BufferLength %lu\n", *BufferLength
);
151 DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION
));
153 if (*BufferLength
< sizeof(FILE_FS_DEVICE_INFORMATION
))
154 return(STATUS_BUFFER_OVERFLOW
);
156 FsDeviceInfo
->DeviceType
= FILE_DEVICE_CD_ROM
;
157 FsDeviceInfo
->Characteristics
= DeviceObject
->Characteristics
;
159 DPRINT("FsdGetFsDeviceInformation() finished.\n");
161 *BufferLength
-= sizeof(FILE_FS_DEVICE_INFORMATION
);
162 DPRINT("BufferLength %lu\n", *BufferLength
);
164 return(STATUS_SUCCESS
);
169 CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject
,
172 FS_INFORMATION_CLASS FsInformationClass
;
173 PIO_STACK_LOCATION Stack
;
174 NTSTATUS Status
= STATUS_SUCCESS
;
178 DPRINT("CdfsQueryVolumeInformation() called\n");
180 Stack
= IoGetCurrentIrpStackLocation(Irp
);
181 FsInformationClass
= Stack
->Parameters
.QueryVolume
.FsInformationClass
;
182 BufferLength
= Stack
->Parameters
.QueryVolume
.Length
;
183 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
185 DPRINT("FsInformationClass %d\n", FsInformationClass
);
186 DPRINT("SystemBuffer %x\n", SystemBuffer
);
188 switch (FsInformationClass
)
190 case FileFsVolumeInformation
:
191 Status
= CdfsGetFsVolumeInformation(DeviceObject
,
196 case FileFsAttributeInformation
:
197 Status
= CdfsGetFsAttributeInformation(DeviceObject
->DeviceExtension
,
202 case FileFsSizeInformation
:
203 Status
= CdfsGetFsSizeInformation(DeviceObject
,
208 case FileFsDeviceInformation
:
209 Status
= CdfsGetFsDeviceInformation(DeviceObject
,
215 Status
= STATUS_NOT_SUPPORTED
;
218 Irp
->IoStatus
.Status
= Status
;
219 if (NT_SUCCESS(Status
))
220 Irp
->IoStatus
.Information
=
221 Stack
->Parameters
.QueryVolume
.Length
- BufferLength
;
223 Irp
->IoStatus
.Information
= 0;
224 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
231 CdfsSetVolumeInformation(PDEVICE_OBJECT DeviceObject
,
234 DPRINT("CdfsSetVolumeInformation() called\n");
236 Irp
->IoStatus
.Status
= STATUS_NOT_SUPPORTED
;
237 Irp
->IoStatus
.Information
= 0;
238 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
240 return(STATUS_NOT_SUPPORTED
);