summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrobi <robi>2011-12-16 20:10:38 +0000
committerrobi <robi>2011-12-16 20:10:38 +0000
commitbe0c55229494231393ae0f122cac8d19753d6804 (patch)
tree2a24350baffbeab4b2896261d0c57e7cf6579c43 /src
parentae69498e24734878c5b4116bbef0801312fc9b7d (diff)
BUG #018427: support for libext2fs 1.41.x and 1.42.x
Diffstat (limited to 'src')
-rw-r--r--src/block.c104
-rw-r--r--src/block.h10
-rw-r--r--src/ext4magic.c91
-rw-r--r--src/imap_search.c8
-rw-r--r--src/inode.c24
-rw-r--r--src/inode.h2
-rw-r--r--src/journal.c21
-rw-r--r--src/journal.h2
-rw-r--r--src/lookup_local.c4
-rw-r--r--src/recover.c12
-rw-r--r--src/util.c12
-rw-r--r--src/util.h16
12 files changed, 246 insertions, 60 deletions
diff --git a/src/block.c b/src/block.c
index f07e0bc..29d8afb 100644
--- a/src/block.c
+++ b/src/block.c
@@ -37,9 +37,9 @@ extern ext2fs_block_bitmap bmap ;
struct block_context {
ext2_filsys fs;
int (*func)(ext2_filsys fs,
- blk_t *blocknr,
+ blk64_t *blocknr,
e2_blkcnt_t bcount,
- blk_t ref_blk,
+ blk64_t ref_blk,
int ref_offset,
void *priv_data);
e2_blkcnt_t bcount;
@@ -73,6 +73,9 @@ struct ext2_extent_handle {
ext2_filsys fs;
ext2_ino_t ino;
struct ext2_inode *inode;
+#ifdef EXT2_FLAG_64BITS
+ struct ext2_inode inodebuf;
+#endif
int type;
int level;
int max_depth;
@@ -115,7 +118,15 @@ int read_block ( ext2_filsys fs, blk_t *blocknr, void *buf )
fprintf(stderr,"Error %d while read block\n", retval);
return retval;
}
-
+#ifdef EXT2_FLAG_64BITS
+int read_block64 ( ext2_filsys fs, blk64_t *blocknr, void *buf )
+{
+ errcode_t retval = io_channel_read_blk64 ( fs->io, *blocknr, 1, buf );
+ if (retval)
+ fprintf(stderr,"Error %d while read block\n", retval);
+ return retval;
+}
+#endif
@@ -184,7 +195,11 @@ static int mark_extent_block(ext2_filsys fs, char *extent_block ){
struct ext3_extent_header *eh;
struct ext3_extent_idx *idx;
int i, ret;
+#ifdef EXT2_FLAG_64BITS
+ blk64_t index_bl;
+#else
blk_t index_bl;
+#endif
char *buf = NULL;
eh = (struct ext3_extent_header*) extent_block;
@@ -193,13 +208,26 @@ static int mark_extent_block(ext2_filsys fs, char *extent_block ){
if (ext2fs_le16_to_cpu(eh->eh_depth)) {
for (i = 1; ((i <= ext2fs_le16_to_cpu(eh->eh_entries)) && (i <= ext2fs_le16_to_cpu(eh->eh_max))); i++){
idx = (struct ext3_extent_idx*) &(extent_block[12 * i]);
+#ifdef EXT2_FLAG_64BITS
+ index_bl = ext2fs_le32_to_cpu(idx->ei_leaf) +
+ ((__u64) ext2fs_le16_to_cpu(idx->ei_leaf_hi) << 32);
+#else
index_bl = ext2fs_le32_to_cpu(idx->ei_leaf);
+#endif
if (index_bl && index_bl <= fs->super->s_blocks_count ){
if (bmap){
+#ifdef EXT2_FLAG_64BITS
+ ext2fs_mark_generic_bmap(bmap, index_bl);
+#else
ext2fs_mark_generic_bitmap(bmap, index_bl);
+#endif
buf = malloc(fs->blocksize);
if (buf){
+#ifdef EXT2_FLAG_64BITS
+ ret = read_block64 (fs, &index_bl, buf );
+#else
ret = read_block (fs, &index_bl, buf );
+#endif
if (!ret)
ret = mark_extent_block(fs,buf);
free(buf);
@@ -239,13 +267,17 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block,
int ret = 0, changed = 0;
int i, flags, limit, offset;
blk_t *block_nr;
+ blk64_t blk64;
limit = ctx->fs->blocksize >> 2;
if (!(ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) &&
- !(ctx->flags & BLOCK_FLAG_DATA_ONLY))
- ret = (*ctx->func)(ctx->fs, ind_block,
+ !(ctx->flags & BLOCK_FLAG_DATA_ONLY)){
+ blk64 = *ind_block;
+ ret = (*ctx->func)(ctx->fs, &blk64,
BLOCK_COUNT_IND, ref_block,
ref_offset, ctx->priv_data);
+ *ind_block = blk64;
+ }
check_for_ro_violation_return(ctx, ret);
if (!*ind_block || (ret & BLOCK_ABORT)) {
ctx->bcount += limit;
@@ -270,9 +302,11 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block,
offset = 0;
if (ctx->flags & BLOCK_FLAG_APPEND) {
for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) {
- flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount,
+ blk64 = *block_nr;
+ flags = (*ctx->func)(ctx->fs, &blk64 , ctx->bcount,
*ind_block, offset,
ctx->priv_data);
+ *block_nr = blk64;
changed |= flags;
if (flags & BLOCK_ABORT) {
ret |= BLOCK_ABORT;
@@ -284,9 +318,11 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block,
for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) {
if (*block_nr == 0)
continue;
- flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount,
+ blk64 = *block_nr;
+ flags = (*ctx->func)(ctx->fs, &blk64, ctx->bcount,
*ind_block, offset,
ctx->priv_data);
+ *block_nr = blk64;
changed |= flags;
if (flags & BLOCK_ABORT) {
ret |= BLOCK_ABORT;
@@ -304,10 +340,13 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block,
}
if ((ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) &&
!(ctx->flags & BLOCK_FLAG_DATA_ONLY) &&
- !(ret & BLOCK_ABORT))
- ret |= (*ctx->func)(ctx->fs, ind_block,
+ !(ret & BLOCK_ABORT)){
+ blk64 = *ind_block;
+ ret |= (*ctx->func)(ctx->fs, &blk64 ,
BLOCK_COUNT_IND, ref_block,
ref_offset, ctx->priv_data);
+ *ind_block = blk64;
+ }
check_for_ro_violation_return(ctx, ret);
return ret;
}
@@ -320,13 +359,17 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block,
int ret = 0, changed = 0;
int i, flags, limit, offset;
blk_t *block_nr;
+ blk64_t blk64;
limit = ctx->fs->blocksize >> 2;
if (!(ctx->flags & (BLOCK_FLAG_DEPTH_TRAVERSE |
- BLOCK_FLAG_DATA_ONLY)))
- ret = (*ctx->func)(ctx->fs, dind_block,
+ BLOCK_FLAG_DATA_ONLY))){
+ blk64 = *dind_block;
+ ret = (*ctx->func)(ctx->fs, &blk64 ,
BLOCK_COUNT_DIND, ref_block,
ref_offset, ctx->priv_data);
+ *dind_block = blk64;
+ }
check_for_ro_violation_return(ctx, ret);
if (!*dind_block || (ret & BLOCK_ABORT)) {
ctx->bcount += limit*limit;
@@ -387,10 +430,14 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block,
}
if ((ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) &&
!(ctx->flags & BLOCK_FLAG_DATA_ONLY) &&
- !(ret & BLOCK_ABORT))
- ret |= (*ctx->func)(ctx->fs, dind_block,
+ !(ret & BLOCK_ABORT)){
+ blk64 = *dind_block;
+ ret |= (*ctx->func)(ctx->fs, &blk64,
BLOCK_COUNT_DIND, ref_block,
ref_offset, ctx->priv_data);
+
+ *dind_block = blk64;
+ }
check_for_ro_violation_return(ctx, ret);
return ret;
}
@@ -403,13 +450,17 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block,
int ret = 0, changed = 0;
int i, flags, limit, offset;
blk_t *block_nr;
+ blk64_t blk64;
limit = ctx->fs->blocksize >> 2;
if (!(ctx->flags & (BLOCK_FLAG_DEPTH_TRAVERSE |
- BLOCK_FLAG_DATA_ONLY)))
- ret = (*ctx->func)(ctx->fs, tind_block,
+ BLOCK_FLAG_DATA_ONLY))){
+ blk64 = *tind_block;
+ ret = (*ctx->func)(ctx->fs, &blk64 ,
BLOCK_COUNT_TIND, ref_block,
ref_offset, ctx->priv_data);
+ *tind_block = blk64;
+ }
check_for_ro_violation_return(ctx, ret);
if (!*tind_block || (ret & BLOCK_ABORT)) {
ctx->bcount += limit*limit*limit;
@@ -470,10 +521,13 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block,
}
if ((ctx->flags & BLOCK_FLAG_DEPTH_TRAVERSE) &&
!(ctx->flags & BLOCK_FLAG_DATA_ONLY) &&
- !(ret & BLOCK_ABORT))
- ret |= (*ctx->func)(ctx->fs, tind_block,
+ !(ret & BLOCK_ABORT)){
+ blk64 = *tind_block;
+ ret |= (*ctx->func)(ctx->fs, &blk64,
BLOCK_COUNT_TIND, ref_block,
ref_offset, ctx->priv_data);
+ *tind_block = blk64;
+ }
check_for_ro_violation_return(ctx, ret);
return ret;
}
@@ -485,9 +539,9 @@ errcode_t local_block_iterate3(ext2_filsys fs,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
- blk_t *blocknr,
+ blk64_t *blocknr,
e2_blkcnt_t blockcnt,
- blk_t ref_blk,
+ blk64_t ref_blk,
int ref_offset,
void *priv_data),
void *priv_data)
@@ -498,6 +552,7 @@ errcode_t local_block_iterate3(ext2_filsys fs,
errcode_t retval;
struct block_context ctx;
int limit;
+ blk64_t blk64;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
ctx.errcode = 0;
@@ -538,10 +593,11 @@ errcode_t local_block_iterate3(ext2_filsys fs,
if ((fs->super->s_creator_os == EXT2_OS_HURD) &&
!(flags & BLOCK_FLAG_DATA_ONLY)) {
if (inode.osd1.hurd1.h_i_translator) {
- ret |= (*ctx.func)(fs,
- &inode.osd1.hurd1.h_i_translator,
+ blk64 = inode.osd1.hurd1.h_i_translator;
+ ret |= (*ctx.func)(fs, &blk64,
BLOCK_COUNT_TRANSLATOR,
0, 0, priv_data);
+ inode.osd1.hurd1.h_i_translator = (blk_t) blk64;
if (ret & BLOCK_ABORT)
goto abort_exit;
check_for_ro_violation_goto(&ctx, ret, abort_exit);
@@ -552,7 +608,7 @@ errcode_t local_block_iterate3(ext2_filsys fs,
ext2_extent_handle_t handle = NULL;
struct ext2fs_extent extent;
e2_blkcnt_t blockcnt = 0;
- blk_t blk, new_blk;
+ blk64_t blk, new_blk;
int op = EXT2_EXTENT_ROOT;
int uninit;
unsigned int j;
@@ -649,8 +705,10 @@ errcode_t local_block_iterate3(ext2_filsys fs,
*/
for (i = 0; i < EXT2_NDIR_BLOCKS ; i++, ctx.bcount++) {
if (inode.i_block[i] || (flags & BLOCK_FLAG_APPEND)) {
- ret |= (*ctx.func)(fs, &inode.i_block[i],
+ blk64 = inode.i_block[i];
+ ret |= (*ctx.func)(fs, &blk64 ,
ctx.bcount, 0, i, priv_data);
+ inode.i_block[i] = (blk_t) blk64;
if (ret & BLOCK_ABORT)
goto abort_exit;
}
diff --git a/src/block.h b/src/block.h
index 97098c9..6436cb6 100644
--- a/src/block.h
+++ b/src/block.h
@@ -10,9 +10,9 @@ errcode_t local_block_iterate3(ext2_filsys fs,
int flags,
char *block_buf,
int (*func)(ext2_filsys fs,
- blk_t *blocknr,
+ blk64_t *blocknr,
e2_blkcnt_t blockcnt,
- blk_t ref_blk,
+ blk64_t ref_blk,
int ref_offset,
void *priv_data),
void *priv_data);
@@ -21,4 +21,10 @@ errcode_t local_block_iterate3(ext2_filsys fs,
int read_block ( ext2_filsys, blk_t*, void* ); //read filesystem block
+#ifdef EXT2_FLAG_64BITS
+int read_block64 ( ext2_filsys, blk64_t*, void* ); //read filesystem block64
+#endif
+
#endif //BLOCK_H
+
+
diff --git a/src/ext4magic.c b/src/ext4magic.c
index 26c5a2e..a710db8 100644
--- a/src/ext4magic.c
+++ b/src/ext4magic.c
@@ -74,7 +74,7 @@ void print_version ( void )
printf("libext2fs version : %s\n",libver);
int n = 1 ;
- if ( * ( char * ) &n == 1 ) // True if the cpu is little endian.
+ if ( * ( char * ) &n == 1 ) // True if the cpu is little endian.
printf("CPU is little endian.\n");
else
printf("CPU is big endian.\n");
@@ -85,6 +85,20 @@ void print_version ( void )
//subfunction for show_super_stats()
+#ifdef EXT2_FLAG_64BITS
+static void print_bg_opts(ext2_filsys fs, dgrp_t group, int mask,
+ const char *str, int *first, FILE *f)
+{
+ if (ext2fs_bg_flags_test(fs, group, mask)) {
+ if (*first) {
+ fputs(" [", f);
+ *first = 0;
+ } else
+ fputs(", ", f);
+ fputs(str, f);
+ }
+}
+#else
static void print_bg_opts(struct ext2_group_desc *gdp, int mask,
const char *str, int *first, FILE *f)
{
@@ -97,10 +111,13 @@ static void print_bg_opts(struct ext2_group_desc *gdp, int mask,
fputs(str, f);
}
}
+#endif
+
//print superblock
void show_super_stats(int header_only)
{
+ const char *units ="block";
dgrp_t i;
FILE *out;
struct ext2_group_desc *gdp;
@@ -115,12 +132,55 @@ void show_super_stats(int header_only)
}
for (i=0; i < current_fs->group_desc_count; i++)
+#ifdef EXT2_FLAG_64BITS
+ numdirs += ext2fs_bg_used_dirs_count(current_fs, i);
+#else
numdirs += current_fs->group_desc[i].bg_used_dirs_count;
+#endif
fprintf(out, "Directories: %d\n", numdirs);
gdt_csum = EXT2_HAS_RO_COMPAT_FEATURE(current_fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
+#ifdef EXT2_FLAG_64BITS
+ for (i = 0; i < current_fs->group_desc_count; i++) {
+ fprintf(out, " Group %2d: block bitmap at %llu, "
+ "inode bitmap at %llu, "
+ "inode table at %llu\n"
+ " %u free %s%s, "
+ "%u free %s, "
+ "%u used %s%s",
+ i, ext2fs_block_bitmap_loc(current_fs, i),
+ ext2fs_inode_bitmap_loc(current_fs, i),
+ ext2fs_inode_table_loc(current_fs, i),
+ ext2fs_bg_free_blocks_count(current_fs, i), units,
+ ext2fs_bg_free_blocks_count(current_fs, i) != 1 ?
+ "s" : "",
+ ext2fs_bg_free_inodes_count(current_fs, i),
+ ext2fs_bg_free_inodes_count(current_fs, i) != 1 ?
+ "inodes" : "inode",
+ ext2fs_bg_used_dirs_count(current_fs, i),
+ ext2fs_bg_used_dirs_count(current_fs, i) != 1 ? "directories"
+ : "directory", gdt_csum ? ", " : "\n");
+ if (gdt_csum)
+ fprintf(out, "%u unused %s\n",
+ ext2fs_bg_itable_unused(current_fs, i),
+ ext2fs_bg_itable_unused(current_fs, i) != 1 ?
+ "inodes" : "inode");
+ first = 1;
+ print_bg_opts(current_fs, i, EXT2_BG_INODE_UNINIT, "Inode not init",
+ &first, out);
+ print_bg_opts(current_fs, i, EXT2_BG_BLOCK_UNINIT, "Block not init",
+ &first, out);
+ if (gdt_csum) {
+ fprintf(out, "%sChecksum 0x%04x",
+ first ? " [":", ", ext2fs_bg_checksum(current_fs, i));
+ first = 0;
+ }
+ if (!first)
+ fputs("]\n", out);
+ }
+#else
gdp = &current_fs->group_desc[0];
for (i = 0; i < current_fs->group_desc_count; i++, gdp++) {
fprintf(out, " Group %2d: block bitmap at %u, "
@@ -155,6 +215,7 @@ void show_super_stats(int header_only)
if (!first)
fputs("]\n", out);
}
+#endif
return;
}
@@ -191,7 +252,7 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock,
if (open_flags & EXT2_FLAG_RW) {
open_flags &= ~EXT2_FLAG_RW;
}
-
+// open_flags |= EXT2_FLAG_64BITS;
retval = ext2fs_open(device, open_flags, superblock, blocksize,
unix_io_manager, &current_fs);
if (retval) {
@@ -214,16 +275,27 @@ static void open_filesystem(char *device, int open_flags, blk_t superblock,
if (magicscan){
// switch on magic scan function
+#ifdef EXT2_FLAG_64BITS
+ if( ext2fs_copy_generic_bmap(current_fs->inode_map, &imap) || ext2fs_copy_generic_bmap(current_fs->block_map, &bmap)){
+#else
if( ext2fs_copy_bitmap(current_fs->inode_map, &imap) || ext2fs_copy_bitmap(current_fs->block_map, &bmap)){
+#endif
fprintf(stderr,"%s Error while copy bitmap\n",device );
imap = NULL;
bmap = NULL;
}else{
int i;
+#ifdef EXT2_FLAG_64BITS
+ ext2fs_clear_generic_bmap(imap);
+ for (i = 1; i < current_fs->super->s_first_ino; i++)//mark inode 1-8
+ ext2fs_mark_generic_bmap(imap,(blk64_t) i);
+ ext2fs_clear_generic_bmap(bmap);
+#else
ext2fs_clear_inode_bitmap(imap);
- for (i = 1; i < current_fs->super->s_first_ino; i++)
- ext2fs_mark_generic_bitmap(imap,i); //mark inode 1-8
+ for (i = 1; i < current_fs->super->s_first_ino; i++)//mark inode 1-8
+ ext2fs_mark_generic_bitmap(imap,i);
ext2fs_clear_block_bitmap(bmap);
+#endif
}
}
@@ -912,9 +984,16 @@ if (mode & READ_JOURNAL){
imap = NULL;
}else{
int i;
- ext2fs_clear_inode_bitmap(imap);
+#ifdef EXT2_FLAG_64BITS
+ ext2fs_clear_generic_bmap(imap);
for (i = 1; i < current_fs->super->s_first_ino; i++)
- ext2fs_mark_generic_bitmap(imap,i); //mark inode 1-8
+ ext2fs_mark_generic_bmap(imap,(blk64_t) i); //mark inode 1-8
+
+#else
+ ext2fs_clear_inode_bitmap(imap);
+ for (i = 1; i < current_fs->super->s_first_ino; i++)//mark inode 1-8
+ ext2fs_mark_generic_bitmap(imap,i);
+#endif
}
}
diff --git a/src/imap_search.c b/src/imap_search.c
index 42fb207..d397380 100644
--- a/src/imap_search.c
+++ b/src/imap_search.c
@@ -40,8 +40,8 @@ struct privat {
//Subfunction for "local_block_iterate3()" for load the first blocks to identify filetype
-int first_blocks ( ext2_filsys fs, blk_t *blocknr, e2_blkcnt_t blockcnt,
- blk_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
+int first_blocks ( ext2_filsys fs, blk64_t *blocknr, e2_blkcnt_t blockcnt,
+ blk64_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
{
char *charbuf = NULL;
((struct privat*)priv)->buf;
@@ -183,7 +183,11 @@ inode_per_block = blocksize / inodesize;
inode_block_group = inode_per_group / inode_per_block;
for (group = 0 ; group < current_fs->group_desc_count ; group++){
+#ifdef EXT2_FLAG_64BITS
+ gdp = ext2fs_group_desc(current_fs, current_fs->group_desc, group);
+#else
gdp = &current_fs->group_desc[group];
+#endif
zero_flag = 0;
if (!(flag & 0x02)){ //skip this in disaster mode
diff --git a/src/inode.c b/src/inode.c
index 50c1840..39131f7 100644
--- a/src/inode.c
+++ b/src/inode.c
@@ -286,26 +286,27 @@ static void finish_range(struct list_blocks_struct *lb)
//subfunction for dump_blocks
static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
- blk_t *blocknr, e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t *block64nr, e2_blkcnt_t blockcnt,
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *private)
{
+ blk_t blocknr = (blk_t) *block64nr;
struct list_blocks_struct *lb = (struct list_blocks_struct *) private;
lb->total++;
if (blockcnt >= 0) {
//* See if we can add on to the existing range (if it exists)
if (lb->first_block &&
- (lb->last_block+1 == *blocknr) &&
+ (lb->last_block+1 == blocknr) &&
(lb->last_bcnt+1 == blockcnt)) {
- lb->last_block = *blocknr;
+ lb->last_block = blocknr;
lb->last_bcnt = blockcnt;
return 0;
}
//* Start a new range.
finish_range(lb);
- lb->first_block = lb->last_block = *blocknr;
+ lb->first_block = lb->last_block = blocknr;
lb->first_bcnt = lb->last_bcnt = blockcnt;
return 0;
}
@@ -316,11 +317,11 @@ static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
else
fprintf(lb->f, ", ");
if (blockcnt == -1)
- fprintf(lb->f, "(IND):%u", *blocknr);
+ fprintf(lb->f, "(IND):%u", blocknr);
else if (blockcnt == -2)
- fprintf(lb->f, "(DIND):%u", *blocknr);
+ fprintf(lb->f, "(DIND):%u", blocknr);
else if (blockcnt == -3)
- fprintf(lb->f, "(TIND):%u", *blocknr);
+ fprintf(lb->f, "(TIND):%u", blocknr);
return 0;
}
@@ -488,7 +489,7 @@ void dump_inode(FILE *out, const char *prefix,
//calculate the position of inode in FS
blk_t get_inode_pos(struct ext2_super_block *es ,struct inode_pos_struct *pos, ext2_ino_t inode_nr,int flag){
-
+//FIXME blk64_t
__u32 inode_group, group_offset, inodes_per_block, inode_offset;
blk_t inode_block;
@@ -496,8 +497,11 @@ blk_t get_inode_pos(struct ext2_super_block *es ,struct inode_pos_struct *pos, e
inode_group = ((inode_nr - 1) / es->s_inodes_per_group);
group_offset = ((inode_nr - 1) % es->s_inodes_per_group);
inodes_per_block = (current_fs->blocksize / pos->size );
-
+#ifdef EXT2_FLAG_64BITS
+ inode_block = (blk_t) ext2fs_inode_table_loc(current_fs,inode_group) + (group_offset / inodes_per_block);
+#else
inode_block = current_fs->group_desc[inode_group].bg_inode_table + (group_offset / inodes_per_block);
+#endif
inode_offset = ((group_offset % inodes_per_block) * pos->size );
if (flag)
printf("Inode %u is at group %u, block %u, offset %u\n", inode_nr, inode_group, inode_block, inode_offset);
diff --git a/src/inode.h b/src/inode.h
index 6127ac6..86184d4 100644
--- a/src/inode.h
+++ b/src/inode.h
@@ -63,7 +63,7 @@ static void dump_xattr_string(FILE*, const char*, int);//subfunction for dump_in
static void local_dump_extents(FILE*, const char*, struct ext2_inode *,int , int, int );//print Blocks of inode (ext4)
static void dump_inode_extra(FILE*, const char* , ext2_ino_t, struct ext2_inode_large*);//print extended attribute of Inode
static void finish_range(struct list_blocks_struct*);//subfunction for dump_blocks
-static int list_blocks_proc(ext2_filsys, blk_t* , e2_blkcnt_t,blk_t, int, void*);//subfunction for dump_blocks
+static int list_blocks_proc(ext2_filsys, blk64_t* , e2_blkcnt_t,blk64_t, int, void*);//subfunction for dump_blocks
static void dump_blocks(FILE*, const char*, struct ext2_inode *);// print the Datablocks from Inode (ext3)
diff --git a/src/journal.c b/src/journal.c
index 9c5bc79..bfd255a 100644
--- a/src/journal.c
+++ b/src/journal.c
@@ -406,7 +406,11 @@ static int block_is_inodetable(blk64_t block){
//FIXME for struct ext4_group_desc 48/64BIT
for (group = 0; group < current_fs->group_desc_count; group++){
- gdp = &current_fs->group_desc[group];
+#ifdef EXT2_FLAG_64BITS
+ gdp = ext2fs_group_desc(current_fs, current_fs->group_desc, group);
+#else
+ gdp = &current_fs->group_desc[group];
+#endif
if (block >= (gdp->bg_inode_table + current_fs->inode_blocks_per_group))
continue;
if (block >= gdp->bg_inode_table){
@@ -546,7 +550,7 @@ return journal_nr;
// get the last dir-block for transaction from journal or if not, found the real block
//FIXME: blk64_t ????
-int get_last_block(char *buf, blk_t *block, __u32 t_start, __u32 t_end){
+int get_last_block(char *buf, blk64_t *block, __u32 t_start, __u32 t_end){
int retval = 0;
int i , count , got;
char *journal_tag_buf = NULL;
@@ -884,14 +888,23 @@ int get_block_bitmap_list( journal_bitmap_tag_t **bitmap_list){
count = sum = 0;
for (i = 0; i < pt_count ; i++, list_pointer++ )
for (j = 0 ; j < current_fs->group_desc_count; j++ )
- if (list_pointer->f_blocknr == (blk64_t) current_fs->group_desc[j].bg_block_bitmap) count++ ;
+#ifdef EXT2_FLAG_64BITS
+ if( list_pointer->f_blocknr == (blk64_t) ext2fs_block_bitmap_loc(current_fs, j))
+#else
+ if (list_pointer->f_blocknr == (blk64_t) current_fs->group_desc[j].bg_block_bitmap)
+#endif
+ count++ ;
if (count && (tag_buf = malloc((sizeof(journal_bitmap_tag_t) * count)))){
fill_pointer = (journal_bitmap_tag_t*)tag_buf ;
list_pointer = pt_buff ;
for ( i = 0 ; (i < pt_count && sum < count); i++ , list_pointer++ )
for ( j = 0; j < current_fs->group_desc_count; j++ )
- if (list_pointer->f_blocknr == (blk64_t) current_fs->group_desc[j].bg_block_bitmap) {
+#ifdef EXT2_FLAG_64BITS
+ if( list_pointer->f_blocknr == (blk64_t) ext2fs_block_bitmap_loc(current_fs, j)){
+#else
+ if (list_pointer->f_blocknr == (blk64_t) current_fs->group_desc[j].bg_block_bitmap){
+#endif
fill_pointer->blockgroup = (blk64_t) j;
fill_pointer->j_blocknr = list_pointer->j_blocknr;
fill_pointer->transaction = list_pointer->transaction;
diff --git a/src/journal.h b/src/journal.h
index 95320c6..1e90ca9 100644
--- a/src/journal.h
+++ b/src/journal.h
@@ -71,7 +71,7 @@ int dump_journal_block( __u32 , int );
void print_block_transaction(blk64_t,int);//print all transactions for a fs-block
__u32 get_journal_blocknr(blk64_t, __u32);// get the last dir-block for transaction from journal or if not found the real block
-int get_last_block(char*, blk_t*, __u32, __u32);// get the last dir-block for transaction from journal or if not, found the real block
+int get_last_block(char*, blk64_t*, __u32, __u32);// get the last dir-block for transaction from journal or if not, found the real block
int get_block_bitmap_list( journal_bitmap_tag_t**);//get a list of all copies of blockbitmap from journal
int init_block_bitmap_list(ext2fs_block_bitmap* , __u32); //create and init the the journal block bitmap
void clear_block_bitmap_list(ext2fs_block_bitmap); //destroy the journal block bitmap
diff --git a/src/lookup_local.c b/src/lookup_local.c
index 7235c6d..4f62414 100644
--- a/src/lookup_local.c
+++ b/src/lookup_local.c
@@ -275,9 +275,9 @@ static int convert_dir_block(char *buf, int flags){
* local_dir_iterate3() (modi of ext2fs_process_dir_block
*/
static int local_process_dir_block(ext2_filsys fs,
- blk_t *blocknr,
+ blk64_t *blocknr,
e2_blkcnt_t blockcnt,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
diff --git a/src/recover.c b/src/recover.c
index 1c720ba..84e3b72 100644
--- a/src/recover.c
+++ b/src/recover.c
@@ -150,8 +150,8 @@ return ;
// Subfunction for "local_block_iterate3()" for check if the blocks allocated
- static int check_block(ext2_filsys fs, blk_t *blocknr, e2_blkcnt_t blockcnt,
- blk_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
+ static int check_block(ext2_filsys fs, blk64_t *blocknr, e2_blkcnt_t blockcnt,
+ blk64_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
{
//FIXME:
if (*blocknr >= fs->super->s_blocks_count)
@@ -168,8 +168,8 @@ return 0;
//Subfunction for "local_block_iterate3()" read a blocks of a long symlink
-static int read_syslink_block ( ext2_filsys fs, blk_t *blocknr, e2_blkcnt_t blockcnt,
- blk_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
+static int read_syslink_block ( ext2_filsys fs, blk64_t *blocknr, e2_blkcnt_t blockcnt,
+ blk64_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
{
char *charbuf =((struct privat*)priv)->buf;
__u32 nbytes;
@@ -199,8 +199,8 @@ return 0;
//Subfunction for "local_block_iterate3()" for recover the blocks of a real file
-static int write_block ( ext2_filsys fs, blk_t *blocknr, e2_blkcnt_t blockcnt,
- blk_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
+static int write_block ( ext2_filsys fs, blk64_t *blocknr, e2_blkcnt_t blockcnt,
+ blk64_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
{
int fd = ((struct privat*)priv)->fd;
char *charbuf =((struct privat*)priv)->buf;
diff --git a/src/util.c b/src/util.c
index 3255d29..26acc5b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -135,7 +135,11 @@ inode_per_block = blocksize / inodesize;
inode_block_group = inode_per_group / inode_per_block;
for (group = 0 ; group < fs->group_desc_count ; group++){
- gdp = &fs->group_desc[group];
+#ifdef EXT2_FLAG_64BITS
+ gdp = ext2fs_group_desc(current_fs, current_fs->group_desc, group);
+#else
+ gdp = &current_fs->group_desc[group];
+#endif
zero_flag = 0;
// NEXT GROUP IF INODE NOT INIT
@@ -292,7 +296,11 @@ inode_block_group = inode_per_group / inode_per_block;
for (flag=0;flag<2;flag++){
for (group = 0 ; group < fs->group_desc_count ; group++){
- gdp = &fs->group_desc[group];
+#ifdef EXT2_FLAG_64BITS
+ gdp = ext2fs_group_desc(current_fs, current_fs->group_desc, group);
+#else
+ gdp = &current_fs->group_desc[group];
+#endif
zero_flag = 0;
// NEXT GROUP IF INODE NOT INIT
diff --git a/src/util.h b/src/util.h
index 1299f62..ac1d576 100644
--- a/src/util.h
+++ b/src/util.h
@@ -125,7 +125,21 @@ struct inode_nr_collect{
};
-//struct for generic bitmap
+//struct for generic bitmap
+/*
+struct ext2fs_struct_loc64_generic_bitmap {
+ errcode_t magic;
+ ext2_filsys fs;
+ struct ext2_bitmap_ops *bitmap_ops;
+ int flags;
+ __u64 start, end;
+ __u64 real_end;
+ int cluster_bits;
+ char *description;
+ void *private;
+ errcode_t base_error_code;
+};*/
+
struct ext2fs_struct_loc_generic_bitmap {
errcode_t magic;
ext2_filsys fs;