ReactOS 0.4.15-dev-5672-gf73ac17
reiserfs.c File Reference
#include "fs_rec.h"
#include "reiserfs.h"
#include <debug.h>
Include dependency graph for reiserfs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOLEAN NTAPI FsRecIsReiserfsVolume (IN PRFSD_SUPER_BLOCK sb)
 
NTSTATUS NTAPI FsRecReiserfsFsControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file reiserfs.c.

Function Documentation

◆ FsRecIsReiserfsVolume()

BOOLEAN NTAPI FsRecIsReiserfsVolume ( IN PRFSD_SUPER_BLOCK  sb)

Definition at line 22 of file reiserfs.c.

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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
superblock * sb
Definition: btrfs.c:4261
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
#define MAGIC_KEY_LENGTH
Definition: reiserfs.h:76
#define REISER2FS_SUPER_MAGIC_STRING
Definition: reiserfs.h:74
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by FsRecReiserfsFsControl().

◆ FsRecReiserfsFsControl()

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

Definition at line 43 of file reiserfs.c.

45{
48 PDEVICE_OBJECT MountDevice;
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,
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 PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#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
#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
BOOLEAN NTAPI FsRecIsReiserfsVolume(IN PRFSD_SUPER_BLOCK sb)
Definition: reiserfs.c:22
#define REISERFS_DISK_OFFSET_IN_BYTES
Definition: reiserfs.h:72
uint32_t ULONG
Definition: typedefs.h:59
#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

Referenced by FsRecFsControl().