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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/fs/vfat/volume.c
24 * PURPOSE: CDROM (ISO 9660) filesystem driver
25 * PROGRAMMER: Art Yerkes
29 /* INCLUDES *****************************************************************/
36 /* FUNCTIONS ****************************************************************/
39 CdfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject
,
40 PFILE_FS_VOLUME_INFORMATION FsVolumeInfo
,
43 DPRINT("CdfsGetFsVolumeInformation() called\n");
44 DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo
);
45 DPRINT("BufferLength %lu\n", *BufferLength
);
47 DPRINT("Vpb %p\n", DeviceObject
->Vpb
);
49 DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
));
50 DPRINT("LabelLength %hu\n", DeviceObject
->Vpb
->VolumeLabelLength
);
51 DPRINT("Label %*.S\n", DeviceObject
->Vpb
->VolumeLabelLength
/ sizeof(WCHAR
), DeviceObject
->Vpb
->VolumeLabel
);
53 if (*BufferLength
< sizeof(FILE_FS_VOLUME_INFORMATION
))
54 return STATUS_INFO_LENGTH_MISMATCH
;
56 if (*BufferLength
< (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
))
57 return STATUS_BUFFER_OVERFLOW
;
60 FsVolumeInfo
->VolumeSerialNumber
= DeviceObject
->Vpb
->SerialNumber
;
61 FsVolumeInfo
->VolumeLabelLength
= DeviceObject
->Vpb
->VolumeLabelLength
;
62 memcpy(FsVolumeInfo
->VolumeLabel
,
63 DeviceObject
->Vpb
->VolumeLabel
,
64 DeviceObject
->Vpb
->VolumeLabelLength
);
67 FsVolumeInfo
->VolumeCreationTime
.QuadPart
= 0;
68 FsVolumeInfo
->SupportsObjects
= FALSE
;
70 DPRINT("Finished FsdGetFsVolumeInformation()\n");
72 *BufferLength
-= (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
);
74 DPRINT("BufferLength %lu\n", *BufferLength
);
76 return(STATUS_SUCCESS
);
81 CdfsGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt
,
82 PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo
,
85 DPRINT("CdfsGetFsAttributeInformation()\n");
86 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo
);
87 DPRINT("BufferLength %lu\n", *BufferLength
);
88 DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8));
90 if (*BufferLength
< sizeof (FILE_FS_ATTRIBUTE_INFORMATION
))
91 return STATUS_INFO_LENGTH_MISMATCH
;
93 if (*BufferLength
< (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8))
94 return STATUS_BUFFER_OVERFLOW
;
96 FsAttributeInfo
->FileSystemAttributes
=
97 FILE_CASE_PRESERVED_NAMES
| FILE_UNICODE_ON_DISK
;
98 FsAttributeInfo
->MaximumComponentNameLength
= 255;
99 FsAttributeInfo
->FileSystemNameLength
= 8;
101 memcpy(FsAttributeInfo
->FileSystemName
, L
"CDFS", 8);
103 DPRINT("Finished FsdGetFsAttributeInformation()\n");
105 *BufferLength
-= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8);
106 DPRINT("BufferLength %lu\n", *BufferLength
);
108 return(STATUS_SUCCESS
);
113 CdfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject
,
114 PFILE_FS_SIZE_INFORMATION FsSizeInfo
,
117 PDEVICE_EXTENSION DeviceExt
;
118 NTSTATUS Status
= STATUS_SUCCESS
;
120 DPRINT("CdfsGetFsSizeInformation()\n");
121 DPRINT("FsSizeInfo = %p\n", FsSizeInfo
);
123 if (*BufferLength
< sizeof(FILE_FS_SIZE_INFORMATION
))
124 return(STATUS_BUFFER_OVERFLOW
);
126 DeviceExt
= DeviceObject
->DeviceExtension
;
128 FsSizeInfo
->AvailableAllocationUnits
.QuadPart
= 0;
129 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= DeviceExt
->CdInfo
.VolumeSpaceSize
;
130 FsSizeInfo
->SectorsPerAllocationUnit
= 1;
131 FsSizeInfo
->BytesPerSector
= BLOCKSIZE
;
133 DPRINT("Finished FsdGetFsSizeInformation()\n");
134 if (NT_SUCCESS(Status
))
135 *BufferLength
-= sizeof(FILE_FS_SIZE_INFORMATION
);
142 CdfsGetFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo
,
145 DPRINT("CdfsGetFsDeviceInformation()\n");
146 DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo
);
147 DPRINT("BufferLength %lu\n", *BufferLength
);
148 DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION
));
150 if (*BufferLength
< sizeof(FILE_FS_DEVICE_INFORMATION
))
151 return(STATUS_BUFFER_OVERFLOW
);
153 FsDeviceInfo
->DeviceType
= FILE_DEVICE_CD_ROM
;
154 FsDeviceInfo
->Characteristics
= 0; /* FIXME: fix this !! */
156 DPRINT("FsdGetFsDeviceInformation() finished.\n");
158 *BufferLength
-= sizeof(FILE_FS_DEVICE_INFORMATION
);
159 DPRINT("BufferLength %lu\n", *BufferLength
);
161 return(STATUS_SUCCESS
);
166 CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject
,
169 FS_INFORMATION_CLASS FsInformationClass
;
170 PIO_STACK_LOCATION Stack
;
171 NTSTATUS Status
= STATUS_SUCCESS
;
175 DPRINT("CdfsQueryVolumeInformation() called\n");
177 Stack
= IoGetCurrentIrpStackLocation(Irp
);
178 FsInformationClass
= Stack
->Parameters
.QueryVolume
.FsInformationClass
;
179 BufferLength
= Stack
->Parameters
.QueryVolume
.Length
;
180 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
182 DPRINT("FsInformationClass %d\n", FsInformationClass
);
183 DPRINT("SystemBuffer %x\n", SystemBuffer
);
185 switch (FsInformationClass
)
187 case FileFsVolumeInformation
:
188 Status
= CdfsGetFsVolumeInformation(DeviceObject
,
193 case FileFsAttributeInformation
:
194 Status
= CdfsGetFsAttributeInformation(DeviceObject
->DeviceExtension
,
199 case FileFsSizeInformation
:
200 Status
= CdfsGetFsSizeInformation(DeviceObject
,
205 case FileFsDeviceInformation
:
206 Status
= CdfsGetFsDeviceInformation(SystemBuffer
,
211 Status
= STATUS_NOT_SUPPORTED
;
214 Irp
->IoStatus
.Status
= Status
;
215 if (NT_SUCCESS(Status
))
216 Irp
->IoStatus
.Information
=
217 Stack
->Parameters
.QueryVolume
.Length
- BufferLength
;
219 Irp
->IoStatus
.Information
= 0;
220 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
227 CdfsSetVolumeInformation(PDEVICE_OBJECT DeviceObject
,
230 DPRINT("CdfsSetVolumeInformation() called\n");
232 Irp
->IoStatus
.Status
= STATUS_NOT_SUPPORTED
;
233 Irp
->IoStatus
.Information
= 0;
234 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
236 return(STATUS_NOT_SUPPORTED
);