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 FsRecIsBtrfsVolume(IN PBTRFS_SUPER_BLOCK SuperBlock
)
24 /* Just check for magic */
25 return (SuperBlock
->magic
== BTRFS_MAGIC
);
30 FsRecBtrfsFsControl(IN PDEVICE_OBJECT DeviceObject
,
33 PIO_STACK_LOCATION Stack
;
35 PDEVICE_OBJECT MountDevice
;
36 PBTRFS_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
= BTRFS_SB_OFFSET
;
57 if (FsRecReadBlock(MountDevice
,
64 /* Check if it's an actual BTRFS volume */
65 if (FsRecIsBtrfsVolume(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\\btrfs");
103 /* Invalid request */
104 Status
= STATUS_INVALID_DEVICE_REQUEST
;