FreeCalypso > hg > freecalypso-reveng
diff mpffs/ls.c @ 39:9bc7f0e03fa8
iterate_extra_chunks() function written, mpffs-ls converted to use it
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jul 2013 06:49:50 +0000 |
parents | 0bf037ba4149 |
children |
line wrap: on
line diff
--- a/mpffs/ls.c Mon Jul 01 06:28:30 2013 +0000 +++ b/mpffs/ls.c Mon Jul 01 06:49:50 2013 +0000 @@ -18,34 +18,29 @@ char workpath[512]; +void +extra_chunk_callback(obj, opaque) + struct objinfo *obj; + u_long opaque; +{ + size_t *accump = (size_t *) opaque; + struct chunkinfo chi; + + size_extra_chunk(obj, &chi); + *accump += chi.len; +} + size_t get_file_size(head) struct objinfo *head; { - int ent; - struct objinfo ch; struct chunkinfo chi; size_t accum; size_head_chunk(head, &chi); accum = chi.len; - 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); - break; - } - validate_chunk(&ch); - size_extra_chunk(&ch, &chi); - accum += chi.len; - if (ch.sibling != 0xFFFF) - fprintf(stderr, -"warning: file continuation object (index %x) has a non-nil sibling pointer\n", - ent); - } + iterate_extra_chunks(head->descend, extra_chunk_callback, + (u_long) &accum); return(accum); }