1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS File System Recognizer 4 * FILE: drivers/filesystems/fs_rec/udfs.c 5 * PURPOSE: USFS Recognizer 6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org) 7 * Eric Kohl 8 */ 9 10 /* INCLUDES *****************************************************************/ 11 12 #include "fs_rec.h" 13 14 #define NDEBUG 15 #include <debug.h> 16 17 #include "udfs.h" 18 19 /* FUNCTIONS ****************************************************************/ 20 21 BOOLEAN 22 NTAPI 23 FsRecIsUdfsVolume(IN PDEVICE_OBJECT DeviceObject, 24 IN ULONG SectorSize) 25 { 26 PVOLSTRUCTDESC VolumeStructDesc = NULL; 27 LARGE_INTEGER Offset; 28 BOOLEAN ret = FALSE; 29 int i; 30 PAGED_CODE(); 31 32 Offset.QuadPart = 16 * SectorSize; 33 for (i = 0; i < 16; i++) 34 { 35 if (!FsRecReadBlock(DeviceObject, 36 &Offset, 37 SectorSize, 38 SectorSize, 39 (PVOID *)&VolumeStructDesc, 40 NULL)) 41 { 42 break; 43 } 44 45 if (!strncmp((const char*)VolumeStructDesc->Ident, 46 VSD_STD_ID_BEA01, 47 VSD_STD_ID_LEN)) 48 { 49 DPRINT("BEA01 found\n"); 50 } 51 52 if (!strncmp((const char*)VolumeStructDesc->Ident, 53 VSD_STD_ID_NSR03, 54 VSD_STD_ID_LEN)) 55 { 56 DPRINT("NSR03 found\n"); 57 ret = TRUE; 58 } 59 60 if (!strncmp((const char*)VolumeStructDesc->Ident, 61 VSD_STD_ID_NSR02, 62 VSD_STD_ID_LEN)) 63 { 64 DPRINT("NSR02 found\n"); 65 ret = TRUE; 66 } 67 68 if (!strncmp((const char*)VolumeStructDesc->Ident, 69 VSD_STD_ID_TEA01, 70 VSD_STD_ID_LEN)) 71 { 72 DPRINT("TEA01 found\n"); 73 } 74 75 if (!strncmp((const char*)VolumeStructDesc->Ident, 76 VSD_STD_ID_CD001, 77 VSD_STD_ID_LEN)) 78 { 79 DPRINT("CD001 found\n"); 80 } 81 82 if (!strncmp((const char*)VolumeStructDesc->Ident, 83 VSD_STD_ID_CDW02, 84 VSD_STD_ID_LEN)) 85 { 86 DPRINT("CDW02 found\n"); 87 } 88 89 if (!strncmp((const char*)VolumeStructDesc->Ident, 90 VSD_STD_ID_BOOT2, 91 VSD_STD_ID_LEN)) 92 { 93 DPRINT("BOOT2 found\n"); 94 } 95 96 Offset.QuadPart += SectorSize; 97 } 98 99 if (VolumeStructDesc) 100 ExFreePool(VolumeStructDesc); 101 return ret; 102 } 103 104 NTSTATUS 105 NTAPI 106 FsRecUdfsFsControl(IN PDEVICE_OBJECT DeviceObject, 107 IN PIRP Irp) 108 { 109 PIO_STACK_LOCATION Stack; 110 NTSTATUS Status; 111 PDEVICE_OBJECT MountDevice; 112 ULONG SectorSize; 113 PAGED_CODE(); 114 115 /* Get the I/O Stack and check the function type */ 116 Stack = IoGetCurrentIrpStackLocation(Irp); 117 switch (Stack->MinorFunction) 118 { 119 case IRP_MN_MOUNT_VOLUME: 120 121 /* Assume failure */ 122 Status = STATUS_UNRECOGNIZED_VOLUME; 123 124 /* Get the device object and request the sector size */ 125 MountDevice = Stack->Parameters.MountVolume.DeviceObject; 126 if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize)) 127 { 128 /* Check if it's an actual UDF volume */ 129 if (FsRecIsUdfsVolume(MountDevice, SectorSize)) 130 { 131 /* It is! */ 132 Status = STATUS_FS_DRIVER_REQUIRED; 133 } 134 } 135 136 break; 137 138 case IRP_MN_LOAD_FILE_SYSTEM: 139 140 /* Load the file system */ 141 Status = FsRecLoadFileSystem(DeviceObject, 142 L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Udfs"); 143 break; 144 145 default: 146 147 /* Invalid request */ 148 Status = STATUS_INVALID_DEVICE_REQUEST; 149 } 150 151 /* Return Status */ 152 return Status; 153 } 154 155 /* EOF */ 156