2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS File System Recognizer
4 * FILE: drivers/filesystems/fs_rec/btrfs.c
5 * PURPOSE: Btrfs Recognizer
6 * PROGRAMMER: Peter Hater
7 * Pierre Schweitzer (pierre@reactos.org)
10 /* INCLUDES *****************************************************************/
18 /* FUNCTIONS ****************************************************************/
22 FsRecIsReiserfsVolume(IN PRFSD_SUPER_BLOCK sb
)
24 UCHAR sz_MagicKey
[] = REISER2FS_SUPER_MAGIC_STRING
;
28 // If any characters read from disk don't match the expected magic key, we don't have a ReiserFS volume.
29 for (i
= 0; i
< MAGIC_KEY_LENGTH
; i
++)
31 currentChar
= sb
->s_magic
[i
];
32 if (currentChar
!= sz_MagicKey
[i
])
43 FsRecReiserfsFsControl(IN PDEVICE_OBJECT DeviceObject
,
46 PIO_STACK_LOCATION Stack
;
48 PDEVICE_OBJECT MountDevice
;
49 PRFSD_SUPER_BLOCK Spb
= NULL
;
52 BOOLEAN DeviceError
= FALSE
;
55 /* Get the I/O Stack and check the function type */
56 Stack
= IoGetCurrentIrpStackLocation(Irp
);
57 switch (Stack
->MinorFunction
)
59 case IRP_MN_MOUNT_VOLUME
:
62 Status
= STATUS_UNRECOGNIZED_VOLUME
;
64 /* Get the device object and request the sector size */
65 MountDevice
= Stack
->Parameters
.MountVolume
.DeviceObject
;
66 if (FsRecGetDeviceSectorSize(MountDevice
, &SectorSize
))
68 /* Try to read the superblock */
69 Offset
.QuadPart
= REISERFS_DISK_OFFSET_IN_BYTES
;
70 if (FsRecReadBlock(MountDevice
,
77 /* Check if it's an actual BTRFS volume */
78 if (FsRecIsReiserfsVolume(Spb
))
81 Status
= STATUS_FS_DRIVER_REQUIRED
;
85 /* Free the boot sector if we have one */
90 /* We have some sort of failure in the storage stack */
94 /* Check if we have an error on the stack */
97 /* Was this because of a floppy? */
98 if (MountDevice
->Characteristics
& FILE_FLOPPY_DISKETTE
)
100 /* Let the FS try anyway */
101 Status
= STATUS_FS_DRIVER_REQUIRED
;
107 case IRP_MN_LOAD_FILE_SYSTEM
:
109 /* Load the file system */
110 Status
= FsRecLoadFileSystem(DeviceObject
,
111 L
"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\reiserfs");
116 /* Invalid request */
117 Status
= STATUS_INVALID_DEVICE_REQUEST
;