From 45f2227fe9b64d8d1520c9ec0a4baff9f6cf6ea2 Mon Sep 17 00:00:00 2001 From: robi Date: Thu, 14 Oct 2010 18:13:07 +0000 Subject: +ogg() and same smal bugs --- src/file_type.c | 37 ++++++++++++++++++++++++++++++++++++- src/hard_link_stack.h | 2 +- src/inode.c | 2 +- src/journal.h | 2 +- src/magic_block_scan.c | 9 +++++---- src/util.h | 2 +- 6 files changed, 45 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/file_type.c b/src/file_type.c index 8dbaddc..7d21d87 100644 --- a/src/file_type.c +++ b/src/file_type.c @@ -843,6 +843,41 @@ int file_SQLite(unsigned char *buf, int *size, __u32 scan , int flag, struct fou } +//ogg +int file_ogg(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){ + int ret = 0; + unsigned char token[7]= {0x80, 't', 'h', 'e', 'o', 'r', 'a'}; + + //FIXME for ext4. must follow the bitstream by the page header (variable page size, 4-8 kB, maximum 65307) + + switch (flag){ + case 0 : + if (*size < (current_fs->blocksize -7)){ + *size += 2; + ret =1; + } + else{ + if (*size < (current_fs->blocksize -2)){ + *size += 2; + ret =2; + } + } + break; + case 1 : + return (scan & (M_IS_META | M_IS_FILE | M_TXT)) ? 0 :1 ; + break; + + case 2 : + if(!(memcmp(&buf[28], token, 7))){ + f_data->name[strlen(f_data->name)-1] == 'm' ; + return 0; + } + } + return ret; +} + + + //change this only carefully //Although the scanner is controlled here, but you can not directly configure whether a file is found or not. //This function has a strong influence on the accuracy of the result. @@ -870,7 +905,7 @@ void get_file_property(struct found_data_t* this){ break; case 0x0105 : //ogg - // this->func = file_ogg ; + this->func = file_ogg ; strncat(this->name,".ogg",7); break; diff --git a/src/hard_link_stack.h b/src/hard_link_stack.h index eea5ed7..639dd1f 100644 --- a/src/hard_link_stack.h +++ b/src/hard_link_stack.h @@ -46,4 +46,4 @@ int match_link_stack(ext2_ino_t, __u32 ); void clear_link_stack(); -#endif \ No newline at end of file +#endif diff --git a/src/inode.c b/src/inode.c index 27fff1c..5ffeb11 100644 --- a/src/inode.c +++ b/src/inode.c @@ -999,4 +999,4 @@ int inode_add_meta_block(struct ext2_inode_large* inode , blk_t blk, blk_t *last } return 0; -} \ No newline at end of file +} diff --git a/src/journal.h b/src/journal.h index 3f3648a..95320c6 100644 --- a/src/journal.h +++ b/src/journal.h @@ -77,4 +77,4 @@ int init_block_bitmap_list(ext2fs_block_bitmap* , __u32); //create and init the void clear_block_bitmap_list(ext2fs_block_bitmap); //destroy the journal block bitmap int next_block_bitmap(ext2fs_block_bitmap); //produces a differential block bitmap for a transaction from the Journal -#endif \ No newline at end of file +#endif diff --git a/src/magic_block_scan.c b/src/magic_block_scan.c index 4d59235..1a10176 100644 --- a/src/magic_block_scan.c +++ b/src/magic_block_scan.c @@ -422,7 +422,8 @@ static int skip_block(blk_t *p_blk ,struct ext2fs_struct_loc_generic_bitmap *ds_ o_blk = (*p_blk) >> 3; p_bmap = (struct ext2fs_struct_loc_generic_bitmap *) bmap; - while (((! *(ds_bmap->bitmap + o_blk)) || (*(ds_bmap->bitmap + o_blk) == 0xff)) && (o_blk < (ds_bmap->end >> 3))){ + while (((! *(ds_bmap->bitmap + o_blk)) || (*(p_bmap->bitmap + o_blk) == (unsigned char)0xff) || + (*(ds_bmap->bitmap + o_blk) == *(p_bmap->bitmap + o_blk))) && (o_blk < (ds_bmap->end >> 3))){ o_blk ++; flag = 1; } @@ -471,7 +472,7 @@ static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_ retval |= M_BINARY ; } - if (!(retval & M_TXT) && (strstr(magic_buf,"application/octet-stream")) && (!(strncmp(text,"data",4)))){ + if (!(retval & M_TXT) && (strstr(magic_buf,"application/octet-stream")) && ((!(strncmp(text,"data",4))) || (!(strncmp(text,"text",4))))){ retval |= M_DATA; } @@ -575,7 +576,7 @@ static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_ out: #ifdef DEBUG_MAGIC_SCAN - printf("BLOCK_SCAN : 0x%08x\n",retval & 0xffffe000); + printf("BLOCK_SCAN : Block = %010u ; 0x%08x\n",blk, retval & 0xffffe000); blockhex(stdout,buf,0,(count < (64)) ? count : 64 ); #endif retval |= (count+1); @@ -888,7 +889,7 @@ while (ds_retval){ printf("stop no file-end\n"); #endif file_data = soft_border(des_dir,buf+((j-1)*blocksize), file_data, &follow, flag[j-1]); - i = j - 11; + i = j - 12; } else i = j; diff --git a/src/util.h b/src/util.h index 9922ea1..d630ce6 100644 --- a/src/util.h +++ b/src/util.h @@ -111,7 +111,7 @@ struct ext2fs_struct_loc_generic_bitmap { __u32 start, end; __u32 real_end; char * description; - char * bitmap; + unsigned char *bitmap; errcode_t base_error_code; __u32 reserved[7]; }; -- cgit v1.2.3