3 * Copyright (C) 2002,2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* $Id: fat.c 9284 2004-05-02 20:12:38Z hbirr $
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: drivers/fs/fs_rec/ext2.c (based on vfat.c)
24 * PURPOSE: Filesystem recognizer driver
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
30 #include <ddk/ntddk.h>
31 #include <rosrtl/string.h>
39 /* FUNCTIONS ****************************************************************/
42 FsRecIsExt2Volume(IN PDEVICE_OBJECT DeviceObject
)
45 PARTITION_INFORMATION PartitionInfo
;
46 DISK_GEOMETRY DiskGeometry
;
48 BOOL RecognizedFS
= FALSE
;
49 Size
= sizeof(DISK_GEOMETRY
);
51 Status
= FsRecDeviceIoControl(DeviceObject
,
52 IOCTL_DISK_GET_DRIVE_GEOMETRY
,
57 if (!NT_SUCCESS(Status
))
59 DPRINT("FsRecDeviceIoControl faild (%x)\n", Status
);
62 if (DiskGeometry
.MediaType
== FixedMedia
|| DiskGeometry
.MediaType
== RemovableMedia
)
64 // We have found a hard disk
65 Size
= sizeof(PARTITION_INFORMATION
);
66 Status
= FsRecDeviceIoControl(DeviceObject
,
67 IOCTL_DISK_GET_PARTITION_INFO
,
72 if (!NT_SUCCESS(Status
))
74 DPRINT("FsRecDeviceIoControl faild (%x)\n", Status
);
78 if (PartitionInfo
.PartitionType
)
80 if (PartitionInfo
.PartitionType
== PARTITION_EXT2
)
87 return RecognizedFS
? STATUS_SUCCESS
: STATUS_UNRECOGNIZED_VOLUME
;
92 FsRecExt2FsControl(IN PDEVICE_OBJECT DeviceObject
,
95 PIO_STACK_LOCATION Stack
;
96 UNICODE_STRING RegistryPath
;
99 Stack
= IoGetCurrentIrpStackLocation(Irp
);
101 switch (Stack
->MinorFunction
)
103 case IRP_MN_MOUNT_VOLUME
:
104 DPRINT("FAT: IRP_MN_MOUNT_VOLUME\n");
105 Status
= FsRecIsExt2Volume(Stack
->Parameters
.MountVolume
.DeviceObject
);
106 if (NT_SUCCESS(Status
))
108 DPRINT("Identified FAT volume\n");
109 Status
= STATUS_FS_DRIVER_REQUIRED
;
113 case IRP_MN_LOAD_FILE_SYSTEM
:
114 DPRINT("FAT: IRP_MN_LOAD_FILE_SYSTEM\n");
115 RtlRosInitUnicodeStringFromLiteral(&RegistryPath
,
116 L
"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Ext2");
117 Status
= ZwLoadDriver(&RegistryPath
);
118 if (!NT_SUCCESS(Status
))
120 DPRINT("ZwLoadDriver failed (Status %x)\n", Status
);
124 IoUnregisterFileSystem(DeviceObject
);
129 DPRINT("FAT: Unknown minor function %lx\n", Stack
->MinorFunction
);
130 Status
= STATUS_INVALID_DEVICE_REQUEST
;