2002-04-15 20:39:49 +00:00
|
|
|
/*
|
2013-03-16 19:49:08 +00:00
|
|
|
* ReactOS kernel
|
|
|
|
* Copyright (C) 2002, 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2015-06-01 15:00:51 +00:00
|
|
|
* FILE: drivers/filesystems/cdfs/volume.c
|
2013-03-16 19:49:08 +00:00
|
|
|
* PURPOSE: CDROM (ISO 9660) filesystem driver
|
|
|
|
* PROGRAMMER: Art Yerkes
|
|
|
|
* Eric Kohl
|
|
|
|
*/
|
2002-04-15 20:39:49 +00:00
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2005-07-20 02:52:52 +00:00
|
|
|
#include "cdfs.h"
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2002-05-01 21:52:05 +00:00
|
|
|
#define NDEBUG
|
2002-04-15 20:39:49 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
CdfsGetFsVolumeInformation(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_FS_VOLUME_INFORMATION FsVolumeInfo,
|
|
|
|
PULONG BufferLength)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("CdfsGetFsVolumeInformation() called\n");
|
|
|
|
DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
|
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Vpb %p\n", DeviceObject->Vpb);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength));
|
|
|
|
DPRINT("LabelLength %hu\n", DeviceObject->Vpb->VolumeLabelLength);
|
|
|
|
DPRINT("Label %*.S\n", DeviceObject->Vpb->VolumeLabelLength / sizeof(WCHAR), DeviceObject->Vpb->VolumeLabel);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (*BufferLength < sizeof(FILE_FS_VOLUME_INFORMATION))
|
|
|
|
return STATUS_INFO_LENGTH_MISMATCH;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength))
|
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
/* valid entries */
|
|
|
|
FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
|
|
|
|
FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength;
|
|
|
|
memcpy(FsVolumeInfo->VolumeLabel,
|
2015-06-01 15:00:51 +00:00
|
|
|
DeviceObject->Vpb->VolumeLabel,
|
|
|
|
DeviceObject->Vpb->VolumeLabelLength);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
/* dummy entries */
|
|
|
|
FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
|
|
|
|
FsVolumeInfo->SupportsObjects = FALSE;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Finished FsdGetFsVolumeInformation()\n");
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
*BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
return STATUS_SUCCESS;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
CdfsGetFsAttributeInformation(
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo,
|
|
|
|
PULONG BufferLength)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("CdfsGetFsAttributeInformation()\n");
|
|
|
|
DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
|
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
|
|
|
DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8));
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2013-05-11 09:24:31 +00:00
|
|
|
UNREFERENCED_PARAMETER(DeviceExt);
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (*BufferLength < sizeof (FILE_FS_ATTRIBUTE_INFORMATION))
|
|
|
|
return STATUS_INFO_LENGTH_MISMATCH;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (*BufferLength < (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8))
|
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
FsAttributeInfo->FileSystemAttributes =
|
2015-05-10 14:09:47 +00:00
|
|
|
FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK | FILE_READ_ONLY_VOLUME;
|
2009-02-03 14:50:50 +00:00
|
|
|
FsAttributeInfo->MaximumComponentNameLength = 255;
|
|
|
|
FsAttributeInfo->FileSystemNameLength = 8;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
memcpy(FsAttributeInfo->FileSystemName, L"CDFS", 8);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Finished FsdGetFsAttributeInformation()\n");
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
*BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8);
|
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
return STATUS_SUCCESS;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS
|
2015-06-01 15:00:51 +00:00
|
|
|
CdfsGetFsSizeInformation(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_FS_SIZE_INFORMATION FsSizeInfo,
|
|
|
|
PULONG BufferLength)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExt;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("CdfsGetFsSizeInformation()\n");
|
|
|
|
DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (*BufferLength < sizeof(FILE_FS_SIZE_INFORMATION))
|
2015-06-01 15:00:51 +00:00
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DeviceExt = DeviceObject->DeviceExtension;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
FsSizeInfo->AvailableAllocationUnits.QuadPart = 0;
|
|
|
|
FsSizeInfo->TotalAllocationUnits.QuadPart = DeviceExt->CdInfo.VolumeSpaceSize;
|
|
|
|
FsSizeInfo->SectorsPerAllocationUnit = 1;
|
|
|
|
FsSizeInfo->BytesPerSector = BLOCKSIZE;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("Finished FsdGetFsSizeInformation()\n");
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
*BufferLength -= sizeof(FILE_FS_SIZE_INFORMATION);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
return Status;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
CdfsGetFsDeviceInformation(
|
2009-12-06 18:49:19 +00:00
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
|
2015-06-01 15:00:51 +00:00
|
|
|
PULONG BufferLength)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("CdfsGetFsDeviceInformation()\n");
|
|
|
|
DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo);
|
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
|
|
|
DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION));
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (*BufferLength < sizeof(FILE_FS_DEVICE_INFORMATION))
|
2015-06-01 15:00:51 +00:00
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
FsDeviceInfo->DeviceType = FILE_DEVICE_CD_ROM;
|
2009-12-06 18:49:19 +00:00
|
|
|
FsDeviceInfo->Characteristics = DeviceObject->Characteristics;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("FsdGetFsDeviceInformation() finished.\n");
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
*BufferLength -= sizeof(FILE_FS_DEVICE_INFORMATION);
|
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
return STATUS_SUCCESS;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-02 12:37:37 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
CdfsGetFsFullSizeInformation(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_FS_FULL_SIZE_INFORMATION FsSizeInfo,
|
|
|
|
PULONG BufferLength)
|
|
|
|
{
|
|
|
|
PDEVICE_EXTENSION DeviceExt;
|
2015-06-02 13:14:33 +00:00
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2015-06-02 12:37:37 +00:00
|
|
|
|
|
|
|
DPRINT("CdfsGetFsFullSizeInformation()\n");
|
|
|
|
DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
|
|
|
|
|
|
|
|
if (*BufferLength < sizeof(FILE_FS_FULL_SIZE_INFORMATION))
|
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
|
|
|
|
|
|
|
DeviceExt = DeviceObject->DeviceExtension;
|
|
|
|
|
|
|
|
FsSizeInfo->TotalAllocationUnits.QuadPart = DeviceExt->CdInfo.VolumeSpaceSize;
|
|
|
|
FsSizeInfo->CallerAvailableAllocationUnits.QuadPart = 0;
|
|
|
|
FsSizeInfo->ActualAvailableAllocationUnits.QuadPart = 0;
|
|
|
|
FsSizeInfo->SectorsPerAllocationUnit = 1;
|
|
|
|
FsSizeInfo->BytesPerSector = BLOCKSIZE;
|
|
|
|
|
|
|
|
DPRINT("Finished CdfsGetFsFullSizeInformation()\n");
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
*BufferLength -= sizeof(FILE_FS_FULL_SIZE_INFORMATION);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2015-06-01 13:13:18 +00:00
|
|
|
CdfsQueryVolumeInformation(
|
|
|
|
PCDFS_IRP_CONTEXT IrpContext)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2015-06-01 13:13:18 +00:00
|
|
|
PIRP Irp;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
2009-02-03 14:50:50 +00:00
|
|
|
FS_INFORMATION_CLASS FsInformationClass;
|
|
|
|
PIO_STACK_LOCATION Stack;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
PVOID SystemBuffer;
|
|
|
|
ULONG BufferLength;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("CdfsQueryVolumeInformation() called\n");
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2015-06-01 13:13:18 +00:00
|
|
|
ASSERT(IrpContext);
|
|
|
|
|
|
|
|
Irp = IrpContext->Irp;
|
|
|
|
DeviceObject = IrpContext->DeviceObject;
|
|
|
|
Stack = IrpContext->Stack;
|
2009-02-03 14:50:50 +00:00
|
|
|
FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
|
|
|
|
BufferLength = Stack->Parameters.QueryVolume.Length;
|
|
|
|
SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("FsInformationClass %d\n", FsInformationClass);
|
2013-05-11 09:24:31 +00:00
|
|
|
DPRINT("SystemBuffer %p\n", SystemBuffer);
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
switch (FsInformationClass)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2015-06-01 15:00:51 +00:00
|
|
|
case FileFsVolumeInformation:
|
|
|
|
Status = CdfsGetFsVolumeInformation(DeviceObject,
|
|
|
|
SystemBuffer,
|
|
|
|
&BufferLength);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FileFsAttributeInformation:
|
|
|
|
Status = CdfsGetFsAttributeInformation(DeviceObject->DeviceExtension,
|
|
|
|
SystemBuffer,
|
|
|
|
&BufferLength);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FileFsSizeInformation:
|
|
|
|
Status = CdfsGetFsSizeInformation(DeviceObject,
|
|
|
|
SystemBuffer,
|
|
|
|
&BufferLength);
|
2015-06-02 12:37:37 +00:00
|
|
|
break;
|
2009-02-03 14:50:50 +00:00
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
case FileFsDeviceInformation:
|
|
|
|
Status = CdfsGetFsDeviceInformation(DeviceObject,
|
|
|
|
SystemBuffer,
|
|
|
|
&BufferLength);
|
|
|
|
break;
|
2009-02-03 14:50:50 +00:00
|
|
|
|
2015-06-02 12:37:37 +00:00
|
|
|
case FileFsFullSizeInformation:
|
|
|
|
Status = CdfsGetFsFullSizeInformation(DeviceObject,
|
|
|
|
SystemBuffer,
|
|
|
|
&BufferLength);
|
|
|
|
break;
|
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
default:
|
|
|
|
Status = STATUS_NOT_SUPPORTED;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
2009-02-03 14:50:50 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
Irp->IoStatus.Information =
|
|
|
|
Stack->Parameters.QueryVolume.Length - BufferLength;
|
|
|
|
else
|
|
|
|
Irp->IoStatus.Information = 0;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
return Status;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2015-06-01 13:13:18 +00:00
|
|
|
CdfsSetVolumeInformation(
|
|
|
|
PCDFS_IRP_CONTEXT IrpContext)
|
2002-04-15 20:39:49 +00:00
|
|
|
{
|
2009-02-03 14:50:50 +00:00
|
|
|
DPRINT("CdfsSetVolumeInformation() called\n");
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2015-06-01 13:13:18 +00:00
|
|
|
ASSERT(IrpContext);
|
2013-05-11 09:24:31 +00:00
|
|
|
|
2015-06-21 14:02:35 +00:00
|
|
|
IrpContext->Irp->IoStatus.Information = 0;
|
2002-04-15 20:39:49 +00:00
|
|
|
|
2015-06-01 15:00:51 +00:00
|
|
|
return STATUS_NOT_SUPPORTED;
|
2002-04-15 20:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|