2727
2828static const struct super_operations qnx4_sops ;
2929
30- static void qnx4_put_super (struct super_block * sb );
3130static struct inode * qnx4_alloc_inode (struct super_block * sb );
3231static void qnx4_destroy_inode (struct inode * inode );
3332static int qnx4_remount (struct super_block * sb , int * flags , char * data );
@@ -37,7 +36,6 @@ static const struct super_operations qnx4_sops =
3736{
3837 .alloc_inode = qnx4_alloc_inode ,
3938 .destroy_inode = qnx4_destroy_inode ,
40- .put_super = qnx4_put_super ,
4139 .statfs = qnx4_statfs ,
4240 .remount_fs = qnx4_remount ,
4341};
@@ -148,18 +146,19 @@ static int qnx4_statfs(struct dentry *dentry, struct kstatfs *buf)
148146 * it really _is_ a qnx4 filesystem, and to check the size
149147 * of the directory entry.
150148 */
151- static const char * qnx4_checkroot (struct super_block * sb )
149+ static const char * qnx4_checkroot (struct super_block * sb ,
150+ struct qnx4_super_block * s )
152151{
153152 struct buffer_head * bh ;
154153 struct qnx4_inode_entry * rootdir ;
155154 int rd , rl ;
156155 int i , j ;
157156
158- if (* ( qnx4_sb ( sb ) -> sb -> RootDir .di_fname ) != '/ ' )
157+ if (s -> RootDir . di_fname [ 0 ] != '/' || s -> RootDir .di_fname [ 1 ] != '\0 ' )
159158 return "no qnx4 filesystem (no root dir)." ;
160159 QNX4DEBUG ((KERN_NOTICE "QNX4 filesystem found on dev %s.\n" , sb -> s_id ));
161- rd = le32_to_cpu (qnx4_sb ( sb ) -> sb -> RootDir .di_first_xtnt .xtnt_blk ) - 1 ;
162- rl = le32_to_cpu (qnx4_sb ( sb ) -> sb -> RootDir .di_first_xtnt .xtnt_size );
160+ rd = le32_to_cpu (s -> RootDir .di_first_xtnt .xtnt_blk ) - 1 ;
161+ rl = le32_to_cpu (s -> RootDir .di_first_xtnt .xtnt_size );
163162 for (j = 0 ; j < rl ; j ++ ) {
164163 bh = sb_bread (sb , rd + j ); /* root dir, first block */
165164 if (bh == NULL )
@@ -189,7 +188,6 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
189188 struct inode * root ;
190189 const char * errmsg ;
191190 struct qnx4_sb_info * qs ;
192- int ret = - EINVAL ;
193191
194192 qs = kzalloc (sizeof (struct qnx4_sb_info ), GFP_KERNEL );
195193 if (!qs )
@@ -198,67 +196,50 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
198196
199197 sb_set_blocksize (s , QNX4_BLOCK_SIZE );
200198
199+ s -> s_op = & qnx4_sops ;
200+ s -> s_magic = QNX4_SUPER_MAGIC ;
201+ s -> s_flags |= MS_RDONLY ; /* Yup, read-only yet */
202+
201203 /* Check the superblock signature. Since the qnx4 code is
202204 dangerous, we should leave as quickly as possible
203205 if we don't belong here... */
204206 bh = sb_bread (s , 1 );
205207 if (!bh ) {
206208 printk (KERN_ERR "qnx4: unable to read the superblock\n" );
207- goto outnobh ;
209+ return - EINVAL ;
208210 }
209- if ( le32_to_cpup ((__le32 * ) bh -> b_data ) != QNX4_SUPER_MAGIC ) {
210- if (!silent )
211- printk (KERN_ERR "qnx4: wrong fsid in superblock.\n" );
212- goto out ;
213- }
214- s -> s_op = & qnx4_sops ;
215- s -> s_magic = QNX4_SUPER_MAGIC ;
216- s -> s_flags |= MS_RDONLY ; /* Yup, read-only yet */
217- qnx4_sb (s )-> sb_buf = bh ;
218- qnx4_sb (s )-> sb = (struct qnx4_super_block * ) bh -> b_data ;
219-
220211
221212 /* check before allocating dentries, inodes, .. */
222- errmsg = qnx4_checkroot (s );
213+ errmsg = qnx4_checkroot (s , (struct qnx4_super_block * ) bh -> b_data );
214+ brelse (bh );
223215 if (errmsg != NULL ) {
224216 if (!silent )
225217 printk (KERN_ERR "qnx4: %s\n" , errmsg );
226- goto out ;
218+ return - EINVAL ;
227219 }
228220
229221 /* does root not have inode number QNX4_ROOT_INO ?? */
230222 root = qnx4_iget (s , QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK );
231223 if (IS_ERR (root )) {
232224 printk (KERN_ERR "qnx4: get inode failed\n" );
233- ret = PTR_ERR (root );
234- goto outb ;
225+ return PTR_ERR (root );
235226 }
236227
237- ret = - ENOMEM ;
238228 s -> s_root = d_make_root (root );
239229 if (s -> s_root == NULL )
240- goto outb ;
230+ return - ENOMEM ;
241231
242- brelse (bh );
243232 return 0 ;
244-
245- outb :
246- kfree (qs -> BitMap );
247- out :
248- brelse (bh );
249- outnobh :
250- kfree (qs );
251- s -> s_fs_info = NULL ;
252- return ret ;
253233}
254234
255- static void qnx4_put_super (struct super_block * sb )
235+ static void qnx4_kill_sb (struct super_block * sb )
256236{
257237 struct qnx4_sb_info * qs = qnx4_sb (sb );
258- kfree ( qs -> BitMap );
259- kfree ( qs );
260- sb -> s_fs_info = NULL ;
261- return ;
238+ kill_block_super (sb );
239+ if (qs ) {
240+ kfree (qs -> BitMap );
241+ kfree (qs );
242+ }
262243}
263244
264245static int qnx4_readpage (struct file * file , struct page * page )
@@ -409,7 +390,7 @@ static struct file_system_type qnx4_fs_type = {
409390 .owner = THIS_MODULE ,
410391 .name = "qnx4" ,
411392 .mount = qnx4_mount ,
412- .kill_sb = kill_block_super ,
393+ .kill_sb = qnx4_kill_sb ,
413394 .fs_flags = FS_REQUIRES_DEV ,
414395};
415396MODULE_ALIAS_FS ("qnx4" );
0 commit comments