ReactOS 0.4.15-dev-5664-g3bf4ef6
btrfs.c
Go to the documentation of this file.
1/*
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)
8 */
9
10/* INCLUDES *****************************************************************/
11
12#include "fs_rec.h"
13#include "btrfs.h"
14
15#define NDEBUG
16#include <debug.h>
17
18/* FUNCTIONS ****************************************************************/
19
23{
24 /* Just check for magic */
25 return (SuperBlock->magic == BTRFS_MAGIC);
26}
27
31 IN PIRP Irp)
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 = BTRFS_SB_OFFSET;
57 if (FsRecReadBlock(MountDevice,
58 &Offset,
61 (PVOID)&Spb,
62 &DeviceError))
63 {
64 /* Check if it's an actual BTRFS volume */
65 if (FsRecIsBtrfsVolume(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\\btrfs");
99 break;
100
101 default:
102
103 /* Invalid request */
105 }
106
107 /* Return Status */
108 return Status;
109}
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define BTRFS_MAGIC
Definition: btrfs.h:42
_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 FsRecIsBtrfsVolume(IN PBTRFS_SUPER_BLOCK SuperBlock)
Definition: btrfs.c:22
NTSTATUS NTAPI FsRecBtrfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: btrfs.c:30
#define BTRFS_SB_SIZE
Definition: btrfs.h:31
#define BTRFS_SB_OFFSET
Definition: btrfs.h:30
#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
unsigned int ULONG
Definition: retypes.h:1
#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
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
#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
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define IRP_MN_LOAD_FILE_SYSTEM
Definition: iotypes.h:4406
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4404