From: Geert U. <Gee...@so...> - 2008-08-29 13:23:48
|
From: Geert Uytterhoeven <Gee...@so...> Convert bitfields to portable structures and use proper accessors: - squashfs_sb_info.fragment_index[] - squashfs_sb_info.inode_lookup_table[] - squashfs_sb_info.uid[] - squashfs_sb_info.guid[] Signed-off-by: Geert Uytterhoeven <Gee...@so...> --- fs/squashfs/inode.c | 77 ++++++----------------------------------- include/linux/squashfs_fs.h | 35 ------------------ include/linux/squashfs_fs_sb.h | 8 ++-- 3 files changed, 17 insertions(+), 103 deletions(-) --- a/fs/squashfs/inode.c +++ b/fs/squashfs/inode.c @@ -576,8 +576,8 @@ static int get_fragment_location(struct unsigned int *fragment_size) { struct squashfs_sb_info *msblk = s->s_fs_info; - long long start_block = - msblk->fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)]; + long long start_block = le64_to_cpu(msblk-> + fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)]); unsigned int offset = SQUASHFS_FRAGMENT_INDEX_OFFSET(fragment); struct squashfs_fragment_entry fragment_entry; @@ -618,22 +618,22 @@ static void squashfs_new_inode(struct sq i->i_mtime.tv_sec = le32_to_cpu(inodeb->mtime); i->i_atime.tv_sec = i->i_mtime.tv_sec; i->i_ctime.tv_sec = i->i_mtime.tv_sec; - i->i_uid = msblk->uid[inodeb->uid]; + i->i_uid = le32_to_cpu(msblk->uid[inodeb->uid]); i->i_mode = le16_to_cpu(inodeb->inode_type_mode) >> 4; i->i_size = 0; if (inodeb->guid == SQUASHFS_GUIDS) i->i_gid = i->i_uid; else - i->i_gid = msblk->guid[inodeb->guid]; + i->i_gid = le32_to_cpu(msblk->guid[inodeb->guid]); } static squashfs_inode_t squashfs_inode_lookup(struct super_block *s, int ino) { struct squashfs_sb_info *msblk = s->s_fs_info; - long long start = - msblk->inode_lookup_table[SQUASHFS_LOOKUP_BLOCK(ino - 1)]; + long long start = le64_to_cpu(msblk-> + inode_lookup_table[SQUASHFS_LOOKUP_BLOCK(ino - 1)]); unsigned int offset = SQUASHFS_LOOKUP_BLOCK_OFFSET(ino - 1); __le64 raw_inode; squashfs_inode_t inode; @@ -993,18 +993,6 @@ static int read_inode_lookup_table(struc return 0; } - if (SQUASHFS_SWAP_ON_READ) { - int i; - long long block; - - for (i = 0; i < SQUASHFS_LOOKUP_BLOCKS(inodes); i++) { - /* XXX */ - SQUASHFS_SWAP_LOOKUP_BLOCKS((&block), - &msblk->inode_lookup_table[i], 1); - msblk->inode_lookup_table[i] = block; - } - } - return 1; } @@ -1034,19 +1022,6 @@ static int read_fragment_index_table(str return 0; } - if (SQUASHFS_SWAP_ON_READ) { - int i; - long long fragment; - - for (i = 0; i < SQUASHFS_FRAGMENT_INDEXES(fragments); - i++) { - /* XXX */ - SQUASHFS_SWAP_FRAGMENT_INDEXES((&fragment), - &msblk->fragment_index[i], 1); - msblk->fragment_index[i] = fragment; - } - } - return 1; } @@ -1200,40 +1175,14 @@ static int squashfs_fill_super(struct su } msblk->guid = msblk->uid + sblk->no_uids; - if (SQUASHFS_SWAP_ON_READ) { - unsigned int *suid; - - suid = kmalloc(id_tab_size, GFP_KERNEL); - if (!suid) { - ERROR("Failed to allocate temporary uid/gid table\n"); - goto failed_mount; - } - - if (!squashfs_read_data(s, suid, le64_to_cpu(sblk->uid_start), - id_tab_size | - SQUASHFS_COMPRESSED_BIT_BLOCK, - NULL, id_tab_size)) { - ERROR("unable to read uid/gid table\n"); - kfree(suid); - goto failed_mount; - } - - SQUASHFS_SWAP_DATA(msblk->uid, suid, - (sblk->no_uids + sblk->no_guids), - sizeof(unsigned int) * 8); - kfree(suid); - } else { - if (!squashfs_read_data(s, msblk->uid, - le64_to_cpu(sblk->uid_start), - id_tab_size | - SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, - id_tab_size)) { - ERROR("unable to read uid/gid table\n"); - goto failed_mount; - } + if (!squashfs_read_data(s, msblk->uid, + le64_to_cpu(sblk->uid_start), + id_tab_size | SQUASHFS_COMPRESSED_BIT_BLOCK, + NULL, id_tab_size)) { + ERROR("unable to read uid/gid table\n"); + goto failed_mount; } - msblk->fragment_cache = squashfs_cache_init("fragment", SQUASHFS_CACHED_FRAGMENTS, block_size, 1); @@ -2142,7 +2091,7 @@ static int __init init_squashfs_fs(void) goto out; printk(KERN_INFO "squashfs: version 3.4 (2008/08/26) " - "Phillip Lougher (step2-squashfs_inode_t)\n"); + "Phillip Lougher (step2-arrays)\n"); err = register_filesystem(&squashfs_fs_type); if (err) --- a/include/linux/squashfs_fs.h +++ b/include/linux/squashfs_fs.h @@ -361,16 +361,6 @@ extern int squashfs_uncompress_exit(void * */ -#define SQUASHFS_SWAP_SHORTS(s, d, n) {\ - int entry;\ - int bit_position;\ - SQUASHFS_SWAP_START\ - SQUASHFS_MEMSET(s, d, n * 2);\ - for (entry = 0, bit_position = 0; entry < n; \ - entry++, bit_position += 16)\ - SQUASHFS_SWAP(s[entry], d, bit_position, 16);\ -} - #define SQUASHFS_SWAP_INTS(s, d, n) {\ int entry;\ int bit_position;\ @@ -381,31 +371,6 @@ extern int squashfs_uncompress_exit(void SQUASHFS_SWAP(s[entry], d, bit_position, 32);\ } -#define SQUASHFS_SWAP_LONG_LONGS(s, d, n) {\ - int entry;\ - int bit_position;\ - SQUASHFS_SWAP_START\ - SQUASHFS_MEMSET(s, d, n * 8);\ - for (entry = 0, bit_position = 0; entry < n; \ - entry++, bit_position += 64)\ - SQUASHFS_SWAP(s[entry], d, bit_position, 64);\ -} - -#define SQUASHFS_SWAP_DATA(s, d, n, bits) {\ - int entry;\ - int bit_position;\ - SQUASHFS_SWAP_START\ - SQUASHFS_MEMSET(s, d, n * bits / 8);\ - for (entry = 0, bit_position = 0; entry < n; \ - entry++, bit_position += bits)\ - SQUASHFS_SWAP(s[entry], d, bit_position, bits);\ -} - -#define SQUASHFS_SWAP_FRAGMENT_INDEXES(s, d, n) \ - SQUASHFS_SWAP_LONG_LONGS(s, d, n) -#define SQUASHFS_SWAP_LOOKUP_BLOCKS(s, d, n) \ - SQUASHFS_SWAP_LONG_LONGS(s, d, n) - #ifdef __KERNEL__ --- a/include/linux/squashfs_fs_sb.h +++ b/include/linux/squashfs_fs_sb.h @@ -57,16 +57,16 @@ struct squashfs_sb_info { struct squashfs_cache *block_cache; struct squashfs_cache *fragment_cache; int next_meta_index; - unsigned int *uid; - unsigned int *guid; - long long *fragment_index; + __le32 *uid; + __le32 *guid; + __le64 *fragment_index; char *read_page; struct mutex read_data_mutex; struct mutex read_page_mutex; struct mutex meta_index_mutex; struct meta_index *meta_index; z_stream stream; - long long *inode_lookup_table; + __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, -- 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 |