# HG changeset patch # User Michael Spacefalcon # Date 1372575599 0 # Node ID 3cca8070ef0f7e29f29acf92c2df2d234b42c2e9 # Parent 9c3c5a572b57eb08cc95e1b550acdb1c01d89462 mpffs-ls reports file sizes diff -r 9c3c5a572b57 -r 3cca8070ef0f mpffs/common.c --- a/mpffs/common.c Sun Jun 30 06:28:58 2013 +0000 +++ b/mpffs/common.c Sun Jun 30 06:59:59 2013 +0000 @@ -311,6 +311,30 @@ exit(1); } +size_head_chunk(ch, chi) + struct objinfo *ch; + struct chunkinfo *chi; +{ + chi->start = (u8 *) index((char *)ch->dataptr, '\0') + 1; + chi->end = find_end_of_chunk(ch); + if (chi->start >= chi->end) { + chi->len = 0; + return(0); + } else { + chi->len = chi->end - chi->start; + return(1); + } +} + +size_extra_chunk(ch, chi) + struct objinfo *ch; + struct chunkinfo *chi; +{ + chi->start = ch->dataptr; + chi->end = find_end_of_chunk(ch); + chi->len = chi->end - chi->start; +} + find_root_node() { struct objinfo obj; diff -r 9c3c5a572b57 -r 3cca8070ef0f mpffs/ls.c --- a/mpffs/ls.c Sun Jun 30 06:28:58 2013 +0000 +++ b/mpffs/ls.c Sun Jun 30 06:59:59 2013 +0000 @@ -18,11 +18,35 @@ char workpath[512]; -u_long +size_t get_file_size(head) struct objinfo *head; { - return(0); /* stub, remains to be implemented */ + 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); + } + return(accum); } dump_dir(firstent, path_prefix) diff -r 9c3c5a572b57 -r 3cca8070ef0f mpffs/struct.h --- a/mpffs/struct.h Sun Jun 30 06:28:58 2013 +0000 +++ b/mpffs/struct.h Sun Jun 30 06:59:59 2013 +0000 @@ -21,3 +21,10 @@ u16 descend; u16 sibling; }; + +/* chunk location and size info */ +struct chunkinfo { + u8 *start; + u8 *end; + size_t len; +};