From: Geert U. <Gee...@so...> - 2008-08-29 13:23:52
|
From: Geert Uytterhoeven <Gee...@so...> Convert bitfields to portable structures and use proper accessors: - block_list[] Signed-off-by: Geert Uytterhoeven <Gee...@so...> --- fs/squashfs/inode.c | 57 ++++++++++++----------------------------- include/linux/squashfs_fs.h | 11 ------- include/linux/squashfs_fs_sb.h | 2 - 3 files changed, 19 insertions(+), 51 deletions(-) --- a/fs/squashfs/inode.c +++ b/fs/squashfs/inode.c @@ -48,7 +48,7 @@ static int squashfs_read_inode(struct in static int squashfs_statfs(struct dentry *, struct kstatfs *); static int squashfs_symlink_readpage(struct file *file, struct page *page); static long long read_blocklist(struct inode *inode, int index, - int readahead_blks, char *block_list, + int readahead_blks, __le32 *block_list, unsigned short **block_p, unsigned int *bsize); static int squashfs_readpage(struct file *file, struct page *page); static int squashfs_readdir(struct file *, void *, filldir_t); @@ -1402,44 +1402,23 @@ static void release_meta_index(struct in static int read_block_index(struct super_block *s, int blocks, - char *block_list, long long *start_block, + __le32 *block_list, long long *start_block, unsigned int *offset) { - unsigned int *block_listp; int block = 0; - if (SQUASHFS_SWAP_ON_READ) { - char *sblock_list; - - sblock_list = kmalloc(blocks << 2, GFP_KERNEL); - if (!sblock_list) { - ERROR("Failed to allocate temporary block list\n"); - goto failure; - } - - if (!squashfs_get_cached_block(s, sblock_list, *start_block, - *offset, blocks << 2, start_block, offset)) { - ERROR("Fail reading block list [%llx:%x]\n", - *start_block, *offset); - kfree(sblock_list); - goto failure; - } - SQUASHFS_SWAP_INTS(((unsigned int *)block_list), - ((unsigned int *)sblock_list), blocks); - kfree(sblock_list); - } else { - if (!squashfs_get_cached_block(s, block_list, *start_block, - *offset, blocks << 2, - start_block, offset)) { - ERROR("Fail reading block list [%llx:%x]\n", - *start_block, *offset); - goto failure; - } + if (!squashfs_get_cached_block(s, block_list, *start_block, *offset, + blocks << 2, start_block, offset)) { + ERROR("Fail reading block list [%llx:%x]\n", + *start_block, *offset); + goto failure; } - for (block_listp = (unsigned int *) block_list; blocks; - block_listp++, blocks--) - block += SQUASHFS_COMPRESSED_SIZE_BLOCK(*block_listp); + while (blocks-- > 0) { + block += + SQUASHFS_COMPRESSED_SIZE_BLOCK(le32_to_cpu(*block_list)); + block_list++; + } return block; @@ -1461,7 +1440,7 @@ static inline int calculate_skip(int blo static int get_meta_index(struct inode *inode, int index, long long *index_block, unsigned int *index_offset, - long long *data_block, char *block_list) + long long *data_block, __le32 *block_list) { struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; struct squashfs_super_block *sblk = &msblk->sblk; @@ -1553,14 +1532,14 @@ failed: static long long read_blocklist(struct inode *inode, int index, - int readahead_blks, char *block_list, + int readahead_blks, __le32 *block_list, unsigned short **block_p, unsigned int *bsize) { long long block_ptr; unsigned int offset; long long block; int res = get_meta_index(inode, index, &block_ptr, &offset, &block, - block_list); + block_list); TRACE("read_blocklist: res %d, index %d, block_ptr 0x%llx, offset" " 0x%x, block 0x%llx\n", res, index, block_ptr, offset, block); @@ -1583,7 +1562,7 @@ static long long read_blocklist(struct i if (read_block_index(inode->i_sb, 1, block_list, &block_ptr, &offset) == -1) goto failure; - *bsize = *((unsigned int *) block_list); + *bsize = le32_to_cpu(*block_list); return block; @@ -1597,7 +1576,7 @@ static int squashfs_readpage(struct file struct inode *inode = page->mapping->host; struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info; struct squashfs_super_block *sblk = &msblk->sblk; - unsigned char *block_list = NULL; + __le32 *block_list = NULL; long long block; unsigned int bsize, i; int bytes; @@ -2091,7 +2070,7 @@ static int __init init_squashfs_fs(void) goto out; printk(KERN_INFO "squashfs: version 3.4 (2008/08/26) " - "Phillip Lougher (step2-arrays)\n"); + "Phillip Lougher (step2-block_list)\n"); err = register_filesystem(&squashfs_fs_type); if (err) --- a/include/linux/squashfs_fs.h +++ b/include/linux/squashfs_fs.h @@ -361,17 +361,6 @@ extern int squashfs_uncompress_exit(void * */ -#define SQUASHFS_SWAP_INTS(s, d, n) {\ - int entry;\ - int bit_position;\ - SQUASHFS_SWAP_START\ - SQUASHFS_MEMSET(s, d, n * 4);\ - for (entry = 0, bit_position = 0; entry < n; \ - entry++, bit_position += 32)\ - SQUASHFS_SWAP(s[entry], d, bit_position, 32);\ -} - - #ifdef __KERNEL__ /* --- a/include/linux/squashfs_fs_sb.h +++ b/include/linux/squashfs_fs_sb.h @@ -69,7 +69,7 @@ struct squashfs_sb_info { __le64 *inode_lookup_table; int (*read_inode)(struct inode *i, squashfs_inode_t inode); long long (*read_blocklist)(struct inode *inode, int index, - int readahead_blks, char *block_list, + int readahead_blks, __le32 *block_list, unsigned short **block_p, unsigned int *bsize); int (*read_fragment_index_table)(struct super_block *s); -- With kind regards, Geert Uytterhoeven Software Architect Sony Techsoft Centre Europe The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium Phone: +32 (0)2 700 8453 Fax: +32 (0)2 700 8622 E-mail: Gee...@so... Internet: http://www.sony-europe.com/ A division of Sony Europe (Belgium) N.V. VAT BE 0413.825.160 · RPR Brussels Fortis · BIC GEBABEBB · IBAN BE41293037680010 |