aboutsummaryrefslogtreecommitdiffstats
path: root/fs/squashfs/super.c
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@lougher.demon.co.uk>2011-05-19 21:26:43 -0400
committerPhillip Lougher <phillip@lougher.demon.co.uk>2011-05-25 13:21:31 -0400
commit82de647e1f81fd89afc48608d889dd3b33cb8983 (patch)
tree847b7b40ed273eaa755c27bef6b1a20d201273c2 /fs/squashfs/super.c
parent117a91e0f25fd7698e20ac3dfa62086be3dc82a3 (diff)
Squashfs: move table allocation into squashfs_read_table()
This eliminates a lot of duplicate code. Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
Diffstat (limited to 'fs/squashfs/super.c')
-rw-r--r--fs/squashfs/super.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 5c8184c061a4..d16c39263f39 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -95,12 +95,6 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
95 } 95 }
96 msblk = sb->s_fs_info; 96 msblk = sb->s_fs_info;
97 97
98 sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
99 if (sblk == NULL) {
100 ERROR("Failed to allocate squashfs_super_block\n");
101 goto failure;
102 }
103
104 msblk->devblksize = sb_min_blocksize(sb, BLOCK_SIZE); 98 msblk->devblksize = sb_min_blocksize(sb, BLOCK_SIZE);
105 msblk->devblksize_log2 = ffz(~msblk->devblksize); 99 msblk->devblksize_log2 = ffz(~msblk->devblksize);
106 100
@@ -114,10 +108,12 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
114 * of bytes_used) we need to set it to an initial sensible dummy value 108 * of bytes_used) we need to set it to an initial sensible dummy value
115 */ 109 */
116 msblk->bytes_used = sizeof(*sblk); 110 msblk->bytes_used = sizeof(*sblk);
117 err = squashfs_read_table(sb, sblk, SQUASHFS_START, sizeof(*sblk)); 111 sblk = squashfs_read_table(sb, SQUASHFS_START, sizeof(*sblk));
118 112
119 if (err < 0) { 113 if (IS_ERR(sblk)) {
120 ERROR("unable to read squashfs_super_block\n"); 114 ERROR("unable to read squashfs_super_block\n");
115 err = PTR_ERR(sblk);
116 sblk = NULL;
121 goto failed_mount; 117 goto failed_mount;
122 } 118 }
123 119
@@ -222,6 +218,7 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
222 msblk->id_table = squashfs_read_id_index_table(sb, 218 msblk->id_table = squashfs_read_id_index_table(sb,
223 le64_to_cpu(sblk->id_table_start), le16_to_cpu(sblk->no_ids)); 219 le64_to_cpu(sblk->id_table_start), le16_to_cpu(sblk->no_ids));
224 if (IS_ERR(msblk->id_table)) { 220 if (IS_ERR(msblk->id_table)) {
221 ERROR("unable to read id index table\n");
225 err = PTR_ERR(msblk->id_table); 222 err = PTR_ERR(msblk->id_table);
226 msblk->id_table = NULL; 223 msblk->id_table = NULL;
227 goto failed_mount; 224 goto failed_mount;
@@ -242,6 +239,7 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
242 msblk->fragment_index = squashfs_read_fragment_index_table(sb, 239 msblk->fragment_index = squashfs_read_fragment_index_table(sb,
243 le64_to_cpu(sblk->fragment_table_start), fragments); 240 le64_to_cpu(sblk->fragment_table_start), fragments);
244 if (IS_ERR(msblk->fragment_index)) { 241 if (IS_ERR(msblk->fragment_index)) {
242 ERROR("unable to read fragment index table\n");
245 err = PTR_ERR(msblk->fragment_index); 243 err = PTR_ERR(msblk->fragment_index);
246 msblk->fragment_index = NULL; 244 msblk->fragment_index = NULL;
247 goto failed_mount; 245 goto failed_mount;
@@ -256,6 +254,7 @@ allocate_lookup_table:
256 msblk->inode_lookup_table = squashfs_read_inode_lookup_table(sb, 254 msblk->inode_lookup_table = squashfs_read_inode_lookup_table(sb,
257 lookup_table_start, msblk->inodes); 255 lookup_table_start, msblk->inodes);
258 if (IS_ERR(msblk->inode_lookup_table)) { 256 if (IS_ERR(msblk->inode_lookup_table)) {
257 ERROR("unable to read inode lookup table\n");
259 err = PTR_ERR(msblk->inode_lookup_table); 258 err = PTR_ERR(msblk->inode_lookup_table);
260 msblk->inode_lookup_table = NULL; 259 msblk->inode_lookup_table = NULL;
261 goto failed_mount; 260 goto failed_mount;
@@ -273,6 +272,7 @@ allocate_xattr_table:
273 msblk->xattr_id_table = squashfs_read_xattr_id_table(sb, 272 msblk->xattr_id_table = squashfs_read_xattr_id_table(sb,
274 xattr_id_table_start, &msblk->xattr_table, &msblk->xattr_ids); 273 xattr_id_table_start, &msblk->xattr_table, &msblk->xattr_ids);
275 if (IS_ERR(msblk->xattr_id_table)) { 274 if (IS_ERR(msblk->xattr_id_table)) {
275 ERROR("unable to read xattr id index table\n");
276 err = PTR_ERR(msblk->xattr_id_table); 276 err = PTR_ERR(msblk->xattr_id_table);
277 msblk->xattr_id_table = NULL; 277 msblk->xattr_id_table = NULL;
278 if (err != -ENOTSUPP) 278 if (err != -ENOTSUPP)
@@ -318,11 +318,6 @@ failed_mount:
318 sb->s_fs_info = NULL; 318 sb->s_fs_info = NULL;
319 kfree(sblk); 319 kfree(sblk);
320 return err; 320 return err;
321
322failure:
323 kfree(sb->s_fs_info);
324 sb->s_fs_info = NULL;
325 return -ENOMEM;
326} 321}
327 322
328 323