# HG changeset patch # User Michael Spacefalcon # Date 1374702729 0 # Node ID e516128db432941f9146312752c56924e10d9478 # Parent 40b1ae2ab2d7884c8ddf87a2d7b092fb1747d4c5 pirollback: resurrect file descendant chains diff -r 40b1ae2ab2d7 -r e516128db432 pirollback/rollback.c --- a/pirollback/rollback.c Wed Jul 24 19:50:24 2013 +0000 +++ b/pirollback/rollback.c Wed Jul 24 21:52:09 2013 +0000 @@ -16,6 +16,7 @@ extern int last_inode; extern int journal_start_ino; +static void report_inode(ino) { struct inode_info *inf = inode + ino; @@ -42,6 +43,7 @@ printf("reverting #%04X %c %s\n", ino, typechar, pathname); } +static void unlink_inode(oldino, newino, is_sibling) { struct inode_info *inf = inode + oldino; @@ -62,6 +64,33 @@ *flashp = 0xFFFF; } +static void +resurrect_descend_chain(headino, ino) +{ + struct inode_info *inf; + u8 *typebyte; + + for (; ino; ino = inf->descend) { + inf = inode + ino; + if (inf->type != 0xF4) { + fprintf(stderr, + "error: #%x, descendant of #%x, is not of type F4\n", + ino, headino); + exit(1); + } + typebyte = &inf->flash->type; + if (*typebyte) { + fprintf(stderr, + "inode #%x to be resurrected: not in deleted state\n", + ino); + exit(1); + } + /* undo the zeroing */ + *typebyte = 0xF4; + } +} + +static void resurrect_old_ver(oldino, newino) { struct inode_info *old = inode + oldino; @@ -84,6 +113,19 @@ } /* undo the zeroing */ *typebyte = old->type; + /* + * Is there a descendant chain (file continuation chunks) + * to resurrect as well? + */ + if (!old->descend) + return; + if (old->type != 0xF1) { + fprintf(stderr, + "resurrecting inode #%x: unexpected descendant with type != F1\n", + oldino); + exit(1); + } + resurrect_descend_chain(oldino, old->descend); } roll_back_inode(ino)