ReactOS 0.4.15-dev-7931-gfd331f1
ext2.c File Reference
#include "fs_rec.h"
#include "ext2.h"
#include <debug.h>
Include dependency graph for ext2.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI FsRecIsExt2Volume (IN PEXT2_SUPER_BLOCK SuperBlock)
 
NTSTATUS NTAPI FsRecExt2FsControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file ext2.c.

Function Documentation

◆ FsRecExt2FsControl()

NTSTATUS NTAPI FsRecExt2FsControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 30 of file ext2.c.

32{
35 PDEVICE_OBJECT MountDevice;
39 BOOLEAN DeviceError = FALSE;
40 PAGED_CODE();
41
42 /* Get the I/O Stack and check the function type */
44 switch (Stack->MinorFunction)
45 {
47
48 /* Assume failure */
50
51 /* Get the device object and request the sector size */
52 MountDevice = Stack->Parameters.MountVolume.DeviceObject;
53 if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
54 {
55 /* Try to read the superblock */
56 Offset.QuadPart = EXT2_SB_OFFSET;
57 if (FsRecReadBlock(MountDevice,
58 &Offset,
61 (PVOID)&Spb,
62 &DeviceError))
63 {
64 /* Check if it's an actual EXT2 volume */
65 if (FsRecIsExt2Volume(Spb))
66 {
67 /* It is! */
69 }
70 }
71
72 /* Free the boot sector if we have one */
73 ExFreePool(Spb);
74 }
75 else
76 {
77 /* We have some sort of failure in the storage stack */
78 DeviceError = TRUE;
79 }
80
81 /* Check if we have an error on the stack */
82 if (DeviceError)
83 {
84 /* Was this because of a floppy? */
85 if (MountDevice->Characteristics & FILE_FLOPPY_DISKETTE)
86 {
87 /* Let the FS try anyway */
89 }
90 }
91
92 break;
93
95
96 /* Load the file system */
98 L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Ext2fs");
99 break;
100
101 default:
102
103 /* Invalid request */
105 }
106
107 /* Return Status */
108 return Status;
109}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOLEAN NTAPI FsRecIsExt2Volume(IN PEXT2_SUPER_BLOCK SuperBlock)
Definition: ext2.c:22
#define EXT2_SB_OFFSET
Definition: ext2.h:47
#define EXT2_SB_SIZE
Definition: ext2.h:48
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
BOOLEAN NTAPI FsRecReadBlock(IN PDEVICE_OBJECT DeviceObject, IN PLARGE_INTEGER Offset, IN ULONG Length, IN ULONG SectorSize, IN OUT PVOID *Buffer, OUT PBOOLEAN DeviceError OPTIONAL)
Definition: blockdev.c:152
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
Status
Definition: gdiplustypes.h:25
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:645
#define L(x)
Definition: ntvdm.h:50
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_In_ ULONG SectorSize
Definition: halfuncs.h:291
#define IRP_MN_LOAD_FILE_SYSTEM
Definition: iotypes.h:4406
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4404

Referenced by FsRecFsControl().

◆ FsRecIsExt2Volume()

BOOLEAN NTAPI FsRecIsExt2Volume ( IN PEXT2_SUPER_BLOCK  SuperBlock)

Definition at line 22 of file ext2.c.

23{
24 /* Just check for magic */
25 return (SuperBlock->Magic == EXT2_SUPER_MAGIC);
26}
#define EXT2_SUPER_MAGIC
Definition: ext2fs.h:349

Referenced by FsRecExt2FsControl().