ReactOS  0.4.14-dev-315-gbb6fece
reiserfs.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 "reiserfs.h"
14 
15 #define NDEBUG
16 #include <debug.h>
17 
18 /* FUNCTIONS ****************************************************************/
19 
20 BOOLEAN
21 NTAPI
23 {
24  UCHAR sz_MagicKey[] = REISER2FS_SUPER_MAGIC_STRING;
25  UCHAR currentChar;
26  int i;
27 
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++)
30  {
31  currentChar = sb->s_magic[i];
32  if (currentChar != sz_MagicKey[i])
33  {
34  return FALSE;
35  }
36  }
37 
38  return TRUE;
39 }
40 
42 NTAPI
44  IN PIRP Irp)
45 {
46  PIO_STACK_LOCATION Stack;
48  PDEVICE_OBJECT MountDevice;
49  PRFSD_SUPER_BLOCK Spb = NULL;
52  BOOLEAN DeviceError = FALSE;
53  PAGED_CODE();
54 
55  /* Get the I/O Stack and check the function type */
57  switch (Stack->MinorFunction)
58  {
60 
61  /* Assume failure */
63 
64  /* Get the device object and request the sector size */
65  MountDevice = Stack->Parameters.MountVolume.DeviceObject;
66  if (FsRecGetDeviceSectorSize(MountDevice, &SectorSize))
67  {
68  /* Try to read the superblock */
70  if (FsRecReadBlock(MountDevice,
71  &Offset,
72  SectorSize,
73  SectorSize,
74  (PVOID)&Spb,
75  &DeviceError))
76  {
77  /* Check if it's an actual BTRFS volume */
78  if (FsRecIsReiserfsVolume(Spb))
79  {
80  /* It is! */
82  }
83  }
84 
85  /* Free the boot sector if we have one */
86  ExFreePool(Spb);
87  }
88  else
89  {
90  /* We have some sort of failure in the storage stack */
91  DeviceError = TRUE;
92  }
93 
94  /* Check if we have an error on the stack */
95  if (DeviceError)
96  {
97  /* Was this because of a floppy? */
98  if (MountDevice->Characteristics & FILE_FLOPPY_DISKETTE)
99  {
100  /* Let the FS try anyway */
102  }
103  }
104 
105  break;
106 
108 
109  /* Load the file system */
111  L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\reiserfs");
112  break;
113 
114  default:
115 
116  /* Invalid request */
118  }
119 
120  /* Return Status */
121  return Status;
122 }
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
#define REISER2FS_SUPER_MAGIC_STRING
Definition: reiserfs.h:74
_In_ PIRP Irp
Definition: csq.h:116
superblock * sb
Definition: btrfs.c:4137
BOOLEAN NTAPI FsRecGetDeviceSectorSize(IN PDEVICE_OBJECT DeviceObject, OUT PULONG SectorSize)
Definition: blockdev.c:80
LONG NTSTATUS
Definition: precomp.h:26
#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
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_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
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4048
#define REISERFS_DISK_OFFSET_IN_BYTES
Definition: reiserfs.h:72
NTSTATUS NTAPI FsRecReiserfsFsControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: reiserfs.c:43
unsigned char UCHAR
Definition: xmlstorage.h:181
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 MAGIC_KEY_LENGTH
Definition: reiserfs.h:76
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
BOOLEAN NTAPI FsRecIsReiserfsVolume(IN PRFSD_SUPER_BLOCK sb)
Definition: reiserfs.c:22
#define ExFreePool(addr)
Definition: env_spec_w32.h:352