mirror of
https://github.com/reactos/reactos.git
synced 2024-11-09 16:20:37 +00:00
c2d0d784c7
- Create a branch to do a proper merge of USB work from a trunk base instead of from cmake-bringup - In the future, DO NOT under any circumstances branch another branch. This leads to merge problems! svn path=/branches/usb-bringup-trunk/; revision=55018
148 lines
3.9 KiB
C
148 lines
3.9 KiB
C
/*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS File System Recognizer
|
|
* FILE: drivers/filesystems/fs_rec/udfs.c
|
|
* PURPOSE: USFS Recognizer
|
|
* PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
|
|
* Eric Kohl
|
|
*/
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
#include "fs_rec.h"
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
#include "udfs.h"
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
BOOLEAN
|
|
NTAPI
|
|
FsRecIsUdfsVolume(IN PDEVICE_OBJECT DeviceObject,
|
|
IN ULONG SectorSize)
|
|
{
|
|
PVOLSTRUCTDESC VolumeStructDesc = NULL;
|
|
LARGE_INTEGER Offset;
|
|
ULONG State = 0;
|
|
PAGED_CODE();
|
|
|
|
Offset.QuadPart = UDFS_VRS_START_OFFSET;
|
|
while (TRUE)
|
|
{
|
|
if (!FsRecReadBlock(DeviceObject,
|
|
&Offset,
|
|
SectorSize,
|
|
SectorSize,
|
|
(PVOID)&VolumeStructDesc,
|
|
NULL))
|
|
{
|
|
break;
|
|
}
|
|
|
|
switch (State)
|
|
{
|
|
case 0:
|
|
|
|
if (!strncmp((const char*)VolumeStructDesc->Ident,
|
|
VSD_STD_ID_BEA01,
|
|
VSD_STD_ID_LEN))
|
|
{
|
|
State = 1;
|
|
}
|
|
else
|
|
{
|
|
ExFreePool(VolumeStructDesc);
|
|
return FALSE;
|
|
}
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!strncmp((const char*)VolumeStructDesc->Ident,
|
|
VSD_STD_ID_NSR03,
|
|
VSD_STD_ID_LEN) ||
|
|
!strncmp((const char*)VolumeStructDesc->Ident,
|
|
VSD_STD_ID_NSR02,
|
|
VSD_STD_ID_LEN))
|
|
{
|
|
State = 2;
|
|
}
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!strncmp((const char*)VolumeStructDesc->Ident,
|
|
VSD_STD_ID_TEA01,
|
|
VSD_STD_ID_LEN))
|
|
{
|
|
ExFreePool(VolumeStructDesc);
|
|
return TRUE;
|
|
}
|
|
break;
|
|
}
|
|
|
|
Offset.QuadPart += SectorSize;
|
|
if (Offset.QuadPart == UDFS_AVDP_SECTOR)
|
|
{
|
|
ExFreePool(VolumeStructDesc);
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
ExFreePool(VolumeStructDesc);
|
|
return TRUE;
|
|
}
|
|
|
|
NTSTATUS
|
|
NTAPI
|
|
FsRecUdfsFsControl(IN PDEVICE_OBJECT DeviceObject,
|
|
IN PIRP Irp)
|
|
{
|
|
PIO_STACK_LOCATION Stack;
|
|
NTSTATUS Status;
|
|
PDEVICE_OBJECT MountDevice;
|
|
ULONG SectorSize;
|
|
PAGED_CODE();
|
|
|
|
/* Get the I/O Stack and check the function type */
|
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
|
switch (Stack->MinorFunction)
|
|
{
|
|
case IRP_MN_MOUNT_VOLUME:
|
|
|
|
/* Assume failure */
|
|
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 FAT volume */
|
|
if (FsRecIsUdfsVolume(MountDevice, SectorSize))
|
|
{
|
|
/* It is! */
|
|
Status = STATUS_FS_DRIVER_REQUIRED;
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case IRP_MN_LOAD_FILE_SYSTEM:
|
|
|
|
/* Load the file system */
|
|
Status = FsRecLoadFileSystem(DeviceObject,
|
|
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Udfs");
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Invalid request */
|
|
Status = STATUS_INVALID_DEVICE_REQUEST;
|
|
}
|
|
|
|
/* Return Status */
|
|
return Status;
|
|
}
|
|
|
|
/* EOF */
|