ReactOS 0.4.15-dev-7131-ge4d03f4
recover.c File Reference
#include <ext2fs.h>
#include <linux/jbd.h>
#include <linux/ext3_fs.h>
Include dependency graph for recover.c:

Go to the source code of this file.

Functions

PEXT2_MCB Ext2LoadInternalJournal (PEXT2_VCB Vcb, ULONG jNo)
 
INT Ext2CheckJournal (PEXT2_VCB Vcb, PULONG jNo)
 
INT Ext2RecoverJournal (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb)
 

Variables

PEXT2_GLOBAL Ext2Global
 

Function Documentation

◆ Ext2CheckJournal()

INT Ext2CheckJournal ( PEXT2_VCB  Vcb,
PULONG  jNo 
)

Definition at line 55 of file recover.c.

59{
60 struct ext3_super_block* esb = NULL;
61
62 /* check ext3 super block */
63 esb = (struct ext3_super_block *)Vcb->SuperBlock;
67 }
68
69 /* must stop here if volume is read-only */
70 if (IsVcbReadOnly(Vcb)) {
71 goto errorout;
72 }
73
74 /* journal is external ? */
75 if (esb->s_journal_inum == 0) {
76 goto errorout;
77 }
78
79 /* oops: volume is corrupted */
80 if (esb->s_journal_dev) {
81 goto errorout;
82 }
83
84 /* return the journal inode number */
85 *jNo = esb->s_journal_inum;
86
87 return TRUE;
88
89errorout:
90
91 return FALSE;
92}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IsVcbReadOnly(Vcb)
Definition: ext2fs.h:814
#define SetLongFlag(_F, _SF)
Definition: ext2fs.h:258
#define VCB_JOURNAL_RECOVER
Definition: ext2fs.h:801
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define EXT3_FEATURE_INCOMPAT_RECOVER
Definition: ext3_fs.h:680
if(dx< 0)
Definition: linetemp.h:194
#define Vcb
Definition: cdprocs.h:1415
__le32 s_journal_inum
Definition: ext3_fs.h:561
__le32 s_feature_incompat
Definition: ext3_fs.h:538
__le32 s_journal_dev
Definition: ext3_fs.h:562

Referenced by Ext2RecoverJournal().

◆ Ext2LoadInternalJournal()

PEXT2_MCB Ext2LoadInternalJournal ( PEXT2_VCB  Vcb,
ULONG  jNo 
)

Definition at line 29 of file recover.c.

33{
34 PEXT2_MCB Jcb = NULL;
35
36 Jcb = Ext2AllocateMcb(Vcb, NULL, NULL, 0);
37 if (!Jcb) {
38 goto errorout;
39 }
40
41 Jcb->Inode.i_ino = jNo;
42 Jcb->Inode.i_sb = &Vcb->sb;
43 if (!Ext2LoadInode(Vcb, &Jcb->Inode)) {
44 DbgBreak();
45 Ext2FreeMcb(Vcb, Jcb);
46 goto errorout;
47 }
48
49errorout:
50
51 return Jcb;
52}
VOID Ext2FreeMcb(IN PEXT2_VCB Vcb, IN PEXT2_MCB Mcb)
Definition: memory.c:1538
#define DbgBreak()
Definition: ext2fs.h:46
BOOLEAN Ext2LoadInode(IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:508
PEXT2_MCB Ext2AllocateMcb(IN PEXT2_VCB Vcb, IN PUNICODE_STRING FileName, IN PUNICODE_STRING Parent, IN ULONG FileAttr)
Definition: memory.c:1430
struct inode Inode
Definition: ext2fs.h:945

Referenced by Ext2RecoverJournal().

◆ Ext2RecoverJournal()

INT Ext2RecoverJournal ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  Vcb 
)

Definition at line 95 of file recover.c.

99{
100 INT rc = 0;
101 ULONG jNo = 0;
102 PEXT2_MCB jcb = NULL;
103 struct block_device * bd = &Vcb->bd;
104#ifndef __REACTOS__
105 struct super_block * sb = &Vcb->sb;
106#endif
107 struct inode * ji = NULL;
108 journal_t * journal = NULL;
109 struct ext3_super_block *esb;
110
111 ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
112
113 /* check journal inode number */
114 if (!Ext2CheckJournal(Vcb, &jNo)) {
115 rc = -1;
116 goto errorout;
117 }
118
119 /* allocate journal Mcb */
120 jcb = Ext2LoadInternalJournal(Vcb, jNo);
121 if (!jcb) {
122 rc = -6;
123 goto errorout;
124 }
125
126 /* allocate journal inode */
127 ji = &jcb->Inode;
128
129 /* initialize journal file from inode */
130 journal = journal_init_inode(ji);
131
132 /* initialzation succeeds ? */
133 if (!journal) {
134 iput(ji);
135 rc = -8;
136 goto errorout;
137 }
138
139 /* start journal recovery */
140 rc = journal_load(journal);
141 if (0 != rc) {
142 rc = -9;
143 DbgPrint("Ext2Fsd: recover_journal: failed "
144 "to recover journal data.\n");
145 }
146
147 /* reload super_block and group_description */
148 Ext2RefreshSuper(IrpContext, Vcb);
149 Ext2RefreshGroup(IrpContext, Vcb);
150
151 /* wipe journal data and clear recover flag in sb */
152 if (rc == 0) {
153 journal_wipe_recovery(journal);
155 Vcb->SuperBlock->s_feature_incompat,
157 Ext2SaveSuper(IrpContext, Vcb);
158 sync_blockdev(bd);
160 }
161
162errorout:
163
164 /* destroy journal structure */
165 if (journal) {
166 journal_destroy(journal);
167 }
168
169 /* destory journal Mcb */
170 if (jcb) {
171 Ext2FreeMcb(Vcb, jcb);
172 }
173
174 ExReleaseResourceLite(&Vcb->MainResource);
175
176 return rc;
177}
superblock * sb
Definition: btrfs.c:4261
void iput(struct inode *inode)
Definition: linux.c:992
INT Ext2CheckJournal(PEXT2_VCB Vcb, PULONG jNo)
Definition: recover.c:55
PEXT2_MCB Ext2LoadInternalJournal(PEXT2_VCB Vcb, ULONG jNo)
Definition: recover.c:29
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
#define ClearLongFlag(_F, _SF)
Definition: ext2fs.h:259
BOOLEAN Ext2SaveSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:67
BOOLEAN Ext2RefreshGroup(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:409
BOOLEAN Ext2RefreshSuper(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb)
Definition: generic.c:92
#define DbgPrint
Definition: hal.h:12
int sync_blockdev(struct block_device *bdev)
Definition: linux.c:919
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
int journal_load(journal_t *journal)
Definition: replay.c:1121
journal_t * journal_init_inode(struct inode *inode)
Definition: replay.c:592
void journal_wipe_recovery(journal_t *journal)
Definition: replay.c:659
void journal_destroy(journal_t *journal)
Definition: replay.c:678
Definition: fs.h:78
Definition: fs.h:64
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59

Referenced by Ext2InitializeVcb(), and Ext2ProcessVolumeProperty().

Variable Documentation

◆ Ext2Global

PEXT2_GLOBAL Ext2Global
extern

Definition at line 16 of file init.c.