summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobi <robi>2012-02-19 17:38:07 +0000
committerrobi <robi>2012-02-19 17:38:07 +0000
commitbf74ad294f506a72d5ae671480ad7b88f3be07df (patch)
tree385c3ba03bf1ab77ff97df0f8c4f664c9fe90593
parent2698ce16c465c39085bee3b20b65c962fdb78530 (diff)
some small bugs and many gcc warnings
-rw-r--r--src/block.c8
-rw-r--r--src/block.h2
-rw-r--r--src/ext4magic.c41
-rw-r--r--src/extent_db.c5
-rw-r--r--src/extent_db.h2
-rw-r--r--src/file_type.c147
-rw-r--r--src/hard_link_stack.c5
-rw-r--r--src/hard_link_stack.h2
-rw-r--r--src/imap_search.c22
-rw-r--r--src/inode.c76
-rw-r--r--src/inode.h10
-rw-r--r--src/jfs_compat.h14
-rw-r--r--src/journal.c140
-rw-r--r--src/journal.h6
-rw-r--r--src/lookup_local.c5
-rw-r--r--src/magic_block_scan.c81
-rw-r--r--src/recover.c16
-rw-r--r--src/util.c26
-rw-r--r--src/util.h11
19 files changed, 322 insertions, 297 deletions
diff --git a/src/block.c b/src/block.c
index 29d8afb..84fc1bb 100644
--- a/src/block.c
+++ b/src/block.c
@@ -115,7 +115,7 @@ int read_block ( ext2_filsys fs, blk_t *blocknr, void *buf )
{
errcode_t retval = io_channel_read_blk ( fs->io, *blocknr, 1, buf );
if (retval)
- fprintf(stderr,"Error %d while read block\n", retval);
+ fprintf(stderr,"Error %d while read block\n", (int)retval);
return retval;
}
#ifdef EXT2_FLAG_64BITS
@@ -123,7 +123,7 @@ 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);
+ fprintf(stderr,"Error %d while read block\n", (int)retval);
return retval;
}
#endif
@@ -136,7 +136,7 @@ errcode_t local_ext2fs_extent_open(ext2_filsys fs, struct ext2_inode inode,
struct ext2_extent_handle *handle;
struct ext3_extent_header *eh;
- int i;
+ int i;
errcode_t retval;
retval = ext2fs_get_mem(sizeof(struct ext2_extent_handle), &handle);
if (retval)
@@ -194,7 +194,7 @@ errcode_t local_ext2fs_extent_open(ext2_filsys fs, struct ext2_inode inode,
static int mark_extent_block(ext2_filsys fs, char *extent_block ){
struct ext3_extent_header *eh;
struct ext3_extent_idx *idx;
- int i, ret;
+ int i, ret = 0 ;
#ifdef EXT2_FLAG_64BITS
blk64_t index_bl;
#else
diff --git a/src/block.h b/src/block.h
index 6436cb6..23a1785 100644
--- a/src/block.h
+++ b/src/block.h
@@ -24,6 +24,8 @@ 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
+errcode_t local_ext2fs_extent_open(ext2_filsys, struct ext2_inode, ext2_extent_handle_t*);
+void local_ext2fs_extent_free(ext2_extent_handle_t);
#endif //BLOCK_H
diff --git a/src/ext4magic.c b/src/ext4magic.c
index 907c6d8..b7c0dda 100644
--- a/src/ext4magic.c
+++ b/src/ext4magic.c
@@ -48,6 +48,7 @@ extern char *optarg;
/* ext3/4 libraries */
#include <ext2fs/ext2fs.h>
+#include <e2p/e2p.h>
//local header files
#include "util.h"
@@ -55,6 +56,7 @@ extern char *optarg;
#include "journal.h"
#include "inode.h"
#include "hard_link_stack.h"
+#include "block.h"
@@ -117,13 +119,13 @@ static void print_bg_opts(struct ext2_group_desc *gdp, int mask,
//print superblock
void show_super_stats(int header_only)
{
+#ifdef EXT2_FLAG_64BITS
const char *units ="block";
+#endif
dgrp_t i;
FILE *out;
struct ext2_group_desc *gdp;
- int c;
int numdirs = 0, first, gdt_csum;
-
out=stdout;
list_super2(current_fs->super, out);
@@ -340,7 +342,6 @@ ext4magic -m [-j <journal_file>] [-d <target_dir>] <filesystem> \n\
ext4magic [-S|-J|-H|-V|-T] [-x] [-j <journal_file>] [-B n|-I n|-f <file_name>|-i <input_list>] [-t n|[[-a n][-b n]]] [-d <target_dir>] [-R|-r|-L|-l] [-Q] <filesystem>";
int c;
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES;
-int exit_status = 0 ;
int recovermodus = 0 ;
int disaster = 0;
int recoverquality = DELETED_OPT; // default use also delete dir entry
@@ -516,7 +517,7 @@ while ((c = getopt (argc, argv, "TJRMLlmrSxi:t:j:f:Vd:B:b:a:I:H")) != EOF) {
if ( inode_nr < 1 )
{
fprintf(stderr,"Error: %s -I: inodeNR \n", progname);
- fprintf(stderr,"%lu is out of range\n", inode_nr);
+ fprintf(stderr,"%lu is out of range\n", (long unsigned int)inode_nr);
exitval = EXIT_FAILURE ;
goto errout;
}
@@ -535,7 +536,7 @@ while ((c = getopt (argc, argv, "TJRMLlmrSxi:t:j:f:Vd:B:b:a:I:H")) != EOF) {
if ( block_nr < 1 )
{
fprintf(stderr,"Error: %s -B: blockNR \n", progname);
- fprintf(stderr,"%lu is out of range\n", block_nr);
+ fprintf(stderr,"%lu is out of range\n", (long unsigned int)block_nr);
exitval = EXIT_FAILURE ;
goto errout;
}
@@ -555,7 +556,7 @@ while ((c = getopt (argc, argv, "TJRMLlmrSxi:t:j:f:Vd:B:b:a:I:H")) != EOF) {
if ( transaction_nr < 1 )
{
fprintf(stderr,"Error: %s -t: transactionNR \n", progname);
- fprintf(stderr,"%lu is out of range\n", transaction_nr);
+ fprintf(stderr,"%lu is out of range\n", (long unsigned int)transaction_nr);
exitval = EXIT_FAILURE ;
goto errout;
}
@@ -663,7 +664,7 @@ while ((c = getopt (argc, argv, "TJRMLlmrSxi:t:j:f:Vd:B:b:a:I:H")) != EOF) {
if ( t_before < 1 )
{
fprintf(stderr,"Error: %s -b: time \n", progname);
- fprintf(stderr,"%lu is out of range\n", inode_nr);
+ fprintf(stderr,"%lu is out of range\n", (long unsigned int)inode_nr);
exitval = EXIT_FAILURE ;
goto errout;
}
@@ -765,7 +766,7 @@ if (mode & INPUT_TIME){
//check for the recoverdir
-if ((mode & RECOVER_INODE) && (recovermodus & REC_DIR_NEEDED) || mode & RECOVER_LIST || magicscan) {
+if (((mode & RECOVER_INODE) && (recovermodus & REC_DIR_NEEDED)) || mode & RECOVER_LIST || magicscan) {
struct stat st_buf;
dev_t file_rdev=0;
@@ -885,7 +886,10 @@ if ((recovermodus & (LIST_ALL | LIST_STATUS)) && format)
}
inode_buf = malloc(EXT2_INODE_SIZE(current_fs->super));
- if (intern_read_inode_full(inode_nr, inode_buf,EXT2_INODE_SIZE(current_fs->super))) return;
+ if (intern_read_inode_full(inode_nr, inode_buf,EXT2_INODE_SIZE(current_fs->super))){
+ fprintf(stderr,"Fatal Error: can not read InodeNr. %lu \n", (long unsigned int)inode_nr);
+ return EXIT_FAILURE;
+ }
allocated = ext2fs_test_inode_bitmap ( current_fs->inode_map, inode_nr );
@@ -904,7 +908,8 @@ if ((recovermodus & (LIST_ALL | LIST_STATUS)) && format)
block_buf = malloc(EXT2_BLOCK_SIZE(current_fs->super ));
if(!read_block ( current_fs , &block_nr , block_buf )){
allocated = ext2fs_test_block_bitmap ( current_fs->block_map, block_nr );
- fprintf(stdout,"Dump Filesystemblock %10lu Status : %s\n",block_nr,(allocated) ? "Block is Allocated" : "Block is Unallocated");
+ fprintf(stdout,"Dump Filesystemblock %10lu Status : %s\n",(long unsigned int)block_nr,
+ (allocated) ? "Block is Allocated" : "Block is Unallocated");
blockhex ( stdout , block_buf , format , EXT2_BLOCK_SIZE(current_fs->super ));
}
free(block_buf);
@@ -950,7 +955,7 @@ if (mode & READ_JOURNAL){
inode_nr = local_namei(NULL,pathname,t_after,t_before,DELETED_OPT);
}
if (inode_nr) {
- printf("Inode found \"%s\" %lu \n", pathname, inode_nr);
+ printf("Inode found \"%s\" %lu \n", pathname, (long unsigned int)inode_nr);
}
else{
fprintf(stderr,"Error: Inode not found for \"%s\"\n",pathname);
@@ -961,7 +966,7 @@ if (mode & READ_JOURNAL){
}
else{
if (mode & COMMAND_INODE){
- pathname = malloc(20);
+ if (!pathname) pathname = malloc(20);
if (!pathname) {
fprintf(stderr,"ERROR: can not allocate memory\n");
goto journalout;
@@ -969,7 +974,7 @@ if (mode & READ_JOURNAL){
if (inode_nr == EXT2_ROOT_INO)
*pathname = 0;
else
- sprintf(pathname,"<%lu>",inode_nr);
+ sprintf(pathname,"<%lu>",(long unsigned int)inode_nr);
}
}
@@ -1022,11 +1027,12 @@ if (mode & READ_JOURNAL){
journal_block = get_journal_blocknr(block_nr, transaction_nr);
if ( journal_block ){
printf("dump Journalblock %lu : a copy of Filesystemblock %lu : Transaction %lu\n",
- journal_block, block_nr, transaction_nr);
+ (long unsigned int)journal_block, (long unsigned int)block_nr, (long unsigned int)transaction_nr);
dump_journal_block( journal_block, format );
}
else
- fprintf(stderr,"Error: Filesystemblock %lu not found in Journaltransaction %lu\n",block_nr, transaction_nr);
+ fprintf(stderr,"Error: Filesystemblock %lu not found in Journaltransaction %lu\n",
+ (long unsigned int)block_nr, (long unsigned int)transaction_nr);
}
@@ -1054,7 +1060,7 @@ if ((mode & COMMAND_INODE) && (mode & RECOVER_INODE))
r_item *item = NULL;
if (ext2fs_test_inode_bitmap ( current_fs->inode_map, inode_nr )) {
- fprintf(stdout,"Inode %lu is allocated\n",inode_nr);
+ fprintf(stdout,"Inode %lu is allocated\n",(long unsigned int)inode_nr);
}
i_list = get_j_inode_list(current_fs->super, inode_nr);
@@ -1096,7 +1102,8 @@ if ((mode & COMMAND_INODE) && (mode & RECOVER_INODE))
clear_dir_list(dir);
}
else
- printf("Inode %lu is a directory but not found after %lu and before %lu\n",inode_nr,t_after,t_before);
+ printf("Inode %lu is a directory but not found after %lu and before %lu\n",
+ (long unsigned int)inode_nr, (long unsigned int)t_after, (long unsigned int)t_before);
}
else {
if (recovermodus & (RECOV_ALL | RECOV_DEL))
diff --git a/src/extent_db.c b/src/extent_db.c
index 6d1f566..3ef5cb3 100644
--- a/src/extent_db.c
+++ b/src/extent_db.c
@@ -30,6 +30,9 @@
extern ext2_filsys current_fs;
+static int mark_extent_len(struct extent_db_t*, blk_t, void*);
+
+
struct extent_area* new_extent_area(){
struct extent_area *ea;
ea = malloc(sizeof(struct extent_area));
@@ -192,7 +195,7 @@ static int mark_extent_len(struct extent_db_t* db, blk_t blk, void * buf){
if (ext2fs_le16_to_cpu(header->eh_depth)){
idx = (struct ext3_extent_idx*) (header + entry);
if(io_channel_read_blk ( current_fs->io,ext2fs_le32_to_cpu(idx->ei_leaf), 1, buf_tmp )){
- fprintf(stderr,"Error read block %lu\n",ext2fs_le32_to_cpu(idx->ei_leaf));
+ fprintf(stderr,"Error read block %lu\n", (long unsigned int)ext2fs_le32_to_cpu(idx->ei_leaf));
ret = 2;
}
else{
diff --git a/src/extent_db.h b/src/extent_db.h
index a9d2c58..3e0d836 100644
--- a/src/extent_db.h
+++ b/src/extent_db.h
@@ -59,8 +59,6 @@ struct extent_db_t {
struct extent_area* new_extent_area();
-//int check_extent_len(struct ext3_extent_header*, struct extent_area* , blk_t );
-static int mark_extent_len(struct extent_db_t*, blk_t, void*);
struct extent_db_t* extent_db_init(ext2fs_block_bitmap);
int extent_db_add (struct extent_db_t* db, struct extent_area*, int);
int extent_db_del(struct extent_db_t* ,blk_t);
diff --git a/src/file_type.c b/src/file_type.c
index 521476e..a695ca0 100644
--- a/src/file_type.c
+++ b/src/file_type.c
@@ -42,7 +42,7 @@
extern ext2_filsys current_fs ;
// index of the files corresponding magic result strings
-int ident_file(struct found_data_t *new, __u32 *scan, char *magic_buf, char *buf){
+int ident_file(struct found_data_t *new, __u32 *scan, char *magic_buf, void *buf){
//Please do not modify the following lines.
//they are used for indices to the filestypes
@@ -789,16 +789,16 @@ static int follow_bz2lib(unsigned char *buf, __u16 blockcount, __u32 *offset, __
//---------------------- Decompress
p_offset = *offset;
total = priv->b_strm.total_in_lo32;
- priv->b_strm.next_in = buf + p_offset ;
+ priv->b_strm.next_in = (char*)buf + p_offset ;
priv->b_strm.avail_in = end - p_offset;
- priv->b_strm.next_out = out;
+ priv->b_strm.next_out = (char*)out;
priv->b_strm.avail_out = OUTLEN;
while ((z_ret >=0) && (z_ret != BZ_STREAM_END) && (priv->b_strm.avail_in)){
z_ret = BZ2_bzDecompress ( &(priv->b_strm) );
p_offset = priv->b_strm.total_in_lo32 - total + *offset ;
if ((z_ret == BZ_OUTBUFF_FULL) || (!priv->b_strm.avail_out)){
- priv->b_strm.next_out = out;
+ priv->b_strm.next_out = (char*)out;
priv->b_strm.avail_out = OUTLEN;
*last_match = p_offset ;
z_ret = 0;
@@ -826,8 +826,7 @@ int file_gzip(unsigned char *buf, int *size, __u32 scan , int flag, struct found
int z_flags, b_count, ret = 0;
__u32 offset;
__u32 last_match = 0;
- struct priv_zlib_t *priv = NULL;
-
+
switch (flag){
case 0 :
@@ -899,7 +898,7 @@ int file_gzip(unsigned char *buf, int *size, __u32 scan , int flag, struct found
//bzip2
int file_bzip2(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
- int z_flags, b_count, ret = 0;
+ int b_count, ret = 0;
__u32 offset;
__u32 last_match = 0;
@@ -958,7 +957,7 @@ int file_bzip2(unsigned char *buf, int *size, __u32 scan , int flag, struct foun
int file_zip(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
int ret = 0;
int j,i, b_count;
- unsigned char token[5];
+ char token[5];
__u32 last_match = 0;
struct zip_priv_t *z_priv = NULL;
__u32 offset;
@@ -1047,7 +1046,7 @@ int file_lzw(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
return (scan & (M_IS_META | M_CLASS_1)) ? 0 :1 ;
break;
case 2 :
- if ((buf[2] & 0x60) || ((buf[2] & 0xF)<12) || ((buf[2] & 0x1F)>16))
+ if ((buf[2] & 0x60) || ((buf[2] & 0x1F)<12) || ((buf[2] & 0x1F)>16))
f_data->first = 0;
break;
}
@@ -1065,7 +1064,6 @@ int file_rpm(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
int i, z_flags, b_count, ret = 0;
__u32 offset;
__u32 last_match = 0;
- struct priv_zlib_t *priv = NULL;
__u32 h_count,h_size;
__u32 p_size = 0;
@@ -1192,7 +1190,7 @@ int file_rpm(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
int file_ttf(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
__u32 table_id[9] = {0x70616d63,0x66796c67,0x64616568,0x61656868,0x78746d68,0x61636f6c,0x7078616d,0x656d616e,0x74736f70};
int i,j,id_count,ret = 0;
- __u16 tables, s_range, shift;
+ __u16 tables ; //s_range, shift;
__u32 *p, id, tmp;
unsigned char *c;
@@ -1260,7 +1258,7 @@ int file_iso9660(unsigned char *buf, int *size, __u32 scan , int flag , struct f
__u16 *p_16;
int ssize;
int ret = 0;
- unsigned char cd_str[] = "CD001";
+ char cd_str[] = "CD001";
switch (flag){
case 0 :
@@ -1288,7 +1286,7 @@ int file_iso9660(unsigned char *buf, int *size, __u32 scan , int flag , struct f
if (current_fs->blocksize > 2048){
p_32 = (__u32*)(buf + 0x8050);
p_16 = (__u16*)(buf + 0x8080);
- if ((!strncmp((buf+0x8001),cd_str,5)) && (ext2fs_le32_to_cpu(*(p_32 +1)) == ext2fs_be32_to_cpu(*p_32))){
+ if ((!strncmp(((char*)buf+0x8001),cd_str,5)) && (ext2fs_le32_to_cpu(*(p_32 +1)) == ext2fs_be32_to_cpu(*p_32))){
lsize = (__u64)(ext2fs_le32_to_cpu(*p_32)) * ext2fs_le16_to_cpu(*p_16);
f_data->size = lsize & 0xFFFFFFFF;
f_data->h_size = lsize >> 32;
@@ -1539,8 +1537,8 @@ static int follow_cpio(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
char c_namesize[8];
char c_check[8];
};
- unsigned char footer[]="TRAILER!!!";
- int i, j,ret = 1;
+ char footer[]="TRAILER!!!";
+ int i, ret = 1; //j;
__u64 f_offset = (__u64) *offset;
__u32 n_len ;
__u64 f_len ;
@@ -1555,7 +1553,7 @@ static int follow_cpio(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
f_len = 0;
old_cpio = (struct header_old_cpio*) (buf+f_offset) ;
if ((old_cpio->c_magic == 0xc771)||(old_cpio->c_magic == 0x71c7)){
- if (strstr(buf+f_offset+sizeof(struct header_old_cpio),footer))
+ if (strstr((char*)buf+f_offset+sizeof(struct header_old_cpio),footer))
ret=2;
if (old_cpio->c_magic == 0xc771)
@@ -1574,7 +1572,7 @@ static int follow_cpio(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
else{
if( (buf[f_offset] == 0x30)&&(buf[f_offset+1] == 0x37)&&(buf[f_offset+2] == 0x30)&&(buf[f_offset+3] == 0x37)&&(buf[f_offset+4] == 0x30)){
if (buf[f_offset+5] == 0x37){
- if (strstr(buf+f_offset+sizeof(struct cpio_odc_header),footer))
+ if (strstr((char*)buf+f_offset+sizeof(struct cpio_odc_header),footer))
ret=2;
odc_header = (struct cpio_odc_header*) old_cpio;
o_str = (__u8*) &(odc_header->c_namesize);
@@ -1596,7 +1594,7 @@ static int follow_cpio(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
}
}
else {
- if (strstr(buf+f_offset+sizeof(struct cpio_newc_header),footer))
+ if (strstr((char*)buf+f_offset+sizeof(struct cpio_newc_header),footer))
ret=2;
newc_header = (struct cpio_newc_header*) old_cpio;
memcpy(help,newc_header->c_namesize,8);
@@ -1628,7 +1626,7 @@ int file_cpio(unsigned char *buf, int *size, __u32 scan , int flag, struct found
int ret = 0;
__u32 offset;
__u32 last_match = 0;
- unsigned char token[]="TRAILER!!!";
+ char token[]="TRAILER!!!";
switch (flag){
case 0 :
@@ -1676,8 +1674,8 @@ int file_cpio(unsigned char *buf, int *size, __u32 scan , int flag, struct found
return ret;
}
-
-static int a2u(unsigned char *buf, __u32 *value){
+//function currently not used
+/*static int a2u(unsigned char *buf, __u32 *value){
int count=0;
__u32 tmp=0;
@@ -1699,7 +1697,7 @@ static int a2u(unsigned char *buf, __u32 *value){
return count;
}
return 0;
-}
+}*/
@@ -2007,7 +2005,7 @@ int file_pdf(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
__u32 last_match = 0;
int b_count;
struct priv_pdf_t *priv = NULL;
- unsigned char token[6];
+ char token[6];
sprintf(token,"%c%c%c%c%c",0x25,0x45,0x4f,0x46,0x0a);
switch (flag){
@@ -2021,7 +2019,7 @@ int file_pdf(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
else{
j = strlen(token) -2;
i = (*size) -2;
- if(buf[i] != (char)0x46)
+ if(buf[i] != 0x46)
i--;
while ((i >= 0) && (j >= 0) && (buf[i] == token[j])){
@@ -2108,7 +2106,7 @@ __u16 save_flag = flag;
return 0;
break;
case 0x800:
- if (((i-f_offset)==8) && (!(strncmp("Subject:", buf+f_offset, 8)))){
+ if (((i-f_offset)==8) && (!(strncmp("Subject:", (char*)buf+f_offset, 8)))){
flag = 0x200;
exception = 2;
}
@@ -2172,7 +2170,7 @@ static int read_smtp_codestr(unsigned char *buf,__u32 f_offset, int len){
}
token[i] = 0;
type++;
- if (!strncmp(buf + 27 + f_offset,token,strlen(token))){
+ if (!strncmp((char*)buf + 27 + f_offset,token,strlen(token))){
flag = 1;
break;
}
@@ -2186,7 +2184,7 @@ static int read_smtp_codestr(unsigned char *buf,__u32 f_offset, int len){
static int smtp_decode_content_type(unsigned char * buf, __u32 offset, int len, struct priv_smtp_t *priv){
int i,j,slot;
- if (!strncmp("Content-Type:",buf+offset,12)) {
+ if (!strncmp("Content-Type:",(char*)buf+offset,12)) {
i = 13;
while ((i<(len-6)) && (buf[offset +i] != ';')) i++;
while ((i<(len-6)) && (!((buf[offset +i] == 'd') && // dary=
@@ -2229,7 +2227,7 @@ static int follow_smtp(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
__u32 end = (blockcount * current_fs->blocksize)-20;
int len = 0;
int tmp_slot,slot = 0;
- __u16 tmp_flag,crc,crc_d ;
+ __u16 tmp_flag = 0; //crc,crc_d ;
if (end == f_offset)
end++;
@@ -2261,16 +2259,16 @@ static int follow_smtp(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
priv->flag = (priv->flag & ~0x0f) | 1;
break;
default :
- if (!strncmp("From: ", buf+f_offset, 6)
- || !strncmp("From ", buf+f_offset, 5)
- || !strncmp("To: ", buf+f_offset, 4)
- || !strncmp("Reply-", buf+f_offset, 6)
- || !strncmp("Cc: ", buf+f_offset, 4)
- || !strncmp("Bcc: ", buf+f_offset, 5)
- || !strncmp("Content-", buf+f_offset, 8)
- || !strncmp("MIME-Version: ", buf+f_offset, 14)){
+ if (!strncmp("From: ", (char*)buf+f_offset, 6)
+ || !strncmp("From ", (char*)buf+f_offset, 5)
+ || !strncmp("To: ", (char*)buf+f_offset, 4)
+ || !strncmp("Reply-", (char*)buf+f_offset, 6)
+ || !strncmp("Cc: ", (char*)buf+f_offset, 4)
+ || !strncmp("Bcc: ", (char*)buf+f_offset, 5)
+ || !strncmp("Content-", (char*)buf+f_offset, 8)
+ || !strncmp("MIME-Version: ", (char*)buf+f_offset, 14)){
if(buf[f_offset + 8] == 'T') {
- if (!strncmp("Content-Transfer-Encoding:",buf+f_offset,26)){
+ if (!strncmp("Content-Transfer-Encoding:",(char*)buf+f_offset,26)){
priv->flag = ((priv->flag & 0xff)|(read_smtp_codestr(buf,f_offset,len)<<8));
//FIXME if (priv->flag & 0xff00
}
@@ -2311,12 +2309,12 @@ static int follow_smtp(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
return 0;
}
- if (!strncmp("--", buf+f_offset, 2)){
+ if (!strncmp("--", (char*)buf+f_offset, 2)){
tmp_flag = (priv->flag & ~0x0f) | 3;
priv->flag = (priv->flag & ~0x0f) | 2;
break;
}
- if (!strncmp("From ", buf+f_offset, 5)){
+ if (!strncmp("From ", (char*)buf+f_offset, 5)){
for(i=0;i<MAX_SMTP_CONTENT;i++)
if (priv->slot[i].c_flag)
break;
@@ -2353,9 +2351,9 @@ static int follow_smtp(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
f_offset++;
break;
default:
- if ((len > 30) && (!strncmp("This ", buf+f_offset, 5))){
+ if ((len > 30) && (!strncmp("This ", (char*)buf+f_offset, 5))){
for(i=6;((i<len) && (!(buf[f_offset +i] == 'M')));i++);
- if ((i<len) && (!strncmp("MIME format", buf+f_offset+i, 11))){
+ if ((i<len) && (!strncmp("MIME format", (char*)buf+f_offset+i, 11))){
*last_match = f_offset;
priv->flag = (priv->flag & ~0x0f) | 1;
}
@@ -2461,7 +2459,7 @@ static int follow_smtp(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
break;
default:
if(buf[f_offset + 8] == 'T'){
- if(!strncmp("Content-Transfer-Encoding:",buf+f_offset,26)){
+ if(!strncmp("Content-Transfer-Encoding:",(char*)buf+f_offset,26)){
priv->slot[slot].c_flag = 3;
priv->slot[slot].c_code = (read_smtp_codestr(buf,f_offset,len)<<8);
}
@@ -2503,7 +2501,7 @@ static int follow_smtp(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
if (!priv->len)
priv->len = len;
- if ((len > 7)&&(!strncmp("--", buf+f_offset, 2))){
+ if ((len > 7)&&(!strncmp("--", (char*)buf+f_offset, 2))){
tmp_flag = priv->flag;
priv->flag = (priv->flag & ~0x0f) | 2;
break;
@@ -2577,9 +2575,9 @@ int file_smtp(unsigned char *buf, int *size, __u32 scan , int flag, struct found
//ps switch only to pdf or txt
int file_ps(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
- unsigned char *c;
int ret = 1;
- unsigned char token[9] = "PS-Adobe";
+// unsigned char *c;
+// unsigned char token[9] = "PS-Adobe";
switch (flag){
case 0 :
@@ -2685,7 +2683,7 @@ static int follow_tar(unsigned char *buf, __u16 blockcount, __u32 *offset, __u32
//tar
int file_tar(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
- int i,ret = 0;
+ int ret = 0;
int b_count;
__u32 offset;
__u32 last_match = 0;
@@ -2699,7 +2697,8 @@ int file_tar(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
else
*size = ((*size) + 1023) & ~1023 ;
- if (((f_data->inode->i_flags & EXT4_EXTENTS_FL) &&(f_data->inode->i_block[12])) || (f_data->size < f_data->inode->i_size)) //FIXME
+ if (((!(f_data->inode->i_flags & EXT4_EXTENTS_FL)) &&(f_data->inode->i_block[12])) || (f_data->size < f_data->inode->i_size)
+ || (f_data->scantype & DATA_READY)) //FIXME
ret = 1;
}
break;
@@ -2707,7 +2706,7 @@ int file_tar(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
if (scan & M_TAR)
ret = 1;
else
- ret = ((scan & M_IS_META | M_CLASS_1 )||(f_data->scantype & DATA_READY)) ? 0 :1 ;
+ ret = ((scan & (M_IS_META | M_CLASS_1))||(f_data->scantype & DATA_READY)) ? 0 :1 ;
break;
case 2 :
offset = 0;
@@ -3600,7 +3599,7 @@ int file_bmp(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
}
else{
wi = ((__u32)*(buf+18)) | ((__u32)*(buf+19))<<8 | ((__u32)*(buf+20))<<16 | ((__u32)*(buf+21))<<24 ;
- colors = colors = ((__u16)*(buf+28)) | ((__u16)*(buf+29))<<8 ;
+ colors = ((__u16)*(buf+28)) | ((__u16)*(buf+29))<<8 ;
switch (colors){
case 1:
wi = (((((wi+0x7) & ~0x7) / 8) + 1) & ~1);
@@ -3693,12 +3692,12 @@ int file_png(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
else{
// if((!(f_data->inode->i_flags & EXT4_EXTENTS_FL))){
if (*size > 8){
- if (strstr(buf + (*size) -8,"END"))
+ if (strstr((char*)buf + (*size) -8,"END"))
ret=1;
}
else{
if (*size >= 5){
- if (strtok(buf,"D" ))
+ if (strtok((char*)buf,"D" ))
ret=1;
}
else
@@ -3841,6 +3840,7 @@ static int follow_pcx(unsigned char *buf, __u16 blockcount, __u32 *offset, __u32
__u32 end = blockcount * current_fs->blocksize;
__u16 w,h,p;
struct pcx_priv_t *p_data = (struct pcx_priv_t*) priv;
+ w = h = p = 0;
while ( (ret == 1) && (f_offset < (end-1))){
for (p = ((flag) ? p_data->p:0) ; p < p_data->planes ; p++){
@@ -4250,7 +4250,6 @@ return ret;
//xcf
int file_xcf(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
int i,ret = 0;
- struct xcf_priv_t *priv;
__u32 offset;
__u32 last_match = 0;
__u32 b_count;
@@ -4399,7 +4398,7 @@ int file_tga(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
__u32 ssize = 0;
__u32 psize = 0;
int ret = 0;
- unsigned char token[]="-XFILE.";
+ char token[]="-XFILE.";
switch (flag){
case 0 :
@@ -4528,7 +4527,7 @@ int file_mkv(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
break;
case 2 :
p = buf;
- if (strncmp(p,header,4))
+ if (strncmp((char*)p,(char*)header,4))
break;
p +=4;
i = read_ebml(&result,(void*)p);
@@ -4537,7 +4536,7 @@ int file_mkv(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
offset = result + 4 + i;
p += (__u32) result + i;
- if (strncmp(p,segment,4))
+ if (strncmp((char*)p,(char*)segment,4))
break;
p +=4;
i = read_ebml(&result,(void*)p);
@@ -4799,7 +4798,7 @@ static int follow_flac(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
__u32 blocksize;
__u32 bits_per_sample;
__u32 channel;
- __u64 total_samples;
+// __u64 total_samples;
__u32 f_offset = *offset;
@@ -4820,7 +4819,7 @@ static int follow_flac(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
else{ //meta data
size = (buf[f_offset+1]<<16) + (buf[f_offset+2]<<8) + buf[f_offset+3] +4;
if(!(buf[f_offset] & 0x7f)){ //stream info
- blocksize = buf[f_offset+4]<<8 + buf[f_offset+5];
+ blocksize = (buf[f_offset+4]<<8) + buf[f_offset+5];
bits_per_sample = ((buf[f_offset+16] & 0x01) << 4) + ((buf[f_offset+17] & 0xf0) >> 4) +1 ;
channel = ((buf[f_offset+16] & 0x0e) >>1) +1;
// total_samples = (((__u64)(buf[f_offset+17] & 0x0f0))<<32)+(buf[f_offset+18] <<24)+(buf[f_offset+19] <<16)+
@@ -4989,7 +4988,7 @@ int file_flac(unsigned char *buf, int *size, __u32 scan , int flag, struct found
__u32 b_count;
int ret = 0;
-static const unsigned char token[4]= {0x66,0x4c,0x61,0x43};
+//static const unsigned char token[4]= {0x66,0x4c,0x61,0x43};
switch (flag){
case 0 :
@@ -5054,7 +5053,8 @@ static int follow_mpeg(unsigned char *buf, __u16 blockcount, __u32 *offset, __u3
int ret =1;
__u32 end;
__u32 frame_offset = *offset;
- __u32 tmp, i ;
+ __u32 tmp = 0;
+ __u32 i ;
int tolerance = 64; //for incorrect zero-byte padding
end = blockcount * current_fs->blocksize ;
@@ -5480,7 +5480,7 @@ int file_psd(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
//pnm
int file_pnm(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
int x,y,d,s ;
- unsigned char *c, *txt;
+ char *c, *txt;
__u32 ssize = 0;
int ret = 0;
@@ -5504,7 +5504,7 @@ case 1:
break;
case 2:
- c = buf;
+ c = (char*)buf;
if (*c =='P'){
c++;
txt = c + 1;
@@ -5536,7 +5536,7 @@ case 2:
break;
case 52 :
ssize = ((x*y)+7) / 8 ;
- ssize += (__u32)(txt -buf);
+ ssize += (__u32)(txt - (char*)buf);
break;
case 53 :
d = atoi(txt);
@@ -5549,7 +5549,7 @@ case 2:
ssize = 2;
if (ssize){
ssize *= (x*y);
- ssize += (__u32)(txt - buf);
+ ssize += (__u32)(txt - (char*)buf);
}
break;
case 54 :
@@ -5563,7 +5563,7 @@ case 2:
ssize = 6;
if (ssize){
ssize *= (x*y);
- ssize += (__u32)(txt - buf);
+ ssize += (__u32)(txt - (char*)buf);
}
break;
}
@@ -6164,7 +6164,7 @@ int file_CDF(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
__u32 FAT_blocks,extra_FAT_blocks;
__u32 last_match = 0;
__u16 shift;
- __u32 offset,last_match_blk = 0;
+ __u32 offset; //,last_match_blk = 0;
switch (flag){
case 0 :
@@ -6365,7 +6365,7 @@ int file_luks(unsigned char *buf, int *size, __u32 scan , int flag, struct found
case 1 :return (scan & (M_IS_META | M_CLASS_1 )) ? 0 :1 ;
break;
case 2 :
- if (!(strncmp(buf,luksmagic,6))){
+ if (!(strncmp((char*)buf,(char*)luksmagic,6))){
f_data->size = ext2fs_be32_to_cpu(phdr->payloadOffset) * 512;
f_data->scantype = DATA_MIN_LENGTH ;
ret = 1;
@@ -6626,7 +6626,7 @@ static const unsigned char avr_header[4]= {'2','B','I','T'};
//au (NeXT)
int file_au(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
-static const unsigned char au_header[4]= {'.','s','n','d'};
+//static const unsigned char au_header[4]= {'.','s','n','d'};
struct au_header_t
{
__u32 magic;
@@ -6999,7 +6999,7 @@ int file_fli(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
ret = 1;
}
else
- f_data->func == file_none;
+ f_data->func = file_none;
break;
}
return ret;
@@ -7055,8 +7055,7 @@ static int follow_ac3(unsigned char *buf, __u16 blockcount, __u32 *offset, __u32
//ac3
int file_ac3(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
- int i, ret = 0;
- unsigned char *ogg_h;
+ int ret = 0;
__u32 b_count;
__u32 offset = 0;
__u32 last_match = 0;
@@ -7160,7 +7159,7 @@ static int follow_ogg(unsigned char *buf, __u16 blockcount, __u32 *offset, __u32
//ogg
int file_ogg(unsigned char *buf, int *size, __u32 scan , int flag, struct found_data_t* f_data){
- int i, ret = 0;
+ int ret = 0;
unsigned char token[2][7]= {{0x80, 't', 'h', 'e', 'o', 'r', 'a'},
{0x01, 'v', 'i', 'd' ,'e', 'o', 0x00}};
unsigned char *ogg_h;
@@ -7224,7 +7223,7 @@ int file_ogg(unsigned char *buf, int *size, __u32 scan , int flag, struct found_
}
-static int follow_mp3(unsigned char *buf, __u16 blockcount, int *offset, int *flag, __u32 *last_match, unsigned char* head){
+static int follow_mp3(unsigned char *buf, __u16 blockcount, __u32 *offset, int *flag, __u32 *last_match, unsigned char* head){
#define MPEG_V25 0
#define MPEG_V2 2
#define MPEG_V1 3
@@ -7444,8 +7443,8 @@ switch (flag){
__u32 b_size = current_fs->blocksize;
unsigned char *v_buf = buf - b_size;
if (reverse < (b_size -1)){
- if (((v_buf[b_size-reverse] == head[0]) && (v_buf[b_size-reverse +1 ] == head[1]) && (v_buf[b_size-reverse+2] == head[2] & ~0x2)) ||
- ((v_buf[b_size-reverse-1] == head[0]) && (v_buf[b_size-reverse] == (head[1])) && (v_buf[b_size-reverse+1] == head[2] | 0x2))){
+ if (((v_buf[b_size-reverse] == head[0]) && (v_buf[b_size-reverse +1 ] == head[1]) && (v_buf[b_size-reverse+2] == (head[2] & ~0x2))) ||
+ ((v_buf[b_size-reverse-1] == head[0]) && (v_buf[b_size-reverse] == (head[1])) && (v_buf[b_size-reverse+1] == (head[2] | 0x2)))){
#ifdef DEBUG_MAGIC_MP3_STREAM
fprintf(stderr,"MP3-CHECK: Block %lu : is mp3-data but not begin of file\n", f_data->first);
blockhex(stderr,(void*)(v_buf+b_size-reverse-16),0,64);
diff --git a/src/hard_link_stack.c b/src/hard_link_stack.c
index fde1609..71a005e 100644
--- a/src/hard_link_stack.c
+++ b/src/hard_link_stack.c
@@ -84,6 +84,7 @@ int rename_hardlink_path(char *old, char *neu){
}
head.pointer = head.pointer->next;
}
+ return 0;
}
@@ -107,7 +108,7 @@ char* check_link_stack(ext2_ino_t inode_nr, __u32 generation){
}
-
+// not used ; gcc warning okay
static void del_link_stack(struct link_entry* entry){
if(entry->name)
free(entry->name);
@@ -146,7 +147,7 @@ void clear_link_stack(){
fflush(stdout);
if (head.count){
- fprintf(stderr,"Hardlink Database\n", head.count);
+ fprintf(stderr,"Hardlink Database : %lu entries\n", (long unsigned int)head.count);
head.pointer = head.begin;
while (head.pointer){
diff --git a/src/hard_link_stack.h b/src/hard_link_stack.h
index 639dd1f..fdca40c 100644
--- a/src/hard_link_stack.h
+++ b/src/hard_link_stack.h
@@ -44,6 +44,6 @@ void add_link_stack(ext2_ino_t , __u32, char*, __u32 );
char* check_link_stack(ext2_ino_t, __u32);
int match_link_stack(ext2_ino_t, __u32 );
void clear_link_stack();
-
+int rename_hardlink_path(char*, char*);
#endif
diff --git a/src/imap_search.c b/src/imap_search.c
index c616e05..752c9df 100644
--- a/src/imap_search.c
+++ b/src/imap_search.c
@@ -30,6 +30,8 @@
#include <time.h>
#include "magic.h"
#include "journal.h"
+#include "block.h"
+#include "hard_link_stack.h"
extern ext2_filsys current_fs;
extern time_t now_time ;
@@ -48,14 +50,13 @@ 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;
- __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);
+ charbuf = (char*)((struct privat*)priv)->buf + (blocksize * blockcnt);
if (((struct privat*)priv)->flag){
int allocated = ext2fs_test_block_bitmap ( fs->block_map, *blocknr );
@@ -108,7 +109,7 @@ static char* get_pathname(blk_t inode_nr, char* i_pathname, char *magic_buf, uns
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);
+ sprintf(name_str,"/I_%010lu",(long unsigned int)inode_nr);
strcat(help_data->name,name_str);
get_file_property(help_data);
}
@@ -151,7 +152,7 @@ static void search_imap_inode(char* des_dir, __u32 t_after, __u32 t_before, int
{
struct ext2_group_desc *gdp;
struct ext2_inode_large *inode;
-struct dir_list_head_t *dir = NULL;
+//struct dir_list_head_t *dir = NULL;
struct ring_buf* i_list = NULL;
r_item* item = NULL;
int zero_flag, retval, load, x ,i ;
@@ -247,7 +248,7 @@ for (group = 0 ; group < current_fs->group_desc_count ; group++){
}
// 1. magical step
if (LINUX_S_ISDIR(mode) && ( flag & 0x01) && (pathname)){
- sprintf(pathname,"<%lu>",inode_nr);
+ sprintf(pathname,"<%lu>",(long unsigned int)inode_nr);
struct dir_list_head_t * dir = NULL;
@@ -281,7 +282,7 @@ for (group = 0 ; group < current_fs->group_desc_count ; group++){
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);
+ sprintf(pathname,"<%lu>",(long unsigned int)inode_nr);
recover_file(des_dir,"MAGIC-2", ((i_pathname)?i_pathname : pathname),
(struct ext2_inode*)item->inode, inode_nr, 0);
if(i_pathname){
@@ -332,7 +333,7 @@ int retval = 0;
recovername = malloc(strlen(des_dir) + strlen(pathname) + 30);
dirname = malloc(strlen(des_dir) + strlen(pathname) + strlen(filename) +10);
if (recovername && dirname){
- sprintf(recovername,"%s/MAGIC-1/<%lu>",des_dir,inode_nr);
+ sprintf(recovername,"%s/MAGIC-1/<%lu>",des_dir,(long unsigned int)inode_nr);
sprintf(dirname,"%s/%s/%s",des_dir,pathname,filename);
retval = stat (recovername, &filestat);
@@ -359,6 +360,7 @@ if (recovername && dirname){
return retval;
}
+return 0;
}
@@ -367,7 +369,7 @@ void search_journal_lost_inode(char* des_dir, __u32 t_after, __u32 t_before, int
struct ext2_inode *p_inode;
struct ext2_inode inode;
-int retval,i ;
+int i;
char *pathname = NULL;
char *i_pathname = NULL;
char *buf= NULL;
@@ -411,7 +413,7 @@ while ( get_pool_block(buf) ){
continue;
if (check_file_stat(&inode)){
i_pathname = identify_filename(i_pathname, tmp_buf, &inode, inode_nr);
- sprintf(pathname,"<%lu>",inode_nr);
+ sprintf(pathname,"<%lu>",(long unsigned int)inode_nr);
recover_file(des_dir,"MAGIC-2", ((i_pathname)?i_pathname : pathname), &inode, inode_nr, 1);
}
if(i_pathname){
diff --git a/src/inode.c b/src/inode.c
index 39131f7..88642ac 100644
--- a/src/inode.c
+++ b/src/inode.c
@@ -31,6 +31,7 @@
#include "inode.h"
#include "ring_buf.h"
#include "extent_db.h"
+#include "block.h"
extern ext2_filsys current_fs;
extern time_t now_time ;
@@ -65,7 +66,7 @@ int intern_read_inode(ext2_ino_t ino, struct ext2_inode * inode)
}
-//#ifdef WORDS_BIGENDIAN
+#ifdef WORDS_BIGENDIAN
// On my current version of libext2 the extra time fields ar not bigendian corrected
// We want this solved temporarily here with this function
static void le_to_cpu_swap_extra_time(struct ext2_inode_large *inode, char *inode_buf){
@@ -77,7 +78,7 @@ int intern_read_inode(ext2_ino_t ino, struct ext2_inode * inode)
inode->i_crtime_extra = ext2fs_le32_to_cpu(((struct ext2_inode_large *)inode_buf)->i_crtime_extra );
//inode->i_version_hi = ext2fs_le32_to_cpu(((struct ext2_inode_large *)inode_buf)->i_version_hi );
}
-//#endif
+#endif
//subfunction for dump_inode_extra
static void dump_xattr_string(FILE *out, const char *str, int len)
@@ -374,6 +375,7 @@ void dump_inode(FILE *out, const char *prefix,
fprintf(out, "%sMode: %04o Flags: 0x%x ",
prefix, inode->i_mode & 0777, inode->i_flags);
#ifdef FILE_ATTR
+#include <e2p/e2p.h>
if (do_dump_blocks && inode->i_flags) {
fprintf(out,"[");
print_flags(out, inode->i_flags, 0);
@@ -433,27 +435,27 @@ void dump_inode(FILE *out, const char *prefix,
prefix, inode->i_faddr, frag, fsize);
if (is_large_inode && large_inode->i_extra_isize >= 24) {
fprintf(out, "%s ctime: %10lu:%010lu -- %s", prefix,
- inode->i_ctime, large_inode->i_ctime_extra,
+ (long unsigned int)inode->i_ctime, (long unsigned int)large_inode->i_ctime_extra,
time_to_string(inode->i_ctime));
fprintf(out, "%s atime: %10lu:%010lu -- %s", prefix,
- inode->i_atime, large_inode->i_atime_extra,
+ (long unsigned int)inode->i_atime, (long unsigned int)large_inode->i_atime_extra,
time_to_string(inode->i_atime));
fprintf(out, "%s mtime: %10lu:%010lu -- %s", prefix,
- inode->i_mtime, large_inode->i_mtime_extra,
+ (long unsigned int)inode->i_mtime, (long unsigned int)large_inode->i_mtime_extra,
time_to_string(inode->i_mtime));
fprintf(out, "%scrtime: %10lu:%010lu -- %s", prefix,
- large_inode->i_crtime, large_inode->i_crtime_extra,
+ (long unsigned int)large_inode->i_crtime, (long unsigned int)large_inode->i_crtime_extra,
time_to_string(large_inode->i_crtime));
} else {
- fprintf(out, "%sctime: %10lu -- %s", prefix, inode->i_ctime,
+ fprintf(out, "%sctime: %10lu -- %s", prefix, (long unsigned int)inode->i_ctime,
time_to_string(inode->i_ctime));
- fprintf(out, "%satime: %10lu -- %s", prefix, inode->i_atime,
+ fprintf(out, "%satime: %10lu -- %s", prefix, (long unsigned int)inode->i_atime,
time_to_string(inode->i_atime));
- fprintf(out, "%smtime: %10lu -- %s", prefix, inode->i_mtime,
+ fprintf(out, "%smtime: %10lu -- %s", prefix, (long unsigned int)inode->i_mtime,
time_to_string(inode->i_mtime));
}
if (inode->i_dtime)
- fprintf(out, "%sdtime: %10lu -- %s", prefix, inode->i_dtime,
+ fprintf(out, "%sdtime: %10lu -- %s", prefix, (long unsigned int)inode->i_dtime,
time_to_string(inode->i_dtime));
if (EXT2_INODE_SIZE(current_fs->super) > EXT2_GOOD_OLD_INODE_SIZE)
dump_inode_extra(out, prefix, inode_num,
@@ -515,18 +517,20 @@ blk_t get_inode_pos(struct ext2_super_block *es ,struct inode_pos_struct *pos, e
// get journalinode from transactionnumber
int get_transaction_inode(ext2_ino_t inode_nr, __u32 transaction_nr, struct ext2_inode_large *inode){
- struct inode_pos_struct pos;
- __u32 journal_block;
- blk_t block_nr;
- struct ext2_inode_large *inode_buf;
- char *buf = NULL;
- int got,retval = 0;
- int blocksize = current_fs->blocksize;
+ struct inode_pos_struct pos;
+ __u32 journal_block;
+ blk_t block_nr;
+ struct ext2_inode_large *inode_buf;
+ char *buf = NULL;
+ int retval = 0;
+ unsigned int got;
+ int blocksize = current_fs->blocksize;
block_nr = get_inode_pos(current_fs->super, &pos , inode_nr, 0);
journal_block = get_journal_blocknr(block_nr, transaction_nr);
if (! journal_block){
- fprintf(stdout,"No journalblock found for inode %lu by transaction %lu\n",inode_nr,transaction_nr);
+ fprintf(stdout,"No journalblock found for inode %lu by transaction %lu\n",
+ (long unsigned int)inode_nr,(long unsigned int)transaction_nr);
retval = -1;
}
else {
@@ -627,7 +631,7 @@ r_item* get_last_undel_inode(struct ring_buf* buf){
r_item* get_undel_inode(struct ring_buf* buf, __u32 after, __u32 before){
r_item* item;
int i, count;
- __u32 generation;
+// __u32 generation;
if (!buf) return NULL;
item = r_last(buf);
@@ -658,21 +662,22 @@ r_item* get_last_undel_inode(struct ring_buf* buf){
//fill all inode found in the Journal in the inode-ringbuffer
struct ring_buf* get_j_inode_list(struct ext2_super_block *es, ext2_ino_t inode_nr){
- struct inode_pos_struct pos;
- blk_t block;
- char * inode_buf = NULL ;
- struct ext2_inode *inode_pointer;
- struct ring_buf* buf = NULL;
- r_item *item = NULL;
-// struct ext2_inode_large *inode = NULL;
- int count, got, retval = 0;
- off_t offset;
- char *journal_tag_buf = NULL;
- journal_descriptor_tag_t *block_list;
- __u32 ctime = 1;
- __u32 same_size = 1;
- __u32 same_block_count = 0;
- __u16 same_link_count = 0;
+ struct inode_pos_struct pos;
+ blk_t block;
+ char *inode_buf = NULL ;
+ struct ext2_inode *inode_pointer;
+ struct ring_buf *buf = NULL;
+ r_item *item = NULL;
+// struct ext2_inode_large *inode = NULL;
+ int count, retval = 0;
+ unsigned int got;
+ off_t offset;
+ char *journal_tag_buf = NULL;
+ journal_descriptor_tag_t *block_list;
+ __u32 ctime = 1;
+ __u32 same_size = 1;
+ __u32 same_block_count = 0;
+ __u16 same_link_count = 0;
if ((inode_nr > es->s_inodes_count) || (inode_nr == 0))
{
@@ -1042,9 +1047,8 @@ return 1;
//add the ext3 indirect Blocks to the inode
-int inode_add_meta_block(struct ext2_inode_large* inode , blk_t blk, blk_t *last, blk_t *next, unsigned char *buf ){
+int inode_add_meta_block(struct ext2_inode_large* inode , blk_t blk, blk_t *last, blk_t *next, char *buf ){
blk_t block_count = 0;
- //blk_t b_blk,count=0;
int i = 0;
__u64 i_size = 0;
int ret = 0;
diff --git a/src/inode.h b/src/inode.h
index 86184d4..bb70e60 100644
--- a/src/inode.h
+++ b/src/inode.h
@@ -58,14 +58,6 @@ struct extent_area {
};
*/
-//private an helper functions
-static void dump_xattr_string(FILE*, const char*, int);//subfunction for dump_inode_extra
-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, 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)
-
//functions for external use
int intern_read_inode_full(ext2_ino_t, struct ext2_inode*, int);// read real fs inode 128++
@@ -84,7 +76,7 @@ struct ring_buf* get_j_inode_list(struct ext2_super_block*, ext2_ino_t);//fill a
//functions for the magic scanner
struct ext2_inode_large* new_inode(); //create a new inode
int inode_add_block(struct ext2_inode_large* , blk_t); //add a block to inode
-int inode_add_meta_block(struct ext2_inode_large*, blk_t, blk_t*, blk_t*,unsigned char* ); //add the ext3 indirect Blocks to the inode
+int inode_add_meta_block(struct ext2_inode_large*, blk_t, blk_t*, blk_t*,char* ); //add the ext3 indirect Blocks to the inode
//functions in develop
int inode_add_extent(struct ext2_inode_large*, struct extent_area*, __u32*, int );
diff --git a/src/jfs_compat.h b/src/jfs_compat.h
index 024333b..0f66f6e 100644
--- a/src/jfs_compat.h
+++ b/src/jfs_compat.h
@@ -5,7 +5,7 @@
/* ext3/4 libraries */
#include <ext2fs/ext2fs.h>
-#include "kernel-list.h"
+/*#include "kernel-list.h"
#include <errno.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
@@ -15,10 +15,10 @@
#define KERN_DEBUG ""
#define READ 0
-#define WRITE 1
+#define WRITE 1*/
-#define cpu_to_be32(n) htonl(n)
-#define be32_to_cpu(n) ntohl(n)
+//#define cpu_to_be32(n) htonl(n)
+//#define be32_to_cpu(n) ntohl(n)
typedef unsigned int tid_t;
typedef struct journal_s journal_t;
@@ -50,7 +50,7 @@ struct journal_s
tid_t j_failed_commit;
};
-#define J_ASSERT(assert) \
+/*#define J_ASSERT(assert) \
do { if (!(assert)) { \
printf ("Assertion failure in %s() at %s line %d: " \
"\"%s\"\n", \
@@ -62,9 +62,9 @@ struct journal_s
#define BUFFER_TRACE(bh, info) do {} while (0)
-/* Need this so we can compile with configure --enable-gcc-wall */
+// Need this so we can compile with configure --enable-gcc-wall
#ifdef NO_INLINE_FUNCS
#define inline
-#endif
+#endif*/
#endif /* _JFS_COMPAT_H */
diff --git a/src/journal.c b/src/journal.c
index d8ccd83..dd1724f 100644
--- a/src/journal.c
+++ b/src/journal.c
@@ -24,7 +24,7 @@
#include <string.h>
#include <time.h>
-#ifdef HAVE_ERRNO_H
+#ifndef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -41,6 +41,7 @@
#include "ext4magic.h"
#include "util.h"
#include "journal.h"
+#include "inode.h"
enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL, JOURNAL_IS_DUMMY};
@@ -89,30 +90,30 @@ void dump_journal_superblock( void)
fprintf(stdout," Signature: 0x%08x \n",jsb->s_header.h_magic);
fprintf(stdout," Blocktype : %s \n",type_to_name(jsb->s_header.h_blocktype));
- fprintf(stdout," Journal block size: %lu \n",jsb->s_blocksize);
- fprintf(stdout," Number of journal blocks: %lu \n",jsb->s_maxlen);
- fprintf(stdout," Journal block where the journal actually starts: %lu\n",jsb->s_first);
- fprintf(stdout," Sequence number of first transaction: %lu\n", jsb->s_sequence);
- fprintf(stdout," Journal block of first transaction: %lu\n", jsb->s_start);
- fprintf(stdout," Error number: %ld\n",jsb->s_errno);
+ fprintf(stdout," Journal block size: %lu \n",(long unsigned int)jsb->s_blocksize);
+ fprintf(stdout," Number of journal blocks: %lu \n",(long unsigned int)jsb->s_maxlen);
+ fprintf(stdout," Journal block where the journal actually starts: %lu\n",(long unsigned int)jsb->s_first);
+ fprintf(stdout," Sequence number of first transaction: %lu\n", (long unsigned int)jsb->s_sequence);
+ fprintf(stdout," Journal block of first transaction: %lu\n", (long unsigned int)jsb->s_start);
+ fprintf(stdout," Error number: %ld\n",(long int)jsb->s_errno);
if ((jsb->s_header.h_blocktype) != JFS_SUPERBLOCK_V2)
return ;
// Remaining fields are only valid in a version-2 superblock
//FIXME: Strings of Features
- fprintf(stdout," Compatible Features: %lu\n",jsb->s_feature_compat);
- fprintf(stdout," Incompatible features: %lu\n",jsb->s_feature_incompat);
- fprintf(stdout," Read only compatible features: %lu\n",jsb->s_feature_ro_compat);
+ fprintf(stdout," Compatible Features: %lu\n",(long unsigned int)jsb->s_feature_compat);
+ fprintf(stdout," Incompatible features: %lu\n",(long unsigned int)jsb->s_feature_incompat);
+ fprintf(stdout," Read only compatible features: %lu\n",(long unsigned int)jsb->s_feature_ro_compat);
uuid_unparse(jsb->s_uuid, buffer);
fprintf(stdout," Journal UUID: %s \n",buffer);
nr_users = jsb->s_nr_users;
- fprintf(stdout," Number of file systems using journal: %lu\n", jsb->s_nr_users);
+ fprintf(stdout," Number of file systems using journal: %lu\n", (long unsigned int)jsb->s_nr_users);
- fprintf(stdout," Location of superblock copy: %lu\n",jsb->s_dynsuper);
- fprintf(stdout," Max journal blocks per transaction: %lu\n",jsb->s_max_transaction);
- fprintf(stdout," Max file system blocks per transaction: %lu\n",jsb->s_max_trans_data);
+ fprintf(stdout," Location of superblock copy: %lu\n",(long unsigned int)jsb->s_dynsuper);
+ fprintf(stdout," Max journal blocks per transaction: %lu\n",(long unsigned int)jsb->s_max_transaction);
+ fprintf(stdout," Max file system blocks per transaction: %lu\n",(long unsigned int)jsb->s_max_trans_data);
if (nr_users && (nr_users < 48)) {
fprintf(stdout," IDs of all file systems using the journal:\n");
@@ -144,12 +145,14 @@ static void journal_superblock_to_cpu ( __u32 *jsb )
extern int journal_open( char *journal_file_name, int journal_backup_flag )
{
char *journal_dev_name = NULL;
- char *dummy_journal = NULL;
int journal_fd = 0;
ext2_ino_t journal_inum;
struct ext2_inode journal_inode;
int retval;
ext2_file_t journal_file;
+#ifdef EXPERT_MODE
+ char *dummy_journal = NULL;
+#endif
pt_buff = NULL;
ptl = NULL;
@@ -197,7 +200,7 @@ extern int journal_open( char *journal_file_name, int journal_backup_flag )
if (journal_backup_flag){
//check the Journal Magic Number
char* jsb_buffer = NULL;
- int got;
+ unsigned int got;
journal_superblock_t* jsb;
jsb_buffer = malloc(1024);
@@ -205,8 +208,8 @@ extern int journal_open( char *journal_file_name, int journal_backup_flag )
journal_source.file = journal_file;
if ((jsb_buffer) && (! read_journal_block(0,jsb_buffer, 1024, &got))){
jsb = (journal_superblock_t *) jsb_buffer;
- if ((be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) ||
- (current_fs->blocksize != be32_to_cpu(jsb->s_blocksize))) {
+ if ((ext2fs_be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) ||
+ (current_fs->blocksize != ext2fs_be32_to_cpu(jsb->s_blocksize))) {
retval = 1;
}
free(jsb_buffer);
@@ -225,13 +228,13 @@ extern int journal_open( char *journal_file_name, int journal_backup_flag )
if (dummy_journal){
memset (dummy_journal,0,current_fs->blocksize *2);
jsb = (journal_superblock_t*) dummy_journal;
- jsb->s_header.h_magic = htonl(JFS_MAGIC_NUMBER);
- jsb->s_header.h_blocktype = htonl(JFS_SUPERBLOCK_V2);
- jsb->s_blocksize = htonl(current_fs->blocksize);
- jsb->s_maxlen = htonl(2);
- jsb->s_nr_users = htonl(1);
- jsb->s_first = htonl(1);
- jsb->s_sequence = htonl(1);
+ jsb->s_header.h_magic = ext2fs_cpu_to_be32(JFS_MAGIC_NUMBER);
+ jsb->s_header.h_blocktype = ext2fs_cpu_to_be32(JFS_SUPERBLOCK_V2);
+ jsb->s_blocksize = ext2fs_cpu_to_be32(current_fs->blocksize);
+ jsb->s_maxlen = ext2fs_cpu_to_be32(2);
+ jsb->s_nr_users = ext2fs_cpu_to_be32(1);
+ jsb->s_first = ext2fs_cpu_to_be32(1);
+ jsb->s_sequence = ext2fs_cpu_to_be32(1);
memcpy(jsb->s_uuid, current_fs->super->s_uuid, sizeof(current_fs->super->s_uuid));
journal_source.where = JOURNAL_IS_DUMMY;
journal_source.file = NULL;
@@ -319,9 +322,10 @@ extern int journal_close(void)
//print hexdump of a journalblock
int dump_journal_block( __u32 block_nr , int flag){
- char *buf = NULL;
- int got,retval = 0;
- int blocksize = current_fs->blocksize;
+ char *buf = NULL;
+ unsigned int got;
+ int retval = 0;
+ int blocksize = current_fs->blocksize;
buf = (char*) malloc(blocksize);
if(! buf) return 1 ;
@@ -340,7 +344,7 @@ int dump_journal_block( __u32 block_nr , int flag){
//read a journal block
int read_journal_block(off_t offset, char *buf, int size, unsigned int *got)
{
- int retval;
+ int retval = 1;
switch (journal_source.where) {
case JOURNAL_IS_EXTERNAL :
if (lseek(journal_source.fd, offset, SEEK_SET) < 0) {
@@ -381,7 +385,7 @@ int read_journal_block(off_t offset, char *buf, int size, unsigned int *got)
-static const char *type_to_name(int btype)
+const char *type_to_name(int btype)
{
switch (btype) {
case JFS_DESCRIPTOR_BLOCK:
@@ -400,7 +404,7 @@ static const char *type_to_name(int btype)
//check if journal block is a lost inodeblock local function
-int jb_is_inodetable(unsigned char *buf){
+static int jb_is_inodetable(char *buf){
struct ext2_inode *inode;
__u16 mode;
__u32 atime;
@@ -410,7 +414,6 @@ int jb_is_inodetable(unsigned char *buf){
int i;
__u32 min = 315601200; // 315601200 = "1980-01-01 20:00:00"
__u32 max = (__u32) now_time;
- int ret = 0;
int i_size = EXT2_INODE_SIZE(current_fs->super);
int inodes_per_block = (current_fs->blocksize / i_size );
int flag = 0;
@@ -472,17 +475,18 @@ return 0;
static __u32 get_transaction_time( __u32 j_block){
char *buf;
struct ext2_inode *inode;
- __u32 t_time = 0;
- int ino, got ,retval = 0;
- int inode_size = EXT2_INODE_SIZE(current_fs->super);
- int blocksize = current_fs->blocksize;
+ __u32 t_time = 0;
+ int ino, retval = 0;
+ unsigned int got;
+ int inode_size = EXT2_INODE_SIZE(current_fs->super);
+ int blocksize = current_fs->blocksize;
buf = (char*) malloc(blocksize);
if(! buf) return 0 ;
retval = read_journal_block(j_block * blocksize ,buf,blocksize,&got);
if (retval || got != blocksize){
- fprintf(stderr,"Error while read journal block %ld\n",j_block);
+ fprintf(stderr,"Error while read journal block %u\n",(unsigned int)j_block);
t_time = 0;
goto errout;
}
@@ -538,11 +542,11 @@ void print_block_list(int flag){
else transaction_time = 0;
}
if (transaction_time)
- fprintf(stdout,"%12llu %8lu %8lu %8lu %s",(__u64) pointer->f_blocknr , pointer->j_blocknr ,
- pointer->transaction, transaction_time, time_to_string(transaction_time) );
+ fprintf(stdout,"%12llu %8lu %8lu %8lu %s",(__u64) pointer->f_blocknr , (long unsigned int)pointer->j_blocknr ,
+ (long unsigned int)pointer->transaction, (long unsigned int)transaction_time, time_to_string(transaction_time) );
else
- fprintf(stdout,"%12llu %8lu %8lu\n",(__u64) pointer->f_blocknr , pointer->j_blocknr ,
- pointer->transaction);
+ fprintf(stdout,"%12llu %8lu %8lu\n",(__u64) pointer->f_blocknr , (long unsigned int)pointer->j_blocknr ,
+ (long unsigned int)pointer->transaction);
pointer++ ;
}
}
@@ -564,10 +568,12 @@ void print_block_transaction(blk64_t block_nr, int flag){
if (pointer->f_blocknr == block_nr){
if (is_inode_block){
transaction_time = get_transaction_time(pointer->j_blocknr);
- fprintf(stdout,"%12llu %8lu %8lu %8lu %s",(__u64) pointer->f_blocknr , pointer->j_blocknr ,
- pointer->transaction, transaction_time, time_to_string(transaction_time) );
+ fprintf(stdout,"%12llu %8lu %8lu %8lu %s",(__u64) pointer->f_blocknr ,
+ (long unsigned int)pointer->j_blocknr, (long unsigned int)pointer->transaction,
+ (long unsigned int)transaction_time, time_to_string(transaction_time));
}else
- fprintf(stdout,"%12llu %8lu %8lu\n",(__u64) pointer->f_blocknr , pointer->j_blocknr , pointer->transaction);
+ fprintf(stdout,"%12llu %8lu %8lu\n",(__u64) pointer->f_blocknr ,
+ (long unsigned int)pointer->j_blocknr , (long unsigned int)pointer->transaction);
}
pointer++ ;
}
@@ -592,12 +598,13 @@ 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, blk64_t *block, __u32 t_start, __u32 t_end){
- int retval = 0;
- int i , count , got;
- char *journal_tag_buf = NULL;
+ int retval = 0;
+ int i , count ;
+ unsigned int got;
+ char *journal_tag_buf = NULL;
journal_descriptor_tag_t *block_list;
- blk_t j_block = 0;
- int blksize = current_fs->blocksize;
+ blk_t j_block = 0;
+ int blksize = current_fs->blocksize;
if ((!t_start) && (!t_end)){
//there is no transaction, it is not from a journal Inode
@@ -751,8 +758,8 @@ static void extract_descriptor_block(char *buf, journal_superblock_t *jsb,
end of this block. */
if (offset > blocksize) break;
- tag_block = be32_to_cpu(tag->t_blocknr) ;
- tag_flags = be32_to_cpu(tag->t_flags);
+ tag_block = ext2fs_be32_to_cpu(tag->t_blocknr) ;
+ tag_flags = ext2fs_be32_to_cpu(tag->t_flags);
if (!(tag_flags & JFS_FLAG_SAME_UUID))
offset += 16;
@@ -764,7 +771,7 @@ static void extract_descriptor_block(char *buf, journal_superblock_t *jsb,
fprintf(stdout,"*");
#endif
pt->f_blocknr = tag_block ;
- if (tag_size > JBD_TAG_SIZE32) pt->f_blocknr |= (__u64)be32_to_cpu(tag->t_blocknr_high) << 32;
+ if (tag_size > JBD_TAG_SIZE32) pt->f_blocknr |= (__u64)ext2fs_be32_to_cpu(tag->t_blocknr_high) << 32;
pt->j_blocknr = blocknr;
pt->transaction = transaction;
pt++;
@@ -789,7 +796,7 @@ static void extract_descriptor_block(char *buf, journal_superblock_t *jsb,
// init and extract the journal in the local private data
-static int init_journal(void)
+int init_journal(void)
{
struct ext2_super_block *sb;
char buf[8192];
@@ -815,7 +822,7 @@ static int init_journal(void)
if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC)) ext2fs_swap_super(sb);
#endif
- if ((be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) &&
+ if ((ext2fs_be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) &&
(sb->s_magic == EXT2_SUPER_MAGIC) &&
(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
blocksize = EXT2_BLOCK_SIZE(sb);
@@ -834,7 +841,7 @@ static int init_journal(void)
if (retval) goto errout;
jsb = (journal_superblock_t *) jsb_buffer;
- if (be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) {
+ if (ext2fs_be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) {
fprintf(stderr, "Journal superblock magic number invalid!\n");
return JOURNAL_ERROR ;
}
@@ -851,7 +858,7 @@ static int init_journal(void)
pt = pt_buff ;
pt_count = 0;
if (pt_buff == NULL) {
- fprintf(stderr,"Error: can't allocate %d Memory\n",maxlen * sizeof(journal_descriptor_tag_t));
+ fprintf(stderr,"Error: can't allocate %lu Memory\n",maxlen * sizeof(journal_descriptor_tag_t));
goto errout;
}
ptl = (__u32*)(pt_buff + (maxlen * sizeof(journal_descriptor_tag_t)));
@@ -868,9 +875,9 @@ static int init_journal(void)
header = (journal_header_t *) buf;
- magic = be32_to_cpu(header->h_magic);
- sequence = be32_to_cpu(header->h_sequence);
- blocktype = be32_to_cpu(header->h_blocktype);
+ magic = ext2fs_be32_to_cpu(header->h_magic);
+ sequence = ext2fs_be32_to_cpu(header->h_sequence);
+ blocktype = ext2fs_be32_to_cpu(header->h_blocktype);
if (magic != JFS_MAGIC_NUMBER) {
#ifdef DEBUG
@@ -1036,7 +1043,8 @@ int next_block_bitmap(ext2fs_block_bitmap d_bmap){
journal_bitmap_tag_t *p1;
journal_bitmap_tag_t *p2;
__u32 blockg, skip,i,len;
- int got,retval;
+ unsigned int got;
+ int retval;
char *diff_buf;
if (jbbm.pointer->transaction < jbbm.first_trans)
@@ -1120,14 +1128,14 @@ errout:
//read the next journal-lost inode block
-int get_pool_block(unsigned char *buf){
- int retval = 0;
- int ret = 0;
- int got,i ;
- int blocksize = current_fs->blocksize;
+int get_pool_block(char *buf){
+ int retval = 0;
+ int ret = 0;
+ unsigned int got ;
+ int blocksize = current_fs->blocksize;
if (ptl_count){
- retval = read_journal_block(*ptl * blocksize ,buf,blocksize,&got);
+ retval = read_journal_block(*ptl * blocksize ,(char*)buf,blocksize,&got);
if ((! retval) && (got == blocksize)){
ret = 1;
}
diff --git a/src/journal.h b/src/journal.h
index be28b85..b2cecc8 100644
--- a/src/journal.h
+++ b/src/journal.h
@@ -60,8 +60,8 @@ struct j_bitmap_list_t
void dump_journal_superblock( void); //print journal superblock
extern int journal_open(char* , int );// open an extract the blocklist from journal
extern int journal_close(void); // close the journal (last function in main() if the journal open)
-static int init_journal(void); // main for extract the journal to the local private data
-static const char *type_to_name(int);
+int init_journal(void); // main for extract the journal to the local private data
+const char *type_to_name(int);
int get_block_list_count(blk64_t);//get count of journal blocklist
__u32 get_trans_time( __u32); //get the transactiontime of a transactionnumber
int get_block_list(journal_descriptor_tag_t*, blk64_t, int);//get a sortet list of all copys of a filesystemblock
@@ -76,5 +76,5 @@ int get_block_bitmap_list( journal_bitmap_tag_t**);//get a list of all copies of
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
int next_block_bitmap(ext2fs_block_bitmap); //produces a differential block bitmap for a transaction from the Journal
-int get_pool_block(unsigned char*);
+int get_pool_block(char*);
#endif
diff --git a/src/lookup_local.c b/src/lookup_local.c
index 4f62414..fbd3943 100644
--- a/src/lookup_local.c
+++ b/src/lookup_local.c
@@ -33,6 +33,7 @@
#include "dir_list.h"
#include "util.h"
#include "inode.h"
+#include "block.h"
#define DIRENT_MIN_LENGTH 12
extern ext2_filsys current_fs ;
@@ -597,7 +598,7 @@ void lookup_local(char* des_dir, struct dir_list_head_t * dir, __u32 t_after , _
switch (flag & REC_FILTER){
case LIST_ALL :
if (dir->dir_inode != lp->inode_nr) break;
- printf("DIR %lu %c%s%c\n",lp->inode_nr,c,dir->pathname,c);
+ printf("DIR %lu %c%s%c\n",(long unsigned int)lp->inode_nr,c,dir->pathname,c);
break;
case LIST_STATUS :
break;
@@ -634,7 +635,7 @@ void lookup_local(char* des_dir, struct dir_list_head_t * dir, __u32 t_after , _
//function for all files apart from dir
switch (flag & REC_FILTER){
case LIST_ALL :
- printf("--- %lu %c%s%s%s%c\n",lp->inode_nr,c,dir->pathname,
+ printf("--- %lu %c%s%s%s%c\n",(long unsigned int)lp->inode_nr,c,dir->pathname,
((strlen(dir->pathname) > 0) && strcmp(dir->pathname,"/")) ? "/" : "",
lp->filename,c);
break;
diff --git a/src/magic_block_scan.c b/src/magic_block_scan.c
index 4a9d620..5e75905 100644
--- a/src/magic_block_scan.c
+++ b/src/magic_block_scan.c
@@ -38,7 +38,7 @@ extern ext2_filsys current_fs ;
ext2fs_block_bitmap d_bmap = NULL ;
-static __u32 get_block_len(unsigned char *buf){
+static __u32 get_block_len(char *buf){
int len = current_fs->blocksize -1;
while ((len >= 0) && (!(*(buf + len))))
@@ -106,7 +106,7 @@ static struct found_data_t* copy_file_data(struct found_data_t* old){
static struct found_data_t* new_file_data(blk_t blk,__u32 scan,char *magic_buf, unsigned char* buf, __u32 *f, __u32 buf_length){
struct found_data_t *new;
int str_len;
- __u32 name_len;
+ int name_len;
char *c;
int def_len = 20;
char name_str[20];
@@ -147,7 +147,7 @@ static struct found_data_t* new_file_data(blk_t blk,__u32 scan,char *magic_buf,
else{
strcpy(new->scan_result,magic_buf);
strncpy(new->name, magic_buf , name_len - def_len+1);
- sprintf(name_str,"/%010lu",blk);
+ sprintf(name_str,"/%010lu",(long unsigned int)blk);
strcat(new->name,name_str);
get_file_property(new);
new->func(buf,&name_len,scan,2,new);
@@ -157,7 +157,8 @@ static struct found_data_t* new_file_data(blk_t blk,__u32 scan,char *magic_buf,
return free_file_data(new);
}
}
-*f++;
+*f++; //"gcc warning: value computed is not used" warning is okay
+
return new;
}
@@ -230,7 +231,7 @@ static int check_file_data_end(struct found_data_t* this,unsigned char *buf, __u
int size;
int ret = 0;
- size = get_block_len(buf);
+ size = get_block_len((char*)buf);
ret = (this->func(buf, &size ,this->scan ,0 , this) & mask) ;
if (ret)
@@ -250,7 +251,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, int flag){
+static int check_meta3_block(char *block_buf, blk_t blk, __u32 size, int flag){
blk_t block, *pb_block;
int i,j ;
@@ -279,12 +280,13 @@ static int check_meta3_block(unsigned char *block_buf, blk_t blk, __u32 size, in
else
return 0;
}
+ return 0; //never used
}
-static int check_indirect_meta3(unsigned char *block_buf){
+static int check_indirect_meta3(char *block_buf){
blk_t *pb_block;
blk_t last;
int i = current_fs->blocksize/sizeof(blk_t) -1;
@@ -309,10 +311,10 @@ static int check_indirect_meta3(unsigned char *block_buf){
-static int check_dindirect_meta3(unsigned char * block_buf){
+static int check_dindirect_meta3(char * block_buf){
__u32 *p_blk;
__u32 block;
- unsigned char *buf = NULL;
+ char *buf = NULL;
int ret = 0;
buf = malloc(current_fs->blocksize);
@@ -331,10 +333,10 @@ return ret;
-static int check_tindirect_meta3(unsigned char * block_buf){
+static int check_tindirect_meta3(char * block_buf){
__u32 *p_blk;
__u32 block;
- unsigned char *buf = NULL;
+ char *buf = NULL;
int ret = 0;
buf = malloc(current_fs->blocksize);
@@ -442,14 +444,14 @@ static int add_ext4_extent_idx_data(struct found_data_t* this, struct extent_are
}
-
+//for future use ; gcc warning is okay
static int add_ext4_extent_data(struct found_data_t* this, struct extent_area* ea){
return inode_add_extent(this->inode ,ea, &(this->last), 0);
}
-static int add_ext3_file_meta_data(struct found_data_t* this, unsigned char *buf, blk_t blk){
+static int add_ext3_file_meta_data(struct found_data_t* this, char *buf, blk_t blk){
blk_t next_meta = 0;
blk_t meta = 0;
blk_t last_data = 0;
@@ -511,7 +513,7 @@ return flag;
//FIXME
static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_f, char *magic_buf, __u32 size, blk_t blk, int deep){
int count = current_fs->blocksize -1 ;
- int *i , len;
+ int len;
char text[100] = "";
char *p_search;
__u32 retval = 0;
@@ -521,7 +523,7 @@ static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_
memset(text,0,100);
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, 0)){
+ if (check_meta3_block((char*)buf, blk, count+1, 0)){
retval = M_EXT3_META ;
goto out;
}
@@ -529,7 +531,7 @@ static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_
if (size > current_fs->blocksize){
strncpy(text,magic_buffer(cookie_f, buf, 512),60);
- if ((!strncmp(text,"data",4))|| (!strncmp(buf,"ID3",3))){
+ if ((!strncmp(text,"data",4))|| (!strncmp((char*)buf,"ID3",3))){
strncpy(text,magic_buffer(cookie_f,buf , size),60);
strncpy(magic_buf, magic_buffer(cookie , buf , size),60);
}
@@ -559,8 +561,8 @@ static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_
char *type;
char searchstr[] = "bin/perl python PEM SGML OpenSSH libtool M3U Tcl=script Perl=POD module=source PPD make=config bin/make awk bin/ruby bin/sed bin/expect bash ";
char searchtype[] = "text/x-perl text/x-python text/PEM text/SGML text/ssh text/libtool text/M3U text/tcl text/POD text/x-perl text/PPD text/configure text/x-makefile text/x-awk text/ruby text/sed text/expect text/x-shellscript ";
- if (deep && (count > 250) && (!strncmp(buf,"From ",5))){
- p_search = buf + 6;
+ if (deep && (count > 250) && (!strncmp((char*)buf,"From ",5))){
+ p_search = (char*)buf + 6;
for (len = 0; (len < (count -7)) ; len++){
if( *(p_search++) == 0x40)
break;
@@ -606,7 +608,7 @@ static int magic_check_block(unsigned char* buf,magic_t cookie , magic_t cookie_
}
if((count < (current_fs->blocksize -2)) || (!buf[-1])){
- p_search = buf + 6;
+ p_search = (char*)buf + 6;
for (len = 0; len < 20 ; len++){
if((*p_search ==0x0a) || (*(p_search++) == 0x20))
break;
@@ -874,7 +876,6 @@ static int get_full_range(blk_t* p_blk ,struct ext2fs_struct_loc_generic_bitmap
blk_t end;
int count=0;
int i;
- errcode_t x;
int diff = (current_fs->blocksize == 1024)?1:0;
for (begin = *p_blk; begin <= ds_bmap->end ; begin++){
@@ -893,7 +894,7 @@ static int get_full_range(blk_t* p_blk ,struct ext2fs_struct_loc_generic_bitmap
i = 0;
//add the previous block to the end of the buffer
if(io_channel_read_blk ( current_fs->io,begin-1,1,buf - current_fs->blocksize)){
- fprintf(stderr,"ERROR: while read block %10lu + %d %lu\n",begin,i,count-1);
+ fprintf(stderr,"ERROR: while read block %10lu + %d %d\n",(long unsigned int)begin,i,count-1);
return 0;
}
@@ -909,7 +910,7 @@ static int get_full_range(blk_t* p_blk ,struct ext2fs_struct_loc_generic_bitmap
else {
if (i){
if (io_channel_read_blk ( current_fs->io, begin , i, buf )){
- fprintf(stderr,"ERROR: while read block %10lu + %d\n",begin,i);
+ fprintf(stderr,"ERROR: while read block %10lu + %d\n",(long unsigned int)begin,i);
return 0;
}
buf += (current_fs->blocksize *i);
@@ -922,7 +923,7 @@ static int get_full_range(blk_t* p_blk ,struct ext2fs_struct_loc_generic_bitmap
*(p_blk+1) = end;
if (i){
if (io_channel_read_blk ( current_fs->io, begin , i, buf )){
- fprintf(stderr,"ERROR: while read block %10lu + %d %lu\n",begin,i,count-1);
+ fprintf(stderr,"ERROR: while read block %10lu + %d %d\n",(long unsigned int)begin,i,count-1);
return 0;
}
}
@@ -1013,8 +1014,8 @@ unsigned char *v_buf = NULL;
unsigned char *buf ;
char *magic_buf = NULL;
unsigned char *tmp_buf = NULL;
-int blocksize, ds_retval,count,i,ret,dummy;
-__u32 scan,follow, size;
+int blocksize, ds_retval,count,i,ret,dummy, size;
+__u32 scan,follow;
printf("MAGIC-3 : start ext3-magic-scan search. Please wait, this may take a long time\n");
@@ -1069,8 +1070,8 @@ while (ds_retval){
for(j=blk[0]+i; j<(blk[0]+i+12);j++)
add_file_data(file_data, j, scan ,&follow);
scan = magic_check_block(buf+((i+12)*blocksize), cookie, cookie_f , magic_buf , blocksize ,blk[0]+i+12, 0);
- if ((scan & M_EXT3_META) && (check_indirect_meta3( buf+((i+12)*blocksize)))){
- if (add_ext3_file_meta_data(file_data, buf+((i+12)*blocksize), j)){
+ if ((scan & M_EXT3_META) && (check_indirect_meta3((char*)buf+((i+12)*blocksize)))){
+ if (add_ext3_file_meta_data(file_data, (char*)buf+((i+12)*blocksize), j)){
io_channel_read_blk (current_fs->io, file_data->last, 1, tmp_buf);
file_data = soft_border(des_dir, tmp_buf, file_data, &follow, 0 ,&last_rec, 0x7);
i++ ;
@@ -1103,7 +1104,7 @@ while (ds_retval){
follow = 0;
scan = magic_check_block(buf+(i*blocksize), cookie, cookie_f , magic_buf , blocksize ,flag[i], 1);
if(scan & (M_DATA | M_BLANK | M_IS_META)){
- if ((!fragment_flag) && (scan & M_EXT3_META) && (check_indirect_meta3(buf+(i*blocksize)))){
+ if ((!fragment_flag) && (scan & M_EXT3_META) && (check_indirect_meta3((char*)buf+(i*blocksize)))){
blk[1] = block_backward(flag[i] , 13);
if (blk[1] && (blk[1] < last_rec) && (blk[1] < (flag[i]-12))){
@@ -1127,7 +1128,7 @@ while (ds_retval){
add_file_data(file_data, flag[j], scan ,&follow);
scan = magic_check_block(buf+((i+12)*blocksize), cookie, cookie_f , magic_buf , blocksize ,flag[i+12],0);
if (scan & M_EXT3_META){
- if (add_ext3_file_meta_data(file_data, buf+((i+12)*blocksize), flag[j])){
+ if (add_ext3_file_meta_data(file_data, (char*)buf+((i+12)*blocksize), flag[j])){
io_channel_read_blk (current_fs->io, file_data->last, 1, tmp_buf);
file_data = soft_border(des_dir, tmp_buf, file_data, &follow, flag[i], &last_rec, 0x7);
i++;
@@ -1155,7 +1156,7 @@ while (ds_retval){
else{
j--;
file_data = soft_border(des_dir,buf+(j*blocksize), file_data, &follow, flag[j], &last_rec,0x7);
- if ((!fragment_flag) && (scan & M_EXT3_META) && (check_indirect_meta3(buf+((j+1)*blocksize)))){
+ if ((!fragment_flag) && (scan & M_EXT3_META) && (check_indirect_meta3((char*)buf+((j+1)*blocksize)))){
blk[1] = block_backward(flag[j] , 12);
if (blk[1] && (blk[1] < last_rec) && (blk[1] < flag[j]-12)){
blk[0] = blk[1];
@@ -1219,6 +1220,7 @@ if (tmp_buf) free(tmp_buf);
if (magic_buf) free(magic_buf);
if (cookie) magic_close(cookie);
if (cookie_f) magic_close(cookie_f);
+return 0;
} //end
@@ -1240,7 +1242,7 @@ static int check_extent_len(struct ext3_extent_header *header, struct extent_are
if (!buf)
return 1;
if(io_channel_read_blk ( current_fs->io,ext2fs_le32_to_cpu(idx->ei_leaf), 1, buf )){
- fprintf(stderr,"Error read block %lu\n",ext2fs_le32_to_cpu(idx->ei_leaf));
+ fprintf(stderr,"Error read block %lu\n",(long unsigned int)ext2fs_le32_to_cpu(idx->ei_leaf));
ret = 2;
}
else{
@@ -1255,7 +1257,8 @@ static int check_extent_len(struct ext3_extent_header *header, struct extent_are
continue;
}
for (i = 0; ((! ret) && (i< ext2fs_le16_to_cpu(extent->ee_len))); i++){
- if (ext2fs_test_block_bitmap(bmap,ext2fs_le32_to_cpu(extent->ee_start)+i)&&(!(d_bmap,ext2fs_le32_to_cpu(extent->ee_start)+i)))
+ if (ext2fs_test_block_bitmap(bmap,ext2fs_le32_to_cpu(extent->ee_start)+i) &&
+ (!ext2fs_test_block_bitmap(d_bmap,ext2fs_le32_to_cpu(extent->ee_start)+i)))
ret = 4;
}
if (!ret){
@@ -1334,7 +1337,7 @@ int tes ; //typical extent size
//int zahler1 =0;
-printf("MAGIC-3 : start ext4-magic-scan search. Experimental in develop \n");
+printf("MAGIC-3 : start ext4-magic-scan search\n");
blocksize = current_fs->blocksize ;
tes = 1048576 / blocksize;
if (ext2fs_copy_bitmap(current_fs->block_map, &c_bmap)){
@@ -1343,6 +1346,7 @@ if (ext2fs_copy_bitmap(current_fs->block_map, &c_bmap)){
}
ext2fs_clear_block_bitmap(c_bmap);
+scan = 0;
count = 0;
blk[0] = 1;
cookie = magic_open(MAGIC_MIME | MAGIC_NO_CHECK_COMPRESS | MAGIC_NO_CHECK_ELF | MAGIC_CONTINUE);
@@ -1397,7 +1401,7 @@ while (ds_retval){
ea = new_extent_area();
if ( ea ){
if (check_extent_len((struct ext3_extent_header*) (buf+(i*blocksize)) , ea, blk[0]+i)){
- printf("extent %lu range allocated or damage\n",blk[0]+i);
+ printf("extent %lu range allocated or damage\n",(long unsigned int)blk[0]+i);
}
else{
// printf(" --> start: %lu end: %lu depth: %lu \n",ea->l_start, ea->l_end, ea->depth);
@@ -1405,7 +1409,7 @@ while (ds_retval){
first_b = ea->start_b;
if(( ext2fs_test_block_bitmap( bmap,first_b)) ||
(io_channel_read_blk (current_fs->io,first_b - 1,9,tmp_buf ))){
- fprintf(stderr,"Warning: block %10lu can not read or is allocated\n",first_b);
+ fprintf(stderr,"Warning: block %10lu can not read or is allocated\n",(long unsigned int)first_b);
//FIXME ERROR goto ?
}
else{
@@ -1453,7 +1457,7 @@ while (ds_retval){
first_b = ea->start_b;
if(( ext2fs_test_block_bitmap( bmap,first_b)) ||
(io_channel_read_blk (current_fs->io,first_b-1 ,9,tmp_buf ))){
- fprintf(stderr,"Warning: block %10lu can not read or is allocated\n",first_b);
+ fprintf(stderr,"Warning: block %10lu can not read or is allocated\n",(long unsigned int)first_b);
//FIXME ERROR goto ?
}
else{
@@ -1469,7 +1473,7 @@ while (ds_retval){
&last_rec, 0x7 | FORCE_RECOVER);
if(last_rec != ea_group[0].blocknr)
- printf("error: block %lu -> file not written\n",ea_group[0].blocknr);
+ printf("error: block %lu -> file not written\n",(long unsigned int)ea_group[0].blocknr);
for (i=0; i<count; i++){
extent_db_del(db,ea_group[i].blocknr);
}
@@ -1624,7 +1628,7 @@ newloop:
//Start of size carving
j = check_next_border(ds_bmap, blk[0]+i,((file_data->size-1)/blocksize)+1);
if ((!j) && (! io_channel_read_blk (current_fs->io, blk[0]+ i + ((file_data->size-1)/blocksize), 1, tmp_buf))){
- size = get_block_len(tmp_buf);
+ size = get_block_len((char*)tmp_buf);
if ((!(file_data->scantype & DATA_MINIMUM)) && (size <= ((file_data->size % blocksize)?(file_data->size % blocksize):blocksize))){
tmp_file_data = copy_file_data(file_data);
if (tmp_file_data){
@@ -1787,5 +1791,6 @@ if (magic_buf) free(magic_buf);
if (cookie) magic_close(cookie);
if (cookie_f) magic_close(cookie_f);
//printf("Count-1 = %lu Count-2 = %lu \n",zahler, zahler1);
+return 0;
}//funcion
//--------END----------
diff --git a/src/recover.c b/src/recover.c
index 87ac9ed..23a5d66 100644
--- a/src/recover.c
+++ b/src/recover.c
@@ -35,6 +35,7 @@
#include "util.h"
#include "hard_link_stack.h"
#include "inode.h"
+#include "block.h"
//defines for error in recover_file
@@ -51,7 +52,7 @@
#ifdef FILE_ATTR
-#include "e2p/e2p.h"
+#include <e2p/e2p.h>
//#FLAGS_MODIFIABLE = EXT2_NOATIME_FL | EXT2_SYNC_FL | EXT2_DIRSYNC_FL | EXT2_APPEND_FL | EXT2_COMPR_FL | EXT2_NODUMP_FL |
// EXT2_IMMUTABLE_FL | EXT3_JOURNAL_DATA_FL | EXT2_SECRM_FL | EXT2_UNRM_FL | EXT2_NOTAIL_FL | EXT2_TOPDIR_FL
#define FLAGS_MODIFIABLE 0x0001E0FF
@@ -85,9 +86,7 @@ void recover_list(char *des_dir, char *input_file,__u32 t_after, __u32 t_before,
char *lineptr = NULL ;
char *filename = NULL ;
char *p1 , *p2;
- char c;
size_t maxlen;
- int l;
size_t got;
ext2_ino_t inode_nr;
struct ring_buf *i_list;
@@ -192,9 +191,9 @@ static int read_syslink_block ( ext2_filsys fs, blk64_t *blocknr, e2_blkcnt_t bl
blk64_t /*ref_blk*/x, int /*ref_offset*/y, void *priv )
{
char *charbuf =((struct privat*)priv)->buf;
- __u32 nbytes;
+// __u32 nbytes;
errcode_t retval;
- int blocksize = fs->blocksize;
+// int blocksize = fs->blocksize;
if (*blocknr >= fs->super->s_blocks_count)
return BLOCK_ERROR;
@@ -527,7 +526,7 @@ int recover_file( char* des_dir,char* pathname, char* filename, struct ext2_inod
}
#ifdef FILE_ATTR
if( LINUX_S_ISREG(inode->i_mode)){
- unsigned long flags;
+ unsigned long flags = 0;
if (fgetflags(recovername, &flags) == -1) {
rec_error -= ATTRI_ERROR;
}
@@ -619,8 +618,9 @@ void set_dir_attributes(char* des_dir,char* pathname,struct ext2_inode *inode){
mode_t i_mode;
struct stat filestat;
struct utimbuf touchtime;
- unsigned long flags;
-
+#ifdef FILE_ATTR
+ unsigned long flags = 0 ;
+#endif
fullname = malloc(strlen(des_dir) + strlen(pathname) + 3);
if (fullname){
p1 = pathname;
diff --git a/src/util.c b/src/util.c
index 26acc5b..1b9053d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -26,11 +26,12 @@
/* ext3/4 libraries */
#include <ext2fs/ext2fs.h>
-//#include <ext2fs/ext2_io.h>
#include <e2p/e2p.h>
#include "util.h"
#include "ext2fsP.h"
+#include "block.h"
+#include "inode.h"
// default maxcount for histrogram
#define HIST_COUNT 10
@@ -67,7 +68,7 @@ dump_hist_header("c_time Histogram",after);
for (i=1;i <= cm ;i++) if (step < (p_hist+i)->c_count) step = (p_hist+i)->c_count;
step = step / 50;
for (i=1;i <= cm ;i++){
- fprintf(stdout,"%10lu : %8lu |", (p_hist+i)->time , (p_hist+i)->c_count);
+ fprintf(stdout,"%10lu : %8lu |", (long unsigned int)(p_hist+i)->time , (long unsigned int)(p_hist+i)->c_count);
for (j = 0,x = (p_hist+i)->c_count/50 ; j < 50 ; j++, x+=step )
fprintf(stdout,"%c",(x<(p_hist+i)->c_count) ? '*' : ' ');
fprintf(stdout,"| %s", time_to_string((__u32)(p_hist+i)->time));
@@ -79,7 +80,7 @@ step = 10.1 ;
for (i=1;i <= cm ;i++) if (step < (p_hist+i)->d_count) step = (p_hist+i)->d_count;
step = step / 50;
for (i=1;i <= cm ;i++){
- fprintf(stdout,"%10lu : %8lu |", (p_hist+i)->time , (p_hist+i)->d_count);
+ fprintf(stdout,"%10lu : %8lu |", (long unsigned int)(p_hist+i)->time , (long unsigned int)(p_hist+i)->d_count);
for (j = 0,x = (p_hist+i)->d_count/50 ; j < 50 ; j++, x+=step )
fprintf(stdout,"%c",(x<(p_hist+i)->d_count) ? '*' : ' ');
fprintf(stdout,"| %s", time_to_string((__u32)(p_hist+i)->time));
@@ -92,7 +93,7 @@ if (crt_found){
for (i=1;i <= cm ;i++) if (step < (p_hist+i)->cr_count) step = (p_hist+i)->cr_count;
step = step / 50;
for (i=1;i <= cm ;i++){
- fprintf(stdout,"%10lu : %8lu |", (p_hist+i)->time , (p_hist+i)->cr_count);
+ fprintf(stdout,"%10lu : %8lu |", (long unsigned int)(p_hist+i)->time , (long unsigned int)(p_hist+i)->cr_count);
for (j = 0,x = (p_hist+i)->cr_count/50 ; j < 50 ; j++, x+=step )
fprintf(stdout,"%c",(x<(p_hist+i)->cr_count) ? '*' : ' ');
fprintf(stdout,"| %s", time_to_string((__u32)(p_hist+i)->time));
@@ -233,7 +234,7 @@ void print_coll_list(__u32 t_after, __u32 t_before, int flag){
}
pointer = collect->list;
for (i = 0; i < collect->count; i++ ,pointer++){
- intern_read_inode_full(*pointer, inode_buf , (inode_size > 256) ? 256 : inode_size );
+ intern_read_inode_full(*pointer, (struct ext2_inode*)inode_buf , (inode_size > 256) ? 256 : inode_size );
c_time = inode->i_ctime;
d_time = inode->i_dtime;
cr_time = ((inode_size > EXT2_GOOD_OLD_INODE_SIZE) && (inode->i_extra_isize >= 24)) ? inode->i_crtime : 0 ;
@@ -274,13 +275,13 @@ __u32 get_last_delete_time(ext2_filsys fs)
{
struct ext2_group_desc *gdp;
char *buf= NULL;
-int zero_flag, x , retval;
+int zero_flag, x;
__u32 blocksize , inodesize , inode_max , inode_per_group, block_count;
__u32 inode_per_block , inode_block_group, group;
blk_t block_nr;
__u32 i, c_time, d_time;
__u32 last = 0;
-__u32 first;
+__u32 first = 0;
int flag;
struct ext2_inode_large *inode;
@@ -404,7 +405,7 @@ void blockhex (FILE *out_file, void *buf, int flag, int blocksize)
unsigned char c;
intp = (int *) buf;
- charp_0 = (unsigned char *) buf;
+ charp_0 = (char *) buf;
charp_1 = (char *) buf;
for (i=0; i<blocksize; i+=16) {
@@ -548,7 +549,8 @@ return;
int get_ind_block_len(char *buf, blk_t *blk, blk_t *last ,blk_t *next, __u64 *p_len){
int i = (current_fs->blocksize >> 2)- 1;
char *priv_buf = NULL;
- blk_t block, *p_block;
+ blk_t block = 0;
+ blk_t *p_block;
int flag = 0;
priv_buf = malloc(current_fs->blocksize);
@@ -587,7 +589,8 @@ int get_dind_block_len(char *buf, blk_t *blk, blk_t *last, blk_t *next, __u64 *p
int ret = 0;
int i = (current_fs->blocksize >> 2)- 1;
char *priv_buf = NULL;
- blk_t block, *p_block;
+ blk_t block = 0;
+ blk_t *p_block;
priv_buf = malloc(current_fs->blocksize);
if (! priv_buf){
@@ -626,7 +629,8 @@ int get_tind_block_len(char *buf, blk_t *blk, blk_t *last, blk_t *next, __u64 *p
int ret = 0;
int i = (current_fs->blocksize >> 2)- 1;
char *priv_buf = NULL;
- blk_t block, *p_block;
+ blk_t block = 0;
+ blk_t *p_block;
priv_buf = malloc(current_fs->blocksize);
if (! priv_buf){
diff --git a/src/util.h b/src/util.h
index 243968e..9844942 100644
--- a/src/util.h
+++ b/src/util.h
@@ -89,11 +89,6 @@
//#define RESERVE_FILETYPE 0xF0000000
-/* Definitions to allow ext4magic compilation with old e2fsprogs */
-//#ifndef EXT4_EXTENTS_FL
-//#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
-//#endif
-
#include "ring_buf.h"
#include "dir_list.h"
@@ -185,8 +180,12 @@ void print_coll_list(__u32, __u32, int); //print the history of collectlist
void add_coll_list(ext2_ino_t );// add inodenumber in a collectlist
void blockhex (FILE* , void*, int , int); //hexdump
char get_inode_mode_type( __u16); //get filetype of inode
+int get_ind_block_len(char*, blk_t*, blk_t*,blk_t*, __u64*);
+int get_dind_block_len(char*, blk_t*, blk_t*, blk_t*, __u64*);
+int get_tind_block_len(char*, blk_t*, blk_t*, blk_t*, __u64*);
//public helper functions util.c
char *time_to_string(__u32);
+__u32 get_last_delete_time(ext2_filsys);
int check_fs_open(char*);
void reset_getopt(void);
unsigned long parse_ulong(const char* , const char* , const char* , int* );
@@ -220,7 +219,7 @@ int check_find_dir(char*, ext2_ino_t, char*, char*); //check if the directory al
//public function file_type.c
//none #do not recover this
int file_none(unsigned char*, int*, __u32, int, struct found_data_t*); //do not recover this
-int ident_file(struct found_data_t*, __u32*, char*, char*); // index of the files corresponding magic result strings
+int ident_file(struct found_data_t*, __u32*, char*, void*); // index of the files corresponding magic result strings
void get_file_property(struct found_data_t*); //set the file properties and the extension