3 * Copyright (C) 2002 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
28 /* INCLUDES *****************************************************************/
30 #include <ddk/ntddk.h>
38 /* FUNCTIONS ****************************************************************/
41 CdfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject,
42 PFILE_FS_VOLUME_INFORMATION FsVolumeInfo,
47 DPRINT("CdfsGetFsVolumeInformation() called\n");
48 DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
49 DPRINT("BufferLength %lu\n", *BufferLength);
51 DPRINT("Vpb %p\n", DeviceObject->Vpb);
52 LabelLength = DeviceObject->Vpb->VolumeLabelLength;
54 DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION) + LabelLength*sizeof(WCHAR)));
55 DPRINT("LabelLength %lu\n", LabelLength);
56 DPRINT("Label %S\n", DeviceObject->Vpb->VolumeLabel);
58 if (*BufferLength < sizeof(FILE_FS_VOLUME_INFORMATION))
59 return STATUS_INFO_LENGTH_MISMATCH;
61 if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + LabelLength*sizeof(WCHAR)))
62 return STATUS_BUFFER_OVERFLOW;
65 FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
66 FsVolumeInfo->VolumeLabelLength = LabelLength * sizeof (WCHAR);
67 wcscpy(FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel);
70 FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
71 FsVolumeInfo->SupportsObjects = FALSE;
73 DPRINT("Finished FsdGetFsVolumeInformation()\n");
75 *BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + LabelLength * sizeof(WCHAR));
77 DPRINT("BufferLength %lu\n", *BufferLength);
79 return(STATUS_SUCCESS);
84 CdfsGetFsAttributeInformation(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 if (*BufferLength < sizeof (FILE_FS_ATTRIBUTE_INFORMATION))
94 return STATUS_INFO_LENGTH_MISMATCH;
96 if (*BufferLength < (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8))
97 return STATUS_BUFFER_OVERFLOW;
99 FsAttributeInfo->FileSystemAttributes =
100 FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK;
101 FsAttributeInfo->MaximumComponentNameLength = 255;
102 FsAttributeInfo->FileSystemNameLength = 8;
104 memcpy(FsAttributeInfo->FileSystemName, L"CDFS", 8);
106 DPRINT("Finished FsdGetFsAttributeInformation()\n");
108 *BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);
109 DPRINT("BufferLength %lu\n", *BufferLength);
111 return(STATUS_SUCCESS);
116 CdfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
117 PFILE_FS_SIZE_INFORMATION FsSizeInfo,
120 PDEVICE_EXTENSION DeviceExt;
121 NTSTATUS Status = STATUS_SUCCESS;
123 DPRINT("CdfsGetFsSizeInformation()\n");
124 DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
126 if (*BufferLength < sizeof(FILE_FS_SIZE_INFORMATION))
127 return(STATUS_BUFFER_OVERFLOW);
129 DeviceExt = DeviceObject->DeviceExtension;
131 FsSizeInfo->AvailableAllocationUnits.QuadPart = 0;
132 FsSizeInfo->TotalAllocationUnits.QuadPart = DeviceExt->CdInfo.VolumeSpaceSize;
133 FsSizeInfo->SectorsPerAllocationUnit = 1;
134 FsSizeInfo->BytesPerSector = BLOCKSIZE;
136 DPRINT("Finished FsdGetFsSizeInformation()\n");
137 if (NT_SUCCESS(Status))
138 *BufferLength -= sizeof(FILE_FS_SIZE_INFORMATION);
145 CdfsGetFsDeviceInformation(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 = 0; /* FIXME: fix this !! */
159 DPRINT("FsdGetFsDeviceInformation() finished.\n");
161 *BufferLength -= sizeof(FILE_FS_DEVICE_INFORMATION);
162 DPRINT("BufferLength %lu\n", *BufferLength);
164 return(STATUS_SUCCESS);
170 CdfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
173 FS_INFORMATION_CLASS FsInformationClass;
174 PIO_STACK_LOCATION Stack;
175 NTSTATUS Status = STATUS_SUCCESS;
179 DPRINT("CdfsQueryVolumeInformation() called\n");
181 Stack = IoGetCurrentIrpStackLocation(Irp);
182 FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
183 BufferLength = Stack->Parameters.QueryVolume.Length;
184 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
186 DPRINT("FsInformationClass %d\n", FsInformationClass);
187 DPRINT("SystemBuffer %x\n", SystemBuffer);
189 switch (FsInformationClass)
191 case FileFsVolumeInformation:
192 Status = CdfsGetFsVolumeInformation(DeviceObject,
197 case FileFsAttributeInformation:
198 Status = CdfsGetFsAttributeInformation(DeviceObject->DeviceExtension,
203 case FileFsSizeInformation:
204 Status = CdfsGetFsSizeInformation(DeviceObject,
209 case FileFsDeviceInformation:
210 Status = CdfsGetFsDeviceInformation(SystemBuffer,
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);