mirror of
https://github.com/bobranten/Ext4Fsd.git
synced 2025-10-30 05:18:31 -05:00
switched from jbd to jbd2
This commit is contained in:
@@ -1 +1 @@
|
|||||||
DIRS = nls ext3 ext4 jbd jbd2 sys
|
DIRS = nls ext3 ext4 jbd2 sys
|
||||||
|
|||||||
@@ -218,9 +218,10 @@
|
|||||||
<ClCompile Include="flush.c" />
|
<ClCompile Include="flush.c" />
|
||||||
<ClCompile Include="fsctl.c" />
|
<ClCompile Include="fsctl.c" />
|
||||||
<ClCompile Include="init.c" />
|
<ClCompile Include="init.c" />
|
||||||
<ClCompile Include="jbd\recovery.c" />
|
<ClCompile Include="jbd2\journal.c" />
|
||||||
<ClCompile Include="jbd\replay.c" />
|
<ClCompile Include="jbd2\recovery.c" />
|
||||||
<ClCompile Include="jbd\revoke.c" />
|
<ClCompile Include="jbd2\revoke.c" />
|
||||||
|
<ClCompile Include="jbd2\transaction.c" />
|
||||||
<ClCompile Include="linux.c" />
|
<ClCompile Include="linux.c" />
|
||||||
<ClCompile Include="lock.c" />
|
<ClCompile Include="lock.c" />
|
||||||
<ClCompile Include="memory.c" />
|
<ClCompile Include="memory.c" />
|
||||||
|
|||||||
@@ -23,12 +23,12 @@
|
|||||||
<Filter Include="Source Files\ext4">
|
<Filter Include="Source Files\ext4">
|
||||||
<UniqueIdentifier>{9ab142d9-f11c-4d93-b92a-0df6595d2e24}</UniqueIdentifier>
|
<UniqueIdentifier>{9ab142d9-f11c-4d93-b92a-0df6595d2e24}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Source Files\jbd">
|
|
||||||
<UniqueIdentifier>{3e51e838-e180-44c1-ae2d-53cf5297396b}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Source Files\nls">
|
<Filter Include="Source Files\nls">
|
||||||
<UniqueIdentifier>{94a9d102-6815-4f19-9b62-763fe5d482ca}</UniqueIdentifier>
|
<UniqueIdentifier>{94a9d102-6815-4f19-9b62-763fe5d482ca}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Source Files\jbd2">
|
||||||
|
<UniqueIdentifier>{05b648dd-bb69-40ed-abff-2df7db3c7f92}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="access.c">
|
<ClCompile Include="access.c">
|
||||||
@@ -142,15 +142,6 @@
|
|||||||
<ClCompile Include="ext4\extents.c">
|
<ClCompile Include="ext4\extents.c">
|
||||||
<Filter>Source Files\ext4</Filter>
|
<Filter>Source Files\ext4</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="jbd\recovery.c">
|
|
||||||
<Filter>Source Files\jbd</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="jbd\replay.c">
|
|
||||||
<Filter>Source Files\jbd</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="jbd\revoke.c">
|
|
||||||
<Filter>Source Files\jbd</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="nls\nls_ascii.c">
|
<ClCompile Include="nls\nls_ascii.c">
|
||||||
<Filter>Source Files\nls</Filter>
|
<Filter>Source Files\nls</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -277,6 +268,18 @@
|
|||||||
<ClCompile Include="ext4\ext4_csum.c">
|
<ClCompile Include="ext4\ext4_csum.c">
|
||||||
<Filter>Source Files\ext4</Filter>
|
<Filter>Source Files\ext4</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="jbd2\journal.c">
|
||||||
|
<Filter>Source Files\jbd2</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jbd2\recovery.c">
|
||||||
|
<Filter>Source Files\jbd2</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jbd2\revoke.c">
|
||||||
|
<Filter>Source Files\jbd2</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jbd2\transaction.c">
|
||||||
|
<Filter>Source Files\jbd2</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="include\ext2fs.h">
|
<ClInclude Include="include\ext2fs.h">
|
||||||
|
|||||||
@@ -1,174 +1,186 @@
|
|||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYRIGHT.TXT
|
* COPYRIGHT: See COPYRIGHT.TXT
|
||||||
* PROJECT: Ext2 File System Driver for WinNT/2K/XP
|
* PROJECT: Ext2 File System Driver for WinNT/2K/XP
|
||||||
* FILE: recover.c
|
* FILE: recover.c
|
||||||
* PROGRAMMER: Matt Wu <mattwu@163.com>
|
* PROGRAMMER: Matt Wu <mattwu@163.com>
|
||||||
* HOMEPAGE: http://www.ext2fsd.com
|
* HOMEPAGE: http://www.ext2fsd.com
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ext2fs.h>
|
#include <ext2fs.h>
|
||||||
#include <linux/jbd.h>
|
#include <linux/jbd2.h>
|
||||||
|
|
||||||
/* GLOBALS ***************************************************************/
|
/* GLOBALS ***************************************************************/
|
||||||
|
|
||||||
extern PEXT2_GLOBAL Ext2Global;
|
extern PEXT2_GLOBAL Ext2Global;
|
||||||
|
|
||||||
/* DEFINITIONS *************************************************************/
|
/* DEFINITIONS *************************************************************/
|
||||||
|
|
||||||
#ifdef ALLOC_PRAGMA
|
#ifdef ALLOC_PRAGMA
|
||||||
#pragma alloc_text(PAGE, Ext2LoadInternalJournal)
|
#pragma alloc_text(PAGE, Ext2LoadInternalJournal)
|
||||||
#pragma alloc_text(PAGE, Ext2CheckJournal)
|
#pragma alloc_text(PAGE, Ext2CheckJournal)
|
||||||
#pragma alloc_text(PAGE, Ext2RecoverJournal)
|
#pragma alloc_text(PAGE, Ext2RecoverJournal)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PEXT2_MCB
|
PEXT2_MCB
|
||||||
Ext2LoadInternalJournal(
|
Ext2LoadInternalJournal(
|
||||||
PEXT2_VCB Vcb,
|
PEXT2_VCB Vcb,
|
||||||
ULONG jNo
|
ULONG jNo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PEXT2_MCB Jcb = NULL;
|
PEXT2_MCB Jcb = NULL;
|
||||||
|
|
||||||
Jcb = Ext2AllocateMcb(Vcb, NULL, NULL, 0);
|
Jcb = Ext2AllocateMcb(Vcb, NULL, NULL, 0);
|
||||||
if (!Jcb) {
|
if (!Jcb) {
|
||||||
goto errorout;
|
goto errorout;
|
||||||
}
|
}
|
||||||
|
|
||||||
Jcb->Inode.i_ino = jNo;
|
Jcb->Inode.i_ino = jNo;
|
||||||
Jcb->Inode.i_sb = &Vcb->sb;
|
Jcb->Inode.i_sb = &Vcb->sb;
|
||||||
if (!Ext2LoadInode(Vcb, &Jcb->Inode)) {
|
if (!Ext2LoadInode(Vcb, &Jcb->Inode)) {
|
||||||
DbgBreak();
|
DbgBreak();
|
||||||
Ext2FreeMcb(Vcb, Jcb);
|
Ext2FreeMcb(Vcb, Jcb);
|
||||||
goto errorout;
|
goto errorout;
|
||||||
}
|
}
|
||||||
|
|
||||||
errorout:
|
errorout:
|
||||||
|
|
||||||
return Jcb;
|
return Jcb;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT
|
INT
|
||||||
Ext2CheckJournal(
|
Ext2CheckJournal(
|
||||||
PEXT2_VCB Vcb,
|
PEXT2_VCB Vcb,
|
||||||
PULONG jNo
|
PULONG jNo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct ext3_super_block* esb = NULL;
|
struct ext3_super_block* esb = NULL;
|
||||||
|
|
||||||
/* check ext3 super block */
|
/* check ext3 super block */
|
||||||
esb = (struct ext3_super_block *)Vcb->SuperBlock;
|
esb = (struct ext3_super_block *)Vcb->SuperBlock;
|
||||||
if (IsFlagOn(esb->s_feature_incompat,
|
if (IsFlagOn(esb->s_feature_incompat,
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER)) {
|
EXT3_FEATURE_INCOMPAT_RECOVER)) {
|
||||||
SetLongFlag(Vcb->Flags, VCB_JOURNAL_RECOVER);
|
SetLongFlag(Vcb->Flags, VCB_JOURNAL_RECOVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* must stop here if volume is read-only */
|
/* must stop here if volume is read-only */
|
||||||
if (IsVcbReadOnly(Vcb)) {
|
if (IsVcbReadOnly(Vcb)) {
|
||||||
goto errorout;
|
goto errorout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* journal is external ? */
|
/* journal is external ? */
|
||||||
if (esb->s_journal_inum == 0) {
|
if (esb->s_journal_inum == 0) {
|
||||||
goto errorout;
|
goto errorout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* oops: volume is corrupted */
|
/* oops: volume is corrupted */
|
||||||
if (esb->s_journal_dev) {
|
if (esb->s_journal_dev) {
|
||||||
goto errorout;
|
goto errorout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return the journal inode number */
|
/* return the journal inode number */
|
||||||
*jNo = esb->s_journal_inum;
|
*jNo = esb->s_journal_inum;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
errorout:
|
errorout:
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT
|
INT
|
||||||
Ext2RecoverJournal(
|
Ext2RecoverJournal(
|
||||||
PEXT2_IRP_CONTEXT IrpContext,
|
PEXT2_IRP_CONTEXT IrpContext,
|
||||||
PEXT2_VCB Vcb
|
PEXT2_VCB Vcb
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
INT rc = 0;
|
INT rc = 0;
|
||||||
ULONG jNo = 0;
|
ULONG jNo = 0;
|
||||||
PEXT2_MCB jcb = NULL;
|
PEXT2_MCB jcb = NULL;
|
||||||
struct block_device * bd = &Vcb->bd;
|
struct block_device * bd = &Vcb->bd;
|
||||||
struct super_block * sb = &Vcb->sb;
|
struct super_block * sb = &Vcb->sb;
|
||||||
struct inode * ji = NULL;
|
struct inode * ji = NULL;
|
||||||
journal_t * journal = NULL;
|
journal_t * journal = NULL;
|
||||||
struct ext3_super_block *esb;
|
struct ext3_super_block *esb;
|
||||||
|
|
||||||
ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
|
DbgPrint("Ext2RecoverJournal begin\n");
|
||||||
|
|
||||||
/* check journal inode number */
|
ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
|
||||||
if (!Ext2CheckJournal(Vcb, &jNo)) {
|
|
||||||
rc = -1;
|
/* check journal inode number */
|
||||||
goto errorout;
|
if (!Ext2CheckJournal(Vcb, &jNo)) {
|
||||||
}
|
rc = -1;
|
||||||
|
goto errorout;
|
||||||
/* allocate journal Mcb */
|
}
|
||||||
jcb = Ext2LoadInternalJournal(Vcb, jNo);
|
|
||||||
if (!jcb) {
|
/* allocate journal Mcb */
|
||||||
rc = -6;
|
jcb = Ext2LoadInternalJournal(Vcb, jNo);
|
||||||
goto errorout;
|
if (!jcb) {
|
||||||
}
|
rc = -6;
|
||||||
|
goto errorout;
|
||||||
/* allocate journal inode */
|
}
|
||||||
ji = &jcb->Inode;
|
|
||||||
|
/* allocate journal inode */
|
||||||
/* initialize journal file from inode */
|
ji = &jcb->Inode;
|
||||||
journal = journal_init_inode(ji);
|
|
||||||
|
/* initialize journal file from inode */
|
||||||
/* initialzation succeeds ? */
|
journal = jbd2_journal_init_inode(ji);
|
||||||
if (!journal) {
|
|
||||||
iput(ji);
|
/* initialzation succeeds ? */
|
||||||
rc = -8;
|
if (!journal) {
|
||||||
goto errorout;
|
DbgPrint("jbd2_journal_init_inode failed\n");
|
||||||
}
|
iput(ji);
|
||||||
|
rc = -8;
|
||||||
/* start journal recovery */
|
goto errorout;
|
||||||
rc = journal_load(journal);
|
}
|
||||||
if (0 != rc) {
|
|
||||||
rc = -9;
|
if (ext4_has_feature_journal_needs_recovery(sb)) {
|
||||||
DbgPrint("Ext2Fsd: recover_journal: failed "
|
/* loading the journal will do a recover */
|
||||||
"to recover journal data.\n");
|
rc = jbd2_journal_load(journal);
|
||||||
}
|
|
||||||
|
if (0 != rc) {
|
||||||
/* reload super_block and group_description */
|
DbgPrint("Ext2Fsd: recover_journal: failed "
|
||||||
Ext2RefreshSuper(IrpContext, Vcb);
|
"to recover journal data. rc=%d\n", rc);
|
||||||
Ext2RefreshGroup(IrpContext, Vcb);
|
rc = -9;
|
||||||
|
//goto errorout;
|
||||||
/* wipe journal data and clear recover flag in sb */
|
}
|
||||||
if (rc == 0) {
|
|
||||||
journal_wipe_recovery(journal);
|
/* reload super_block and group_description */
|
||||||
ClearLongFlag(
|
Ext2RefreshSuper(IrpContext, Vcb);
|
||||||
Vcb->SuperBlock->s_feature_incompat,
|
Ext2RefreshGroup(IrpContext, Vcb);
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER );
|
|
||||||
Ext2SaveSuper(IrpContext, Vcb);
|
/* clear recover flag in sb */
|
||||||
sync_blockdev(bd);
|
if (rc == 0) {
|
||||||
ClearLongFlag(Vcb->Flags, VCB_JOURNAL_RECOVER);
|
ClearLongFlag(
|
||||||
}
|
Vcb->SuperBlock->s_feature_incompat,
|
||||||
|
EXT3_FEATURE_INCOMPAT_RECOVER);
|
||||||
errorout:
|
Ext2SaveSuper(IrpContext, Vcb);
|
||||||
|
sync_blockdev(bd);
|
||||||
/* destroy journal structure */
|
ClearLongFlag(Vcb->Flags, VCB_JOURNAL_RECOVER);
|
||||||
if (journal) {
|
}
|
||||||
journal_destroy(journal);
|
}
|
||||||
}
|
else {
|
||||||
|
/* if the journal is clean wipe it */
|
||||||
/* destory journal Mcb */
|
rc = jbd2_journal_wipe(journal, !IsVcbReadOnly(Vcb));
|
||||||
if (jcb) {
|
}
|
||||||
Ext2FreeMcb(Vcb, jcb);
|
|
||||||
}
|
errorout:
|
||||||
|
|
||||||
ExReleaseResourceLite(&Vcb->MainResource);
|
/* destroy journal structure */
|
||||||
|
if (journal) {
|
||||||
return rc;
|
jbd2_journal_destroy(journal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* destory journal Mcb */
|
||||||
|
if (jcb) {
|
||||||
|
Ext2FreeMcb(Vcb, jcb);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExReleaseResourceLite(&Vcb->MainResource);
|
||||||
|
|
||||||
|
DbgPrint("Ext2RecoverJournal end\n");
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "ext2fs.h"
|
#include "ext2fs.h"
|
||||||
#include "linux\ext4.h"
|
#include "linux\ext4.h"
|
||||||
#include "linux\jbd.h"
|
|
||||||
|
|
||||||
static handle_t no_journal;
|
static handle_t no_journal;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
//#include <linux/blkdev.h>
|
//#include <linux/blkdev.h>
|
||||||
#include <linux/magic.h>
|
#include <linux/magic.h>
|
||||||
//#include <linux/jbd2.h>
|
#include <linux/jbd2.h>
|
||||||
//#include <linux/quota.h>
|
//#include <linux/quota.h>
|
||||||
//#include <linux/rwsem.h>
|
//#include <linux/rwsem.h>
|
||||||
#include <linux/rbtree.h>
|
#include <linux/rbtree.h>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
//#include <linux/compat.h>
|
//#include <linux/compat.h>
|
||||||
#endif
|
#endif
|
||||||
typedef struct handle_s handle_t;
|
//typedef struct handle_s handle_t;
|
||||||
typedef unsigned long long ext4_fsblk_t;
|
typedef unsigned long long ext4_fsblk_t;
|
||||||
#include <linux/ext4_jbd2.h>
|
#include <linux/ext4_jbd2.h>
|
||||||
typedef unsigned __int16 uint16_t;
|
typedef unsigned __int16 uint16_t;
|
||||||
|
|||||||
@@ -2631,12 +2631,13 @@ Ext2InitializeVcb( IN PEXT2_IRP_CONTEXT IrpContext,
|
|||||||
/*
|
/*
|
||||||
* Mount ext4 with 64-bit block numbers read-only while testing.
|
* Mount ext4 with 64-bit block numbers read-only while testing.
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
if (EXT3_HAS_INCOMPAT_FEATURE(&Vcb->sb, EXT4_FEATURE_INCOMPAT_64BIT)) {
|
if (EXT3_HAS_INCOMPAT_FEATURE(&Vcb->sb, EXT4_FEATURE_INCOMPAT_64BIT)) {
|
||||||
printk(KERN_ERR "EXT3-fs: %s: Mounting ext4 with 64-bit block numbers read-only.\n",
|
printk(KERN_ERR "EXT3-fs: %s: Mounting ext4 with 64-bit block numbers read-only.\n",
|
||||||
Vcb->sb.s_id);
|
Vcb->sb.s_id);
|
||||||
SetLongFlag(Vcb->Flags, VCB_READ_ONLY);
|
SetLongFlag(Vcb->Flags, VCB_READ_ONLY);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
has_huge_files = EXT3_HAS_RO_COMPAT_FEATURE(&Vcb->sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE);
|
has_huge_files = EXT3_HAS_RO_COMPAT_FEATURE(&Vcb->sb, EXT4_FEATURE_RO_COMPAT_HUGE_FILE);
|
||||||
|
|
||||||
Vcb->sb.s_maxbytes = ext3_max_size(BLOCK_BITS, has_huge_files);
|
Vcb->sb.s_maxbytes = ext3_max_size(BLOCK_BITS, has_huge_files);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ USER_C_FLAGS = $(USER_C_FLAGS) /D__KERNEL__
|
|||||||
|
|
||||||
INCLUDES=..\include;
|
INCLUDES=..\include;
|
||||||
TARGETLIBS= $(TARGETPATH)\*\nlssup.lib \
|
TARGETLIBS= $(TARGETPATH)\*\nlssup.lib \
|
||||||
$(TARGETPATH)\*\jbd.lib \
|
$(TARGETPATH)\*\jbd2.lib \
|
||||||
$(TARGETPATH)\*\ext3.lib \
|
$(TARGETPATH)\*\ext3.lib \
|
||||||
$(TARGETPATH)\*\ext4.lib
|
$(TARGETPATH)\*\ext4.lib
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user