2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS File System Recognizer
4 * FILE: drivers/filesystems/fs_rec/ext2.c
5 * PURPOSE: EXT2 Recognizer
6 * PROGRAMMER: Eric Kohl
7 * Pierre Schweitzer (pierre@reactos.org)
10 /* INCLUDES *****************************************************************/
18 /* FUNCTIONS ****************************************************************/
22 FsRecIsExt2Volume(IN PEXT2_SUPER_BLOCK SuperBlock
)
24 /* Just check for magic */
25 return (SuperBlock
->Magic
== EXT2_SUPER_MAGIC
);
30 FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject
,
33 PIO_STACK_LOCATION Stack
;
35 PDEVICE_OBJECT MountDevice
;
36 PEXT2_SUPER_BLOCK Spb
= NULL
;
39 BOOLEAN DeviceError
= FALSE
;
42 /* Get the I/O Stack and check the function type */
43 Stack
= IoGetCurrentIrpStackLocation(Irp
);
44 switch (Stack
->MinorFunction
)
46 case IRP_MN_MOUNT_VOLUME
:
49 Status
= STATUS_UNRECOGNIZED_VOLUME
;
51 /* Get the device object and request the sector size */
52 MountDevice
= Stack
->Parameters
.MountVolume
.DeviceObject
;
53 if (FsRecGetDeviceSectorSize(MountDevice
, &SectorSize
))
55 /* Try to read the superblock */
56 Offset
.QuadPart
= EXT2_SB_OFFSET
;
57 if (FsRecReadBlock(MountDevice
,
64 /* Check if it's an actual EXT2 volume */
65 if (FsRecIsExt2Volume(Spb
))
68 Status
= STATUS_FS_DRIVER_REQUIRED
;
72 /* Free the boot sector if we have one */
77 /* We have some sort of failure in the storage stack */
81 /* Check if we have an error on the stack */
84 /* Was this because of a floppy? */
85 if (MountDevice
->Characteristics
& FILE_FLOPPY_DISKETTE
)
87 /* Let the FS try anyway */
88 Status
= STATUS_FS_DRIVER_REQUIRED
;
94 case IRP_MN_LOAD_FILE_SYSTEM
:
96 /* Load the file system */
97 Status
= FsRecLoadFileSystem(DeviceObject
,
98 L
"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Ext2fs");
103 /* Invalid request */
104 Status
= STATUS_INVALID_DEVICE_REQUEST
;