diff options
author | robi <robi> | 2010-11-19 00:03:14 +0000 |
---|---|---|
committer | robi <robi> | 2010-11-19 00:03:14 +0000 |
commit | 9c00d1f8a21ff27f3dac4fc139f9199f9d77b87c (patch) | |
tree | 22faa4f761c75e06d4be8f6afaf339f09370fe6f /src | |
parent | a288dc7194011fb0fbf372c1e9ad40c0ae204963 (diff) |
changed metadata scan
Diffstat (limited to 'src')
-rw-r--r-- | src/magic_block_scan.c | 22 | ||||
-rw-r--r-- | src/util.c | 8 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/magic_block_scan.c b/src/magic_block_scan.c index e1bde79..439091c 100644 --- a/src/magic_block_scan.c +++ b/src/magic_block_scan.c @@ -183,9 +183,9 @@ static int check_file_data_end(struct found_data_t* this,unsigned char *buf, __u int ret = 0; size = get_block_len(buf); - ret = this->func(buf, &size ,this->scan ,0 , this); + ret = (this->func(buf, &size ,this->scan ,0 , this) & mask) ; - if (ret & mask) + if (ret) ret = file_data_correct_size(this,size); return ret; } @@ -215,7 +215,7 @@ static int check_file_data_possible(struct found_data_t* this, __u32 scan ,unsig -static int check_meta3_block(unsigned char *block_buf, blk_t blk, __u32 size){ +static int check_meta3_block(unsigned char *block_buf, blk_t blk, __u32 size, int flag){ blk_t block, *pb_block; int i,j ; @@ -226,7 +226,11 @@ static int check_meta3_block(unsigned char *block_buf, blk_t blk, __u32 size){ pb_block = (blk_t*)(block_buf+i); block = ext2fs_le32_to_cpu(*pb_block); if( block && (block < current_fs->super->s_blocks_count) && - (ext2fs_test_block_bitmap( d_bmap, block)) && (!ext2fs_test_block_bitmap(bmap,block))){ + (ext2fs_test_block_bitmap( d_bmap, block)) && ( ((!flag) && (!ext2fs_test_block_bitmap(bmap,block))) || + (((flag == 1) && (i == (size -4)) && (i>4))||(!ext2fs_test_block_bitmap(bmap,block))) || + (flag == 2) ) ){ + + if (i) { //work not by sparse file for (j = i - 4 ; j >= 0 ;j -= 4){ if (block == ext2fs_le32_to_cpu(*((blk_t*)(block_buf+j)))) @@ -283,7 +287,7 @@ static int check_dindirect_meta3(unsigned char * block_buf){ p_blk = (__u32*) block_buf; block = ext2fs_le32_to_cpu(*p_blk); io_channel_read_blk ( current_fs->io, block, 1, buf ); - if (check_meta3_block(buf, block, get_block_len(buf))){ + if (check_meta3_block(buf, block, get_block_len(buf),2)){ ret = check_indirect_meta3(buf); } free (buf); @@ -305,7 +309,7 @@ static int check_tindirect_meta3(unsigned char * block_buf){ p_blk = (__u32*) block_buf; block = ext2fs_le32_to_cpu(*p_blk); io_channel_read_blk ( current_fs->io, block, 1, buf ); - if (check_meta3_block(buf, block, get_block_len(buf))){ + if (check_meta3_block(buf, block, get_block_len(buf),2)){ ret = check_dindirect_meta3(buf); } free (buf); @@ -406,7 +410,7 @@ static int add_ext3_file_meta_data(struct found_data_t* this, unsigned char *buf next_meta = 0; io_channel_read_blk ( current_fs->io, meta, 1, buf ); - if (check_meta3_block(buf, meta, get_block_len(buf)) && check_dindirect_meta3(buf)){ + if (check_meta3_block(buf, meta, get_block_len(buf),1) && check_dindirect_meta3(buf)){ ret = inode_add_meta_block(this->inode , meta, &last_data, &next_meta, buf ); this->last = last_data; @@ -415,7 +419,7 @@ static int add_ext3_file_meta_data(struct found_data_t* this, unsigned char *buf next_meta = 0; io_channel_read_blk ( current_fs->io, meta, 1, buf ); - if (check_meta3_block(buf, meta, get_block_len(buf)) && check_tindirect_meta3(buf)){ + if (check_meta3_block(buf, meta, get_block_len(buf),1) && check_tindirect_meta3(buf)){ ret = inode_add_meta_block(this->inode , meta, &last_data, &next_meta, buf ); this->last = last_data; } @@ -460,7 +464,7 @@ static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_ while ((count >= 0) && (*(buf+count) == 0)) count-- ; if (ext2fs_le32_to_cpu(*(blk_t*)buf) == blk +1){ - if (check_meta3_block(buf, blk, count+1)){ + if (check_meta3_block(buf, blk, count+1, 0)){ retval = M_EXT3_META ; goto out; } @@ -525,6 +525,10 @@ unsigned long parse_ulong(const char *str, const char *cmd, } + +extern ext2fs_block_bitmap d_bmap; + + void get_nblock_len(char *buf, blk_t *blk, __u64 *p_len){ (*blk)++; *p_len += current_fs->blocksize ; @@ -555,7 +559,7 @@ int get_ind_block_len(char *buf, blk_t *blk, blk_t *last ,blk_t *next, __u64 *p_ else break; } if ((block >= current_fs->super->s_blocks_count) || - (ext2fs_test_block_bitmap(bmap,block)) || (io_channel_read_blk ( current_fs->io, block, 1, priv_buf ))){ + (!ext2fs_test_block_bitmap(d_bmap,block)) || (io_channel_read_blk ( current_fs->io, block, 1, priv_buf ))){ // fprintf(stderr,"ERROR: while read block %10u\n",block); return 0; } @@ -592,7 +596,7 @@ int get_dind_block_len(char *buf, blk_t *blk, blk_t *last, blk_t *next, __u64 *p else break; } if ((block >= current_fs->super->s_blocks_count) || - (ext2fs_test_block_bitmap(bmap,block)) || (io_channel_read_blk ( current_fs->io, block, 1, priv_buf ))){ + (!ext2fs_test_block_bitmap(d_bmap,block)) || (io_channel_read_blk ( current_fs->io, block, 1, priv_buf ))){ // fprintf(stderr,"ERROR: while read ind-block %10u\n",block); return 0; } |