19
19
#include <linux/buffer_head.h>
20
20
#include <linux/writeback.h>
21
21
#include <linux/statfs.h>
22
- #include <linux/parser.h>
23
22
#include <linux/seq_file.h>
24
- #include <linux/mount.h>
25
23
#include <linux/crc32.h>
26
24
#include <linux/mpage.h>
25
+ #include <linux/fs_parser.h>
26
+ #include <linux/fs_context.h>
27
27
#include "qnx6.h"
28
28
29
29
static const struct super_operations qnx6_sops ;
30
30
31
31
static void qnx6_put_super (struct super_block * sb );
32
32
static struct inode * qnx6_alloc_inode (struct super_block * sb );
33
33
static void qnx6_free_inode (struct inode * inode );
34
- static int qnx6_remount (struct super_block * sb , int * flags , char * data );
34
+ static int qnx6_reconfigure (struct fs_context * fc );
35
35
static int qnx6_statfs (struct dentry * dentry , struct kstatfs * buf );
36
36
static int qnx6_show_options (struct seq_file * seq , struct dentry * root );
37
37
@@ -40,7 +40,6 @@ static const struct super_operations qnx6_sops = {
40
40
.free_inode = qnx6_free_inode ,
41
41
.put_super = qnx6_put_super ,
42
42
.statfs = qnx6_statfs ,
43
- .remount_fs = qnx6_remount ,
44
43
.show_options = qnx6_show_options ,
45
44
};
46
45
@@ -54,10 +53,12 @@ static int qnx6_show_options(struct seq_file *seq, struct dentry *root)
54
53
return 0 ;
55
54
}
56
55
57
- static int qnx6_remount (struct super_block * sb , int * flags , char * data )
56
+ static int qnx6_reconfigure (struct fs_context * fc )
58
57
{
58
+ struct super_block * sb = fc -> root -> d_sb ;
59
+
59
60
sync_filesystem (sb );
60
- * flags |= SB_RDONLY ;
61
+ fc -> sb_flags |= SB_RDONLY ;
61
62
return 0 ;
62
63
}
63
64
@@ -218,39 +219,36 @@ void qnx6_superblock_debug(struct qnx6_super_block *sb, struct super_block *s)
218
219
#endif
219
220
220
221
enum {
221
- Opt_mmifs ,
222
- Opt_err
222
+ Opt_mmifs
223
+ };
224
+
225
+ struct qnx6_context {
226
+ unsigned long s_mount_opts ;
223
227
};
224
228
225
- static const match_table_t tokens = {
226
- { Opt_mmifs , "mmi_fs" } ,
227
- {Opt_err , NULL }
229
+ static const struct fs_parameter_spec qnx6_param_spec [] = {
230
+ fsparam_flag ( "mmi_fs" , Opt_mmifs ) ,
231
+ {}
228
232
};
229
233
230
- static int qnx6_parse_options ( char * options , struct super_block * sb )
234
+ static int qnx6_parse_param ( struct fs_context * fc , struct fs_parameter * param )
231
235
{
232
- char * p ;
233
- struct qnx6_sb_info * sbi = QNX6_SB (sb );
234
- substring_t args [MAX_OPT_ARGS ];
235
-
236
- if (!options )
237
- return 1 ;
238
-
239
- while ((p = strsep (& options , "," )) != NULL ) {
240
- int token ;
241
- if (!* p )
242
- continue ;
243
-
244
- token = match_token (p , tokens , args );
245
- switch (token ) {
246
- case Opt_mmifs :
247
- set_opt (sbi -> s_mount_opt , MMI_FS );
248
- break ;
249
- default :
250
- return 0 ;
251
- }
236
+ struct qnx6_context * ctx = fc -> fs_private ;
237
+ struct fs_parse_result result ;
238
+ int opt ;
239
+
240
+ opt = fs_parse (fc , qnx6_param_spec , param , & result );
241
+ if (opt < 0 )
242
+ return opt ;
243
+
244
+ switch (opt ) {
245
+ case Opt_mmifs :
246
+ ctx -> s_mount_opts |= QNX6_MOUNT_MMI_FS ;
247
+ break ;
248
+ default :
249
+ return - EINVAL ;
252
250
}
253
- return 1 ;
251
+ return 0 ;
254
252
}
255
253
256
254
static struct buffer_head * qnx6_check_first_superblock (struct super_block * s ,
@@ -293,35 +291,33 @@ static struct buffer_head *qnx6_check_first_superblock(struct super_block *s,
293
291
static struct inode * qnx6_private_inode (struct super_block * s ,
294
292
struct qnx6_root_node * p );
295
293
296
- static int qnx6_fill_super (struct super_block * s , void * data , int silent )
294
+ static int qnx6_fill_super (struct super_block * s , struct fs_context * fc )
297
295
{
298
296
struct buffer_head * bh1 = NULL , * bh2 = NULL ;
299
297
struct qnx6_super_block * sb1 = NULL , * sb2 = NULL ;
300
298
struct qnx6_sb_info * sbi ;
299
+ struct qnx6_context * ctx = fc -> fs_private ;
301
300
struct inode * root ;
302
301
const char * errmsg ;
303
302
struct qnx6_sb_info * qs ;
304
303
int ret = - EINVAL ;
305
304
u64 offset ;
306
305
int bootblock_offset = QNX6_BOOTBLOCK_SIZE ;
306
+ int silent = fc -> sb_flags & SB_SILENT ;
307
307
308
308
qs = kzalloc (sizeof (struct qnx6_sb_info ), GFP_KERNEL );
309
309
if (!qs )
310
310
return - ENOMEM ;
311
311
s -> s_fs_info = qs ;
312
+ qs -> s_mount_opt = ctx -> s_mount_opts ;
312
313
313
314
/* Superblock always is 512 Byte long */
314
315
if (!sb_set_blocksize (s , QNX6_SUPERBLOCK_SIZE )) {
315
316
pr_err ("unable to set blocksize\n" );
316
317
goto outnobh ;
317
318
}
318
319
319
- /* parse the mount-options */
320
- if (!qnx6_parse_options ((char * ) data , s )) {
321
- pr_err ("invalid mount options.\n" );
322
- goto outnobh ;
323
- }
324
- if (test_opt (s , MMI_FS )) {
320
+ if (qs -> s_mount_opt == QNX6_MOUNT_MMI_FS ) {
325
321
sb1 = qnx6_mmi_fill_super (s , silent );
326
322
if (sb1 )
327
323
goto mmi_success ;
@@ -632,18 +628,43 @@ static void destroy_inodecache(void)
632
628
kmem_cache_destroy (qnx6_inode_cachep );
633
629
}
634
630
635
- static struct dentry * qnx6_mount (struct file_system_type * fs_type ,
636
- int flags , const char * dev_name , void * data )
631
+ static int qnx6_get_tree (struct fs_context * fc )
632
+ {
633
+ return get_tree_bdev (fc , qnx6_fill_super );
634
+ }
635
+
636
+ static void qnx6_free_fc (struct fs_context * fc )
637
637
{
638
- return mount_bdev (fs_type , flags , dev_name , data , qnx6_fill_super );
638
+ kfree (fc -> fs_private );
639
+ }
640
+
641
+ static const struct fs_context_operations qnx6_context_ops = {
642
+ .parse_param = qnx6_parse_param ,
643
+ .get_tree = qnx6_get_tree ,
644
+ .reconfigure = qnx6_reconfigure ,
645
+ .free = qnx6_free_fc ,
646
+ };
647
+
648
+ static int qnx6_init_fs_context (struct fs_context * fc )
649
+ {
650
+ struct qnx6_context * ctx ;
651
+
652
+ ctx = kzalloc (sizeof (struct qnx6_context ), GFP_KERNEL );
653
+ if (!ctx )
654
+ return - ENOMEM ;
655
+ fc -> ops = & qnx6_context_ops ;
656
+ fc -> fs_private = ctx ;
657
+
658
+ return 0 ;
639
659
}
640
660
641
661
static struct file_system_type qnx6_fs_type = {
642
- .owner = THIS_MODULE ,
643
- .name = "qnx6" ,
644
- .mount = qnx6_mount ,
645
- .kill_sb = kill_block_super ,
646
- .fs_flags = FS_REQUIRES_DEV ,
662
+ .owner = THIS_MODULE ,
663
+ .name = "qnx6" ,
664
+ .kill_sb = kill_block_super ,
665
+ .fs_flags = FS_REQUIRES_DEV ,
666
+ .init_fs_context = qnx6_init_fs_context ,
667
+ .parameters = qnx6_param_spec ,
647
668
};
648
669
MODULE_ALIAS_FS ("qnx6" );
649
670
0 commit comments