# HG changeset patch # User Michael Spacefalcon # Date 1372662241 0 # Node ID 7ceab8bfacb3090c254772b57a0db2ec6aada3e2 # Parent 9bc7f0e03fa8bc45cf459385d0d368c0d62352b0 mpffs-cat and mpffs-xtr converted to use the new extra chunk handling diff -r 9bc7f0e03fa8 -r 7ceab8bfacb3 mpffs/cat.c --- a/mpffs/cat.c Mon Jul 01 06:49:50 2013 +0000 +++ b/mpffs/cat.c Mon Jul 01 07:04:01 2013 +0000 @@ -46,9 +46,19 @@ } } +void +extra_chunk_callback(obj, opaque) + struct objinfo *obj; + u_long opaque; +{ + struct chunkinfo chi; + + size_extra_chunk(obj, &chi); + cat_chunk(&chi); +} + cat_file(headidx) { - int ent; struct objinfo obj; struct chunkinfo chi; @@ -62,19 +72,7 @@ validate_chunk(&obj); size_head_chunk(&obj, &chi); cat_chunk(&chi); - for (ent = obj.descend; ent != 0xFFFF; ent = obj.descend) { - obj.entryno = ent; - get_index_entry(&obj); - if (obj.type != 0xF4) { - fprintf(stderr, - "file continuation object at index %x: type %02X != expected F4\n", - ent, obj.type); - exit(1); - } - validate_chunk(&obj); - size_extra_chunk(&obj, &chi); - cat_chunk(&chi); - } + iterate_extra_chunks(obj.descend, extra_chunk_callback, (u_long) 0); if (cat_v) putchar('\n'); } diff -r 9bc7f0e03fa8 -r 7ceab8bfacb3 mpffs/xtr.c --- a/mpffs/xtr.c Mon Jul 01 06:49:50 2013 +0000 +++ b/mpffs/xtr.c Mon Jul 01 07:04:01 2013 +0000 @@ -49,9 +49,11 @@ } void -dump_extra_chunk(fd, ch) +dump_extra_chunk(ch, opaque) struct objinfo *ch; + u_long opaque; { + int fd = (int) opaque; u8 *endchunk; endchunk = find_end_of_chunk(ch); @@ -62,8 +64,6 @@ struct objinfo *head; { int fd; - int ent; - struct objinfo ch; fd = open(workpath + 1, O_WRONLY|O_CREAT|O_TRUNC, 0666); if (fd < 0) { @@ -71,21 +71,7 @@ exit(1); } dump_head_chunk(fd, head); - for (ent = head->descend; ent != 0xFFFF; ent = ch.descend) { - ch.entryno = ent; - get_index_entry(&ch); - if (ch.type != 0xF4) { - fprintf(stderr, - "file continuation object at index %x: type %02X != expected F4\n", - ent, ch.type); - exit(1); - } - validate_chunk(&ch); - dump_extra_chunk(fd, &ch); - if (ch.sibling != 0xFFFF) - printf("warning: file continuation object (index %x) has a non-nil sibling pointer\n", - ent); - } + iterate_extra_chunks(head->descend, dump_extra_chunk, (u_long) fd); close(fd); }