mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 01:24:11 +00:00
[FS_REC]
- Add a detection routine for CDFS (ISO-9660) volumes that verifies the Primary Volume Descriptor. - Use this to also detect CDFS on disks and load the CDFS driver if it has not been loaded yet (e.g. when a bootcd/livecd flashed USB drive is inserted at boot of an installed ReactOS). - Fix a comment in udfs.c. svn path=/trunk/; revision=75630
This commit is contained in:
parent
ecc55a34f2
commit
4f8ba0560c
4 changed files with 106 additions and 11 deletions
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* PROJECT: ReactOS File System Recognizer
|
||||||
* PROJECT: ReactOS File System Recognizer
|
* LICENSE: GPL-2.0 (https://spdx.org/licenses/GPL-2.0)
|
||||||
* FILE: drivers/filesystems/fs_rec/cdfs.c
|
* PURPOSE: CDFS Recognizer
|
||||||
* PURPOSE: CDFS Recognizer
|
* COPYRIGHT: Copyright 2002 Eric Kohl
|
||||||
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
|
* Copyright 2007 Alex Ionescu <alex.ionescu@reactos.org>
|
||||||
* Eric Kohl
|
* Copyright 2017 Colin Finck <colin@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -14,13 +14,60 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include "cdfs.h"
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
FsRecIsCdfsVolume(IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN ULONG SectorSize)
|
||||||
|
{
|
||||||
|
BOOLEAN bReturnValue = FALSE;
|
||||||
|
LARGE_INTEGER Offset;
|
||||||
|
PVD_HEADER pVdHeader = NULL;
|
||||||
|
PAGED_CODE();
|
||||||
|
|
||||||
|
// Read the Primary Volume Descriptor.
|
||||||
|
Offset.QuadPart = VD_HEADER_OFFSET;
|
||||||
|
if (!FsRecReadBlock(DeviceObject, &Offset, sizeof(VD_HEADER), SectorSize, (PVOID*)&pVdHeader, NULL))
|
||||||
|
{
|
||||||
|
// We cannot read this block, so no reason to let the CDFS driver try it.
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the fields.
|
||||||
|
if (pVdHeader->Type != VD_TYPE_PRIMARY)
|
||||||
|
goto Cleanup;
|
||||||
|
|
||||||
|
DPRINT("pVdHeader->Type verified!\n");
|
||||||
|
|
||||||
|
if (RtlCompareMemory(pVdHeader->Identifier, VD_IDENTIFIER, VD_IDENTIFIER_LENGTH) != VD_IDENTIFIER_LENGTH)
|
||||||
|
goto Cleanup;
|
||||||
|
|
||||||
|
DPRINT("pVdHeader->Identifier verified!\n");
|
||||||
|
|
||||||
|
if (pVdHeader->Version != VD_VERSION)
|
||||||
|
goto Cleanup;
|
||||||
|
|
||||||
|
DPRINT("pVdHeader->Version verified! This is a CDFS volume!\n");
|
||||||
|
|
||||||
|
bReturnValue = TRUE;
|
||||||
|
|
||||||
|
Cleanup:
|
||||||
|
if (pVdHeader)
|
||||||
|
ExFreePool(pVdHeader);
|
||||||
|
|
||||||
|
return bReturnValue;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject,
|
FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PDEVICE_OBJECT MountDevice;
|
||||||
|
ULONG SectorSize;
|
||||||
PIO_STACK_LOCATION Stack;
|
PIO_STACK_LOCATION Stack;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
@ -31,8 +78,21 @@ FsRecCdfsFsControl(IN PDEVICE_OBJECT DeviceObject,
|
||||||
{
|
{
|
||||||
case IRP_MN_MOUNT_VOLUME:
|
case IRP_MN_MOUNT_VOLUME:
|
||||||
|
|
||||||
/* We don't validate */
|
/* Assume failure */
|
||||||
Status = STATUS_FS_DRIVER_REQUIRED;
|
Status = STATUS_UNRECOGNIZED_VOLUME;
|
||||||
|
|
||||||
|
/* Get the device object and request the sector size */
|
||||||
|
MountDevice = Stack->Parameters.MountVolume.DeviceObject;
|
||||||
|
if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
|
||||||
|
{
|
||||||
|
/* Check if it's an actual CDFS (ISO-9660) volume */
|
||||||
|
if (FsRecIsCdfsVolume(MountDevice, SectorSize))
|
||||||
|
{
|
||||||
|
/* It is! */
|
||||||
|
Status = STATUS_FS_DRIVER_REQUIRED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_LOAD_FILE_SYSTEM:
|
case IRP_MN_LOAD_FILE_SYSTEM:
|
||||||
|
|
24
reactos/drivers/filesystems/fs_rec/cdfs.h
Normal file
24
reactos/drivers/filesystems/fs_rec/cdfs.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS File System Recognizer
|
||||||
|
* LICENSE: GPL-2.0 (https://spdx.org/licenses/GPL-2.0+)
|
||||||
|
* PURPOSE: CDFS Recognizer
|
||||||
|
* COPYRIGHT: Copyright 2017 Colin Finck <colin@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Information from http://wiki.osdev.org/ISO_9660#Volume_Descriptors
|
||||||
|
|
||||||
|
// Structures
|
||||||
|
typedef struct _VD_HEADER
|
||||||
|
{
|
||||||
|
char Type;
|
||||||
|
char Identifier[5];
|
||||||
|
char Version;
|
||||||
|
}
|
||||||
|
VD_HEADER, *PVD_HEADER;
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
#define VD_HEADER_OFFSET 32768 // Offset of the VD Header
|
||||||
|
#define VD_IDENTIFIER "CD001" // Identifier that must be in the Volume Descriptor
|
||||||
|
#define VD_IDENTIFIER_LENGTH 5 // Character count of VD_IDENTIFIER
|
||||||
|
#define VD_TYPE_PRIMARY 1 // Type code for Primary Volume Descriptor
|
||||||
|
#define VD_VERSION 1 // Volume Descriptor Version
|
|
@ -316,6 +316,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
{
|
{
|
||||||
ULONG DeviceCount = 0;
|
ULONG DeviceCount = 0;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PDEVICE_OBJECT CdfsObject;
|
||||||
PDEVICE_OBJECT UdfsObject;
|
PDEVICE_OBJECT UdfsObject;
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
|
@ -340,16 +341,26 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
||||||
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FsRecFsControl;
|
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = FsRecFsControl;
|
||||||
DriverObject->DriverUnload = FsRecUnload;
|
DriverObject->DriverUnload = FsRecUnload;
|
||||||
|
|
||||||
/* Register CDFS */
|
/* Register CDFS for CDs */
|
||||||
Status = FsRecRegisterFs(DriverObject,
|
Status = FsRecRegisterFs(DriverObject,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
&CdfsObject,
|
||||||
L"\\Cdfs",
|
L"\\Cdfs",
|
||||||
L"\\FileSystem\\CdfsRecognizer",
|
L"\\FileSystem\\CdfsRecognizer",
|
||||||
FS_TYPE_CDFS,
|
FS_TYPE_CDFS,
|
||||||
FILE_DEVICE_CD_ROM_FILE_SYSTEM);
|
FILE_DEVICE_CD_ROM_FILE_SYSTEM);
|
||||||
if (NT_SUCCESS(Status)) DeviceCount++;
|
if (NT_SUCCESS(Status)) DeviceCount++;
|
||||||
|
|
||||||
|
/* Register CDFS for HDDs */
|
||||||
|
Status = FsRecRegisterFs(DriverObject,
|
||||||
|
CdfsObject,
|
||||||
|
NULL,
|
||||||
|
L"\\CdfsHdd",
|
||||||
|
L"\\FileSystem\\CdfsHddRecognizer",
|
||||||
|
FS_TYPE_CDFS,
|
||||||
|
FILE_DEVICE_DISK_FILE_SYSTEM);
|
||||||
|
if (NT_SUCCESS(Status)) DeviceCount++;
|
||||||
|
|
||||||
/* Register UDFS for CDs */
|
/* Register UDFS for CDs */
|
||||||
Status = FsRecRegisterFs(DriverObject,
|
Status = FsRecRegisterFs(DriverObject,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -125,7 +125,7 @@ FsRecUdfsFsControl(IN PDEVICE_OBJECT DeviceObject,
|
||||||
MountDevice = Stack->Parameters.MountVolume.DeviceObject;
|
MountDevice = Stack->Parameters.MountVolume.DeviceObject;
|
||||||
if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
|
if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
|
||||||
{
|
{
|
||||||
/* Check if it's an actual FAT volume */
|
/* Check if it's an actual UDF volume */
|
||||||
if (FsRecIsUdfsVolume(MountDevice, SectorSize))
|
if (FsRecIsUdfsVolume(MountDevice, SectorSize))
|
||||||
{
|
{
|
||||||
/* It is! */
|
/* It is! */
|
||||||
|
|
Loading…
Reference in a new issue