void read_fragment_table_2() { int i, indexes = SQUASHFS_FRAGMENT_INDEXES_2(sBlk.fragments); unsigned int fragment_table_index[indexes]; TRACE("read_fragment_table: %d fragments, reading %d fragment indexes from 0x%llx\n", sBlk.fragments, indexes, sBlk.fragment_table_start); if(sBlk.fragments == 0) return; if((fragment_table_2 = (squashfs_fragment_entry_2 *) malloc(sBlk.fragments * sizeof(squashfs_fragment_entry))) == NULL) EXIT_UNSQUASH("read_fragment_table: failed to allocate fragment table\n"); if(swap) { unsigned int sfragment_table_index[indexes]; read_bytes(sBlk.fragment_table_start, SQUASHFS_FRAGMENT_INDEX_BYTES_2(sBlk.fragments), (char *) sfragment_table_index); SQUASHFS_SWAP_FRAGMENT_INDEXES_2(fragment_table_index, sfragment_table_index, indexes); } else read_bytes(sBlk.fragment_table_start, SQUASHFS_FRAGMENT_INDEX_BYTES_2(sBlk.fragments), (char *) fragment_table_index); for(i = 0; i < indexes; i++) { int length = read_block(fragment_table_index[i], NULL, ((char *) fragment_table_2) + (i * SQUASHFS_METADATA_SIZE)); TRACE("Read fragment table block %d, from 0x%llx, length %d\n", i, fragment_table_index[i], length); } if(swap) { squashfs_fragment_entry_2 sfragment; for(i = 0; i < sBlk.fragments; i++) { SQUASHFS_SWAP_FRAGMENT_ENTRY_2((&sfragment), (&fragment_table_2[i])); memcpy((char *) &fragment_table_2[i], (char *) &sfragment, sizeof(squashfs_fragment_entry_2)); } } }
static int read_fragment_index_table_2(struct super_block *s) { struct squashfs_sb_info *msblk = s->s_fs_info; struct squashfs_super_block *sblk = &msblk->sblk; if (!(msblk->fragment_index_2 = kmalloc(SQUASHFS_FRAGMENT_INDEX_BYTES_2 (sblk->fragments), GFP_KERNEL))) { ERROR("Failed to allocate uid/gid table\n"); return 0; } if (SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments) && !squashfs_read_data(s, (char *) msblk->fragment_index_2, sblk->fragment_table_start, SQUASHFS_FRAGMENT_INDEX_BYTES_2 (sblk->fragments) | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, SQUASHFS_FRAGMENT_INDEX_BYTES_2(sblk->fragments))) { ERROR("unable to read fragment index table\n"); return 0; } if (msblk->swap) { int i; unsigned int fragment; for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES_2(sblk->fragments); i++) { SQUASHFS_SWAP_FRAGMENT_INDEXES_2((&fragment), &msblk->fragment_index_2[i], 1); msblk->fragment_index_2[i] = fragment; } } return 1; }
int read_fragment_table_2() { int res, i, indexes = SQUASHFS_FRAGMENT_INDEXES_2(sBlk.fragments); unsigned int fragment_table_index[indexes]; TRACE("read_fragment_table: %d fragments, reading %d fragment indexes " "from 0x%llx\n", sBlk.fragments, indexes, sBlk.fragment_table_start); if(sBlk.fragments == 0) return TRUE; fragment_table = malloc(sBlk.fragments * sizeof(squashfs_fragment_entry_2)); if(fragment_table == NULL) EXIT_UNSQUASH("read_fragment_table: failed to allocate " "fragment table\n"); if(swap) { unsigned int sfragment_table_index[indexes]; res = read_bytes(sBlk.fragment_table_start, SQUASHFS_FRAGMENT_INDEX_BYTES_2(sBlk.fragments), (char *) sfragment_table_index); if(res == FALSE) { ERROR("read_fragment_table: failed to read fragment " "table index\n"); return FALSE; } SQUASHFS_SWAP_FRAGMENT_INDEXES_2(fragment_table_index, sfragment_table_index, indexes); } else { res = read_bytes(sBlk.fragment_table_start, SQUASHFS_FRAGMENT_INDEX_BYTES_2(sBlk.fragments), (char *) fragment_table_index); if(res == FALSE) { ERROR("read_fragment_table: failed to read fragment " "table index\n"); return FALSE; } } for(i = 0; i < indexes; i++) { int length = read_block(fragment_table_index[i], NULL, ((char *) fragment_table) + (i * SQUASHFS_METADATA_SIZE)); TRACE("Read fragment table block %d, from 0x%x, length %d\n", i, fragment_table_index[i], length); if(length == FALSE) { ERROR("read_fragment_table: failed to read fragment " "table block\n"); return FALSE; } } if(swap) { squashfs_fragment_entry_2 sfragment; for(i = 0; i < sBlk.fragments; i++) { SQUASHFS_SWAP_FRAGMENT_ENTRY_2((&sfragment), (&fragment_table[i])); memcpy((char *) &fragment_table[i], (char *) &sfragment, sizeof(squashfs_fragment_entry_2)); } } return TRUE; }