summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrobi <robi>2011-10-23 12:24:44 +0000
committerrobi <robi>2011-10-23 12:24:44 +0000
commit43108fe26c6c7c2168fe2253fbf7c30db0f8bab7 (patch)
tree5d781593b50024fe3ded04c9ed8f591cf8618636 /src
parente19aee9ba2dd89c142329e1fe7cd1109149cba4d (diff)
type sorted file names with extension in MAGIC-2/
Diffstat (limited to 'src')
-rw-r--r--src/ext4magic.c4
-rw-r--r--src/file_type.c119
-rw-r--r--src/imap_search.c150
-rw-r--r--src/magic_block_scan.c2
-rw-r--r--src/util.h1
5 files changed, 198 insertions, 78 deletions
diff --git a/src/ext4magic.c b/src/ext4magic.c
index 7d19983..1d1baf0 100644
--- a/src/ext4magic.c
+++ b/src/ext4magic.c
@@ -637,7 +637,7 @@ while ((c = getopt (argc, argv, "TJRMLlmrSxi:t:j:f:Vd:B:b:a:I:H")) != EOF) {
}
}
- if (getuid()) mode = 0;
+// if (getuid()) mode = 0;
if (optind < argc)
open_filesystem(argv[optind], open_flags,superblock, blocksize, magicscan, data_filename);
@@ -994,7 +994,7 @@ if ((mode & COMMAND_INODE) && (mode & RECOVER_INODE))
dir = get_dir3(NULL,0, inode_nr , "",pathname, t_after,t_before, recoverquality );
if (dir) {
- lookup_local(des_dir, dir,t_after,t_before, recoverquality | recovermodus );
+// lookup_local(des_dir, dir,t_after,t_before, recoverquality | recovermodus );
if (recovermodus & HIST_DIR )
print_coll_list(t_after, t_before, format);
//Magic step 1 + 2 +3
diff --git a/src/file_type.c b/src/file_type.c
index 72770ad..e287fbe 100644
--- a/src/file_type.c
+++ b/src/file_type.c
@@ -47,13 +47,13 @@ int ident_file(struct found_data_t *new, __u32 *scan, char *magic_buf, char *buf
//Please do not modify the following lines.
//they are used for indices to the filestypes
char typestr[] ="application/ audio/ image/ message/ model/ text/ video/ ";
- char imagestr[] ="gif jp2 jpeg png svg+xml tiff vnd.adobe.photoshop vnd.djvu x-coreldraw x-cpi x-ico x-ms-bmp x-niff x-portable-bitmap x-portable-greymap x-portable-pixmap x-psion-sketch x-quicktime x-unknown x-xcursor x-xpmi x-tga ";
+ char imagestr[] ="gif jp2 jpeg png svg+xml tiff vnd.adobe.photoshop vnd.djvu x-coreldraw x-cpi x-ico x-ms-bmp x-niff x-portable-bitmap x-portable-greymap x-portable-pixmap x-psion-sketch x-quicktime x-unknown x-xcursor x-xpmi x-tga x-xcf ";
char videostr[] ="3gpp h264 mp2p mp2t mp4 mp4v-es mpeg mpv quicktime x-flc x-fli x-flv x-jng x-mng x-msvideo x-sgi-movie x-unknown x-ms-asf x-matroska webm ";
char audiostr[] ="basic midi mp4 mpeg x-adpcm x-aiff x-dec-basic x-flac x-hx-aac-adif x-hx-aac-adts x-mod x-mp4a-latm x-pn-realaudio x-unknown x-wav ";
char messagestr[] ="news rfc822 ";
char modelstr[] ="vrml x3d ";
char applistr[] ="dicom mac-binhex40 msword octet-stream ogg pdf pgp pgp-encrypted pgp-keys pgp-signature postscript unknown+zip vnd.google-earth.kml+xml vnd.google-earth.kmz vnd.lotus-wordpro vnd.ms-cab-compressed vnd.ms-excel vnd.ms-tnef vnd.oasis.opendocument. vnd.rn-realmedia vnd.symbian.install x-123 x-adrift x-archive x-arc x-arj x-bittorrent x-bzip2 x-compress x-coredump x-cpio x-dbf x-dbm x-debian-package x-dosexec x-dvi x-eet x-elc x-executable x-gdbm x-gnucash x-gnumeric x-gnupg-keyring x-gzip x-hdf x-hwp x-ichitaro4 x-ichitaro5 x-ichitaro6 x-iso9660-image x-java-applet x-java-jce-keystore x-java-keystore x-java-pack200 x-kdelnk x-lha x-lharc x-lzip x-mif xml xml-sitemap x-msaccess x-ms-reader x-object x-pgp-keyring x-quark-xpress-3 x-quicktime-player x-rar x-rpm x-sc x-setupscript x-sharedlib x-shockwave-flash x-stuffit x-svr4-package x-tar x-tex-tfm x-tokyocabinet-btree x-tokyocabinet-fixed x-tokyocabinet-hash x-tokyocabinet-table x-xz x-zoo zip x-font-ttf x-7z-compressed ";
- char textstr[] = "html PGP rtf texmacs troff vnd.graphviz x-awk x-diff x-fortran x-gawk x-info x-lisp x-lua x-msdos-batch x-nawk x-perl x-php x-shellscript x-texinfo x-tex x-vcard x-xmcd plain x-pascal x-c++ x-c x-mail x-makefile x-asm x-python text ";
+ char textstr[] = "html PGP rtf texmacs troff vnd.graphviz x-awk x-diff x-fortran x-gawk x-info x-lisp x-lua x-msdos-batch x-nawk x-perl x-php x-shellscript x-texinfo x-tex x-vcard x-xmcd plain x-pascal x-c++ x-c x-mail x-makefile x-asm x-python x-java text ";
//Files not found as mime-type
char undefstr[] ="MPEG Targa 7-zip cpio CD-ROM DVD 9660 Kernel boot ext2 ext3 ext4 Image CDF SQLite OpenOffice.org Microsoft VMWare3 VMware4 JPEG ART PCX RIFF DIF IFF ATSC ScreamTracker EBML LZMA Audio=Visual Sample=Vision ISO=Media Linux filesystem x86 LUKS ";
//-----------------------------------------------------------------------------------
@@ -6458,7 +6458,7 @@ void get_file_property(struct found_data_t* this){
case 0x0104 : //octet-stream
// this->func = file_octet-stream;
- strncat(this->name,".unknow",7);
+ strncat(this->name,".unknown",8);
break;
case 0x0105 : //ogg
@@ -6528,7 +6528,7 @@ void get_file_property(struct found_data_t* this){
case 0x0112 : //vnd.ms-tnef
this->func = file_none ;
- // strncat(this->name,".vnd.ms-tnef",7);
+ strncat(this->name,".dat",7);
break;
case 0x0113 : //vnd.oasis.opendocument.
@@ -6558,12 +6558,12 @@ void get_file_property(struct found_data_t* this){
case 0x0115 : //vnd.symbian.install
// this->func = file_vnd.symbian.install ;
- // strncat(this->name,".vnd.symbian.install",7);
+ strncat(this->name,".sis",7);
break;
case 0x0116 : //x-123
// this->func = file_x-123 ;
- // strncat(this->name,".x-123",7);
+ strncat(this->name,".123",7);
break;
case 0x0117 : //x-adrift
@@ -6578,7 +6578,7 @@ void get_file_property(struct found_data_t* this){
case 0x0119 : //x-arc deaktiv
// this->func = file_x-arc ;
- // strncat(this->name,".x-arc",7);
+ strncat(this->name,".arc",7);
break;
case 0x011a : //x-arj
@@ -6613,17 +6613,17 @@ void get_file_property(struct found_data_t* this){
case 0x0120 : //x-dbf
// this->func = file_x-dbf ;
- // strncat(this->name,".x-dbf",7);
+ strncat(this->name,".dbf",7);
break;
case 0x0121 : //x-dbm
// this->func = file_x-dbm ;
- // strncat(this->name,".x-dbm",7);
+ strncat(this->name,".dbm",7);
break;
case 0x0122 : //x-debian-package
// this->func = file_x-debian-package ;
- // strncat(this->name,".x-debian-package",7);
+ strncat(this->name,".deb",7);
break;
case 0x0123 : //x-dosexec
@@ -6638,12 +6638,12 @@ void get_file_property(struct found_data_t* this){
case 0x0125 : //x-eet
// this->func = file_x-eet ;
- // strncat(this->name,".x-eet",7);
+ strncat(this->name,".eet",7);
break;
case 0x0126 : //x-elc
// this->func = file_x-elc ;
- // strncat(this->name,".x-elc",7);
+ strncat(this->name,".elc",7);
break;
case 0x0127 : //x-executable
@@ -6653,22 +6653,22 @@ void get_file_property(struct found_data_t* this){
case 0x0128 : //x-gdbm
// this->func = file_x-gdbm ;
- // strncat(this->name,".x-gdbm",7);
+ strncat(this->name,".dbm",7);
break;
case 0x0129 : //x-gnucash
- // this->func = file_x-gnucash ;
- // strncat(this->name,".x-gnucash",7);
+ this->func = file_txt ;
+ strncat(this->name,".xml",7);
break;
case 0x012a : //x-gnumeric
// this->func = file_x-gnumeric ;
- // strncat(this->name,".x-gnumeric",7);
+ strncat(this->name,".gnm",7);
break;
case 0x012b : //x-gnupg-keyring deaktiv
// this->func = file_x-gnupg-keyring ;
- // strncat(this->name,".x-gnupg-keyring",7);
+ strncat(this->name,".key",7);
break;
case 0x012c : //x-gzip
@@ -6683,22 +6683,22 @@ void get_file_property(struct found_data_t* this){
case 0x012e : //x-hwp
// this->func = file_x-hwp ;
- // strncat(this->name,".x-hwp",7);
+ strncat(this->name,".hwp",7);
break;
case 0x012f : //x-ichitaro4
// this->func = file_x-ichitaro4 ;
- // strncat(this->name,".x-ichitaro4",7);
+ strncat(this->name,".JDT",7);
break;
case 0x0130 : //x-ichitaro5
// this->func = file_x-ichitaro5 ;
- // strncat(this->name,".x-ichitaro5",7);
+ strncat(this->name,".JDT",7);
break;
case 0x0131 : //x-ichitaro6
// this->func = file_x-ichitaro6 ;
- // strncat(this->name,".x-ichitaro6",7);
+ strncat(this->name,".JDT",7);
break;
case 0x0132 : //x-iso9660-image
@@ -6708,7 +6708,7 @@ void get_file_property(struct found_data_t* this){
case 0x0133 : //x-java-applet
// this->func = file_x-java-applet ;
- strncat(this->name,".java",7);
+ strncat(this->name,".jar",7);
break;
case 0x0134 : //x-java-jce-keystore
@@ -6738,12 +6738,12 @@ void get_file_property(struct found_data_t* this){
case 0x0139 : //x-lharc
// this->func = file_x-lharc ;
- // strncat(this->name,".x-lharc",7);
+ strncat(this->name,".lzs",7);
break;
case 0x013a : //x-lzip
// this->func = file_x-lzip ;
- // strncat(this->name,".x-lzip",7);
+ strncat(this->name,".lz",7);
break;
case 0x013b : //x-mif
@@ -6783,7 +6783,7 @@ void get_file_property(struct found_data_t* this){
case 0x0142 : //x-quark-xpress-3
// this->func = file_x-quark-xpress-3 ;
- // strncat(this->name,".x-quark-xpress-3",7);
+ strncat(this->name,".qxp",7);
break;
case 0x0143 : //x-quicktime-player
@@ -6803,7 +6803,7 @@ void get_file_property(struct found_data_t* this){
case 0x0146 : //x-sc
// this->func = file_x-sc ;
- // strncat(this->name,".x-sc",7);
+ strncat(this->name,".sc",7);
break;
case 0x0147 : //x-setupscript
@@ -6868,7 +6868,7 @@ void get_file_property(struct found_data_t* this){
case 0x0153 : //x-zoo
// this->func = file_x-zoo ;
- // strncat(this->name,".x-zoo",7);
+ strncat(this->name,".zoo",7);
break;
case 0x0154 : //zip
@@ -6992,7 +6992,7 @@ void get_file_property(struct found_data_t* this){
case 0x0306 : //tiff
this->func = file_tiff ;
- strncat(this->name,".tiff",7);
+ strncat(this->name,".tif",7);
break;
case 0x0307 : //vnd.adobe.photoshop
@@ -7012,7 +7012,7 @@ void get_file_property(struct found_data_t* this){
case 0x030a : //x-cpi
// this->func = file_x-cpi ;
- // strncat(this->name,".x-cpi",7);
+ strncat(this->name,".cpi",7);
break;
case 0x030b : //x-ico
@@ -7057,7 +7057,7 @@ void get_file_property(struct found_data_t* this){
case 0x0313 : //x-unknown
// this->func = file_x-unknown ;
- // strncat(this->name,".x-unknown",7);
+ strncat(this->name,".x-unknown",7);
break;
case 0x0314 : //x-xcursor
@@ -7074,7 +7074,12 @@ void get_file_property(struct found_data_t* this){
this->func = file_tga ;
strncat(this->name,".tga",7);
break;
-
+
+ case 0x0317 : //x-xcf
+ // this->func = file_x-xcf;
+ strncat(this->name,".xcf",7);
+ break;
+
//----------------------------------------------------------------
//Messages
@@ -7111,7 +7116,7 @@ void get_file_property(struct found_data_t* this){
case 0x0602 : //PGP
this->func = file_txt ;
- // strncat(this->name,".PGP",7);
+ strncat(this->name,".pgp",7);
break;
case 0x0603 : //rtf
@@ -7121,7 +7126,7 @@ void get_file_property(struct found_data_t* this){
case 0x0604 : //texmacs
// this->func = file_texmacs ;
- // strncat(this->name,".texmacs",7);
+ strncat(this->name,".tm",7);
break;
case 0x0605 : //troff
@@ -7131,7 +7136,7 @@ void get_file_property(struct found_data_t* this){
case 0x0606 : //vnd.graphviz
// this->func = file_vnd.graphviz ;
- // strncat(this->name,".vnd.graphviz",7);
+ strncat(this->name,".gv",7);
break;
case 0x0607 : //x-awk
@@ -7166,7 +7171,7 @@ void get_file_property(struct found_data_t* this){
case 0x060d : //x-lua
// this->func = file_x-lua ;
- // strncat(this->name,".x-lua",7);
+ strncat(this->name,".lua",7);
break;
case 0x060e : //x-msdos-batch
@@ -7254,10 +7259,14 @@ void get_file_property(struct found_data_t* this){
strncat(this->name,".py",7);
break;
+ case 0x061f : //x-java
+ this->func = file_txt ;
+ strncat(this->name,".jar",7);
+ break;
- case 0x061f : //text (for all unknown)
+ case 0x0620 : //text (for all unknown)
this->func = file_txt ;
- // strncat(this->name,".txt",7);
+ strncat(this->name,".txt",7);
break;
//----------------------------------------------------------------
@@ -7344,7 +7353,7 @@ void get_file_property(struct found_data_t* this){
case 0x0711 : //x-unknown
// this->func = file_x-unknown ;
- // strncat(this->name,".x-unknown",7);
+ strncat(this->name,".unknown",7);
break;
case 0x0712 : //x-ms-asf
@@ -7409,21 +7418,6 @@ void get_file_property(struct found_data_t* this){
strncat(this->name,".iso",7);
break;
-/* case 0x080a : //Linux
- // this->func = file_Linux ;
- // strncat(this->name,".Linux",7);
- break;
-
- case 0x080b : //filesystem
- // this->func = file_filesystem ;
- strncat(this->name,".iso",7);
- break;
-
- case 0x080c : //x86
- // this->func = file_x86 ;
- strncat(this->name,".iso",7);
- break;*/
-
case 0x080a : //ext2
this->func = file_ext2fs ;
strncat(this->name,".ext2",7);
@@ -7446,7 +7440,7 @@ void get_file_property(struct found_data_t* this){
case 0x080e : //CDF
this->func = file_CDF ;
- // strncat(this->name,".doc",7);
+ strncat(this->name,".doc",7);
break;
case 0x080f : //SQLite
@@ -7461,7 +7455,7 @@ void get_file_property(struct found_data_t* this){
case 0x0811 : //Microsoft
this->func = file_CDF ;
- // strncat(this->name,".doc",7);
+ strncat(this->name,".doc",7);
break;
case 0x0812 : //VMWare3
@@ -7538,21 +7532,6 @@ void get_file_property(struct found_data_t* this){
strncat(this->name,".mp4",7);
break;
-/* case 0x0821 : //ext2
- this->func = file_ext2fs ;
- strncat(this->name,".ext2",7);
- break;
-
- case 0x0822 : //ext3
- this->func = file_ext2fs ;
- strncat(this->name,".ext3",7);
- break;
-
- case 0x0823 : //ext4
- this->func = file_ext2fs ;
- strncat(this->name,".ext4",7);
- break;*/
-
case 0x0821 : //Linux
// this->func = file_Linux ;
// strncat(this->name,".Linux",7);
diff --git a/src/imap_search.c b/src/imap_search.c
index 54578a2..0ed06db 100644
--- a/src/imap_search.c
+++ b/src/imap_search.c
@@ -27,9 +27,120 @@
#include "inode.h"
#include <sys/stat.h>
#include <errno.h>
+#include "magic.h"
extern ext2_filsys current_fs;
+struct privat {
+ int count;
+ int error;
+ unsigned char* buf;
+ char flag;
+};
+
+
+//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 )
+{
+ char *charbuf = NULL;
+ ((struct privat*)priv)->buf;
+ __u32 nbytes;
+ errcode_t retval;
+ int blocksize = fs->blocksize;
+
+ if ((blockcnt >= 12) || ((struct privat*)priv)->count >=12)
+ return BLOCK_ABORT;
+ charbuf = ((struct privat*)priv)->buf + (blocksize * blockcnt);
+
+ if (((struct privat*)priv)->flag){
+ int allocated = ext2fs_test_block_bitmap ( fs->block_map, *blocknr );
+ if ( allocated ){
+ ((struct privat*)priv)->error = BLOCK_ABORT | BLOCK_ERROR ;
+ return (BLOCK_ABORT | BLOCK_ERROR);
+ }
+ }
+
+ retval = io_channel_read_blk ( fs->io, *blocknr, 1, charbuf );
+ ((struct privat*)priv)->count = blockcnt;
+ if (retval){
+ ((struct privat*)priv)->error = BLOCK_ERROR ;
+ return (BLOCK_ERROR);
+ }
+return retval;
+}
+
+
+static char* get_pathname(blk_t inode_nr, char* i_pathname, char *magic_buf, unsigned char* buf){
+ struct found_data_t *help_data = NULL;
+ int str_len;
+ __u32 name_len;
+ char *c;
+ int def_len = 22;
+ char name_str[22];
+ __u32 scan = 0;
+
+ help_data = malloc(sizeof(struct found_data_t));
+ if (!help_data) return NULL;
+ memset (help_data,0, sizeof(struct found_data_t));
+
+ if ( ident_file(help_data,&scan,magic_buf,buf)){
+ help_data->type = scan;
+ str_len = strlen(magic_buf) + 1;
+ c = strpbrk(magic_buf,";:, ");
+ if (c){
+ *c = 0;
+ name_len = c - magic_buf + def_len;
+ }
+ else
+ name_len = str_len + def_len;
+
+ help_data->scan_result = malloc(str_len);
+ help_data->name = malloc(name_len);
+ if((!help_data->name) || (!help_data->scan_result)){
+ free_file_data( help_data );
+ fprintf(stderr,"ERROR: allocate memory\n");
+ }
+ else{
+ strcpy(help_data->scan_result,magic_buf);
+ strncpy(help_data->name, magic_buf , name_len - def_len+1);
+ sprintf(name_str,"/I_%010lu",inode_nr);
+ strcat(help_data->name,name_str);
+ get_file_property(help_data);
+ }
+ i_pathname = malloc(name_len);
+ if (i_pathname)
+ strncpy (i_pathname,help_data->name,name_len);
+ }
+ free_file_data(help_data);
+return i_pathname;
+}
+
+
+static magic_t cookie = 0;
+
+
+char* identify_filename(char* i_pathname, unsigned char *tmp_buf, struct ext2_inode* inode, blk_t inode_nr){
+ struct privat priv ;
+ char magic_buf[100];
+ int retval= 0;
+
+ priv.count = priv.error = priv.flag = 0;
+ priv.buf = tmp_buf;
+ memset(magic_buf,0,100);
+ if ((inode->i_mode & LINUX_S_IFMT) == LINUX_S_IFREG){
+ memset(tmp_buf,0,12 * current_fs->blocksize);
+ // iterate first 12 Data Blocks
+ retval = local_block_iterate3 ( current_fs, *inode, BLOCK_FLAG_DATA_ONLY, NULL, first_blocks, &priv );
+ if (priv.count <12){
+ strncpy(magic_buf, magic_buffer(cookie , tmp_buf,
+ ((inode->i_size < 12 * current_fs->blocksize) ? inode->i_size : (12 * current_fs->blocksize))), 60);
+ i_pathname = get_pathname(inode_nr, i_pathname, magic_buf, tmp_buf);
+ }
+ }
+ return i_pathname;
+}
+
// search inode by use imap (step1: flag 1 = only directory ; step2: flag 0 = only file)
static void search_imap_inode(char* des_dir, __u32 t_after, __u32 t_before, int flag)
@@ -41,7 +152,9 @@ struct ring_buf* i_list = NULL;
r_item* item = NULL;
int zero_flag, retval, load, x ,i ;
char *pathname = NULL;
+char *i_pathname = NULL;
char *buf= NULL;
+unsigned char *tmp_buf = NULL;
__u32 blocksize, inodesize, inode_max, inode_per_group, block_count;
__u16 inode_per_block , inode_block_group, group;
blk_t block_nr;
@@ -55,6 +168,16 @@ inodesize = current_fs->super->s_inode_size;
inode_max = current_fs->super->s_inodes_count;
inode_per_group = current_fs->super->s_inodes_per_group;
buf = malloc(blocksize);
+if (! (flag & 0x01) ){
+ tmp_buf = malloc (12 * blocksize);
+ if (!tmp_buf)
+ goto errout;
+ cookie = magic_open(MAGIC_MIME | MAGIC_NO_CHECK_COMPRESS | MAGIC_NO_CHECK_ELF | MAGIC_CONTINUE);
+ if ((! cookie) || magic_load(cookie, NULL)){
+ fprintf(stderr,"ERROR: can't find libmagic\n");
+ goto errout;
+ }
+}
inode_per_block = blocksize / inodesize;
inode_block_group = inode_per_group / inode_per_block;
@@ -115,7 +238,7 @@ for (group = 0 ; group < current_fs->group_desc_count ; group++){
}
}
// 1. magical step
- if (LINUX_S_ISDIR(mode) && ( flag & 0x01) ){
+ if (LINUX_S_ISDIR(mode) && ( flag & 0x01) && (pathname)){
sprintf(pathname,"<%lu>",inode_nr);
@@ -132,7 +255,7 @@ for (group = 0 ; group < current_fs->group_desc_count ; group++){
else{ //search for all
dir = get_dir3(NULL,0, inode_nr , "MAGIC-1",pathname, t_after,t_before, DELETED_OPT);
if (dir) {
- lookup_local(des_dir, dir,t_after,t_before, DELETED_OPT | RECOV_ALL | LOST_DIR_SEARCH );
+ lookup_local(des_dir,dir,t_after,t_before,DELETED_OPT|RECOV_ALL|LOST_DIR_SEARCH);
clear_dir_list(dir);
}
}
@@ -148,8 +271,15 @@ for (group = 0 ; group < current_fs->group_desc_count ; group++){
if (item) {
if (! LINUX_S_ISDIR(item->inode->i_mode) ) {
+ i_pathname = identify_filename(i_pathname, tmp_buf,
+ (struct ext2_inode*)item->inode, inode_nr);
sprintf(pathname,"<%lu>",inode_nr);
- recover_file(des_dir,"MAGIC-2", pathname, (struct ext2_inode*)item->inode, inode_nr, 0);
+ recover_file(des_dir,"MAGIC-2", ((i_pathname)?i_pathname : pathname),
+ (struct ext2_inode*)item->inode, inode_nr, 0);
+ if(i_pathname){
+ free(i_pathname);
+ i_pathname = NULL;
+ }
}
}
if (i_list) ring_del(i_list);
@@ -159,6 +289,7 @@ for (group = 0 ; group < current_fs->group_desc_count ; group++){
}
}
}
+errout:
if (pathname)
free(pathname);
@@ -166,6 +297,15 @@ for (group = 0 ; group < current_fs->group_desc_count ; group++){
free(buf);
buf = NULL;
}
+
+ if (tmp_buf){
+ free(tmp_buf);
+ tmp_buf = NULL;
+ }
+ if (cookie){
+ magic_close(cookie);
+ cookie = 0;
+ }
return;
}
@@ -196,7 +336,7 @@ if (recovername && dirname){
}
else{
if(check_dir(dirname)){
- fprintf(stderr,"Unknown error at target directory by file: %s\ntrying to continue normal\n", dirname);
+ fprintf(stderr,"Unknown error at target directory by file: %s\ntrying to continue normal\n", dirname);
}else{
retval = rename(recovername, dirname);
rename_hardlink_path(recovername, dirname);
@@ -217,7 +357,7 @@ return retval;
//2 step search for journalinode, will find some lost directory and files
void imap_search(char* des_dir, __u32 t_after, __u32 t_before , int disaster ){
printf("MAGIC-1 : start lost directory search\n");
- search_imap_inode(des_dir, t_after, t_before, 1 | disaster ); //search for lost fragments of directorys
+// search_imap_inode(des_dir, t_after, t_before, 1 | disaster ); //search for lost fragments of directorys
printf("MAGIC-2 : start lost file search\n");
search_imap_inode(des_dir, t_after, t_before, 0 | disaster ); //search for lost files
return;
diff --git a/src/magic_block_scan.c b/src/magic_block_scan.c
index 3eef1ac..1efacf3 100644
--- a/src/magic_block_scan.c
+++ b/src/magic_block_scan.c
@@ -48,7 +48,7 @@ static __u32 get_block_len(unsigned char *buf){
-static struct found_data_t* free_file_data(struct found_data_t* old){
+struct found_data_t* free_file_data(struct found_data_t* old){
int tmp;
if(old->inode) free(old->inode);
diff --git a/src/util.h b/src/util.h
index d843f57..7dc4033 100644
--- a/src/util.h
+++ b/src/util.h
@@ -210,6 +210,7 @@ void get_file_property(struct found_data_t*); //set the file properties and the
//public functions magic_block_scan.c
+struct found_data_t* free_file_data(struct found_data_t*); //clear + free found_data
int magic_block_scan3(char*, __u32);//main of the magic_scan_engine for ext3
//functions in develop