summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrobi <robi>2010-06-25 19:36:31 +0000
committerrobi <robi>2010-06-25 19:36:31 +0000
commit14264f692000d068f1dc8b4853852f30a72a8517 (patch)
treecc52524665341673f432584cac4e0ccb13e29bda /src
parent98b2c6649a00dace7f1815635d0d955b5f2392df (diff)
time matching in dirlist
Diffstat (limited to 'src')
-rw-r--r--src/ext4magic.c10
-rw-r--r--src/inode.c33
-rw-r--r--src/inode.h1
-rw-r--r--src/journal.c25
-rw-r--r--src/journal.h1
-rw-r--r--src/lookup_local.c6
-rw-r--r--src/util.h6
7 files changed, 70 insertions, 12 deletions
diff --git a/src/ext4magic.c b/src/ext4magic.c
index 3aa0925..4915c2e 100644
--- a/src/ext4magic.c
+++ b/src/ext4magic.c
@@ -884,6 +884,7 @@ if ((mode & COMMAND_INODE) && (mode & RECOVER_INODE))
{
struct ring_buf* i_list;
r_item *item = NULL;
+ __u32 time_stamp;
i_list = get_j_inode_list(current_fs->super, inode_nr);
if (i_list){
@@ -891,8 +892,13 @@ if ((mode & COMMAND_INODE) && (mode & RECOVER_INODE))
item = get_undel_inode(i_list,t_after,t_before);
if(item){
dump_inode(stdout, "",inode_nr, (struct ext2_inode *)item->inode, format);
- if ( LINUX_S_ISDIR(item->inode->i_mode))
- list_dir3(inode_nr, (struct ext2_inode*) item->inode, &(item->transaction));
+ if ( LINUX_S_ISDIR(item->inode->i_mode)){
+ time_stamp = (item->transaction.start) ? get_trans_time(item->transaction.start) : 0 ;
+#ifdef DEBUG
+ printf ("Transaction-time for search %ld : %s\n", time_stamp, time_to_string(time_stamp));
+#endif
+ list_dir3(inode_nr, (struct ext2_inode*) item->inode, &(item->transaction) , time_stamp);
+ }
}
else
printf("No entry with this time found\n");
diff --git a/src/inode.c b/src/inode.c
index b88b89f..a000da6 100644
--- a/src/inode.c
+++ b/src/inode.c
@@ -564,6 +564,7 @@ return ;
void dump_inode_list(struct ring_buf* buf, int flag){
r_item* item;
int i, count;
+ __u32 time_stamp;
if (!buf ) return;
item = r_first(buf);
@@ -571,8 +572,13 @@ void dump_inode_list(struct ring_buf* buf, int flag){
count = r_get_count(buf);
for (i = 0; i < count ; i++){
print_j_inode(item->inode , buf->nr , item->transaction.start, flag);
- if ( LINUX_S_ISDIR(item->inode->i_mode))
- list_dir3(buf->nr, (struct ext2_inode*)item->inode, &(item->transaction));
+ if ( LINUX_S_ISDIR(item->inode->i_mode)){
+ time_stamp = (item->transaction.start) ? get_trans_time(item->transaction.start) : 0 ;
+#ifdef DEBUG
+ printf ("Transaction-time for search %ld : %s\n", time_stamp, time_to_string(time_stamp));
+#endif
+ list_dir3(buf->nr, (struct ext2_inode*)item->inode, &(item->transaction),time_stamp);
+ }
item = r_next(item);
}
return;
@@ -808,6 +814,29 @@ errout:
return NULL;
}
+// get the first Journal Inode by time_stamp
+int read_time_match_inode( ext2_ino_t inode_nr, struct ext2_inode* inode_buf, __u32 time_stamp){
+ struct ring_buf* i_ring;
+ r_item* item;
+ int retval = 1;
+
+ i_ring = get_j_inode_list(current_fs->super, inode_nr);
+ if (i_ring) {
+ item = r_last(i_ring);
+
+ while ((ext2fs_le32_to_cpu(item->inode->i_ctime) > time_stamp) && ( item != r_first(i_ring)))
+ item = r_prev(item);
+
+//FIXME
+ memcpy(inode_buf,item->inode,EXT2_GOOD_OLD_INODE_SIZE);
+ ring_del(i_ring);
+ retval= 0;
+ }
+return retval;
+}
+
+
+
// get the first Journal Inode by transaction
diff --git a/src/inode.h b/src/inode.h
index 3fe22e6..a09c574 100644
--- a/src/inode.h
+++ b/src/inode.h
@@ -63,6 +63,7 @@ int get_transaction_inode(ext2_ino_t, int, struct ext2_inode_large*);// get jour
void dump_inode_list(struct ring_buf* , int);//print the contents of all copy of inode in the journal
void dump_inode(FILE*, const char*, ext2_ino_t, struct ext2_inode*,int);//print the contents of inode
int read_journal_inode( ext2_ino_t, struct ext2_inode*, __u32);// get the first Journal Inode by transaction
+int read_time_match_inode( ext2_ino_t, struct ext2_inode*, __u32);// get the first Journal Inode by time_stamp
struct ring_buf* get_j_inode_list(struct ext2_super_block*, ext2_ino_t);//fill all inode found in the Journal in the inode-ringbuffer
diff --git a/src/journal.c b/src/journal.c
index 89896b1..8781792 100644
--- a/src/journal.c
+++ b/src/journal.c
@@ -321,7 +321,7 @@ static const char *type_to_name(int btype)
//check if block is a inodeblock local function
-static int bock_is_inodetable(blk64_t block){
+static int block_is_inodetable(blk64_t block){
int group;
struct ext2_group_desc *gdp;
blk64_t last;
@@ -381,6 +381,25 @@ return t_time;
}
+
+//get the transactiontime of a transactionnumber
+__u32 get_trans_time( __u32 transaction){
+ journal_descriptor_tag_t *pointer;
+ __u32 counter;
+
+ pointer = pt_buff;
+ for (counter=0 ; counter<pt_count ; counter++, pointer++) {
+ if (pointer->transaction != transaction) continue;
+
+ if (block_is_inodetable(pointer->f_blocknr)) {
+ return get_transaction_time(pointer->j_blocknr);
+ }
+ else continue;
+ }
+ return 0;
+}
+
+
//print all usable copy of filesystem blocks are found in journal
void print_block_list(int flag){
journal_descriptor_tag_t *pointer;
@@ -393,7 +412,7 @@ void print_block_list(int flag){
for (counter=0 ; counter<pt_count ; counter++) {
if (flag){
- if (bock_is_inodetable (pointer->f_blocknr)){
+ if (block_is_inodetable (pointer->f_blocknr)){
transaction_time = get_transaction_time(pointer->j_blocknr);
}
else transaction_time = 0;
@@ -416,7 +435,7 @@ void print_block_transaction(blk64_t block_nr, int flag){
int is_inode_block = 0;
__u32 transaction_time = 0;
- if (flag) is_inode_block = bock_is_inodetable(block_nr);
+ if (flag) is_inode_block = block_is_inodetable(block_nr);
pointer = pt_buff;
printf("\nTransactions of Filesystemblock %llu in Journal\n",block_nr);
diff --git a/src/journal.h b/src/journal.h
index 34ada1a..c4bf5d3 100644
--- a/src/journal.h
+++ b/src/journal.h
@@ -36,6 +36,7 @@ extern int journal_close(void); // close the journal (last function in main() if
static int init_journal(void); // main for extract the journal to the local private data
static const char *type_to_name(int);
int get_block_list_count(blk64_t block);//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
int read_journal_block(off_t, char*, int, unsigned int*);
void print_block_list(int);
diff --git a/src/lookup_local.c b/src/lookup_local.c
index a48daa2..d46fe53 100644
--- a/src/lookup_local.c
+++ b/src/lookup_local.c
@@ -88,7 +88,8 @@ static int list_dir_proc(ext2_ino_t dir EXT2FS_ATTR((unused)),
else if (ls->options & LONG_OPT) {
if ((ino && (ino <= current_fs->super->s_inodes_count))) {
if (ls->options & ONLY_JOURNAL)
- retval = read_journal_inode( ino,&inode, ls->transaction->start);
+// retval = read_journal_inode( ino, &inode, ls->transaction->start);
+ retval = read_time_match_inode( ino, &inode, ls->time_stamp);
if (retval || !(ls->options & ONLY_JOURNAL))
if (intern_read_inode(ino, &inode))
return 0;
@@ -627,7 +628,7 @@ if(d_list)
// list dir over journal inode and journal dir blocks an journal dir-entry-inodes
-void list_dir3(ext2_ino_t ino, struct ext2_inode *inode, trans_range_t* transaction)
+void list_dir3(ext2_ino_t ino, struct ext2_inode *inode, trans_range_t* transaction ,__u32 time_stamp)
{
int retval;
int flags;
@@ -639,6 +640,7 @@ void list_dir3(ext2_ino_t ino, struct ext2_inode *inode, trans_range_t* transact
ls.options |= LONG_OPT;
ls.options |= DELETED_OPT;
ls.options |= ONLY_JOURNAL;
+ ls.time_stamp = time_stamp;
if (! ext2fs_test_inode_bitmap ( current_fs->inode_map, ino )) ls.options |= DELETED_DIR ;
diff --git a/src/util.h b/src/util.h
index cf706aa..3ead8ff 100644
--- a/src/util.h
+++ b/src/util.h
@@ -52,9 +52,9 @@
struct priv_dir_iterate_struct {
// char *name;
// char *path;
- // __u32 inode;
+ __u32 time_stamp;
// ext2_ino_t *found_inode;
- // int col;
+ // int col;
int options;
struct dir_list_head_t *dir_list;
//FIXME;
@@ -91,7 +91,7 @@ unsigned long parse_ulong(const char* , const char* , const char* , int* );
// public functions lookup_local.c
void list_dir(ext2_ino_t inode); //list dir (using normal functions from ext2fs)
void list_dir2(ext2_ino_t, struct ext2_inode*); //list dir (search in journal ; not automatical use the real inode from fs)
-void list_dir3(ext2_ino_t, struct ext2_inode*, trans_range_t* ); //list (search over journal; both inode as well journaldirblocks)
+void list_dir3(ext2_ino_t, struct ext2_inode*, trans_range_t* ,__u32 ); //list (search over journal; both inode as well journaldirblocks)
struct dir_list_head_t* get_dir3(struct ext2_inode*,ext2_ino_t, ext2_ino_t,char*, char*,__u32,__u32,int ); //directory finder
void lookup_local(char*, struct dir_list_head_t*, __u32 , __u32 , int ); // main worker function for recover and list
ext2_ino_t local_namei(struct dir_list_head_t*, char* , __u32, __u32, int);// search the Inode for an pathname (use journal data)