ReactOS  0.4.14-dev-317-g96040ec
btrfs.c File Reference
#include "fs_rec.h"
#include "btrfs.h"
#include <debug.h>
Include dependency graph for btrfs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI FsRecIsBtrfsVolume (IN PBTRFS_SUPER_BLOCK SuperBlock)
 
NTSTATUS NTAPI FsRecBtrfsFsControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file btrfs.c.

Function Documentation

◆ FsRecBtrfsFsControl()

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

Definition at line 30 of file btrfs.c.

32 {
33  PIO_STACK_LOCATION Stack;
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,
60  SectorSize,
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 TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: btrfs.c:4150
#define IRP_MN_LOAD_FILE_SYSTEM
Definition: iotypes.h:4050
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_FS_DRIVER_REQUIRED
Definition: ntstatus.h:631
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI FsRecIsBtrfsVolume(IN PBTRFS_SUPER_BLOCK SuperBlock)
Definition: btrfs.c:22
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4048
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
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
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define BTRFS_SB_SIZE
Definition: btrfs.h:31
#define BTRFS_SB_OFFSET
Definition: btrfs.h:30
NTSTATUS NTAPI FsRecLoadFileSystem(IN PDEVICE_OBJECT DeviceObject, IN PWCHAR DriverServiceName)
Definition: fs_rec.c:23
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG SectorSize
Definition: halfuncs.h:291
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FsRecFsControl().

◆ FsRecIsBtrfsVolume()

BOOLEAN NTAPI FsRecIsBtrfsVolume ( IN PBTRFS_SUPER_BLOCK  SuperBlock)

Definition at line 22 of file btrfs.c.

23 {
24  /* Just check for magic */
25  return (SuperBlock->magic == BTRFS_MAGIC);
26 }
#define BTRFS_MAGIC
Definition: btrfs.h:42

Referenced by FsRecBtrfsFsControl().