1919#include <linux/buffer_head.h>
2020#include <linux/writeback.h>
2121#include <linux/statfs.h>
22- #include <linux/parser.h>
2322#include <linux/seq_file.h>
24- #include <linux/mount.h>
2523#include <linux/crc32.h>
2624#include <linux/mpage.h>
25+ #include <linux/fs_parser.h>
26+ #include <linux/fs_context.h>
2727#include "qnx6.h"
2828
2929static const struct super_operations qnx6_sops ;
3030
3131static void qnx6_put_super (struct super_block * sb );
3232static struct inode * qnx6_alloc_inode (struct super_block * sb );
3333static 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 );
3535static int qnx6_statfs (struct dentry * dentry , struct kstatfs * buf );
3636static int qnx6_show_options (struct seq_file * seq , struct dentry * root );
3737
@@ -40,7 +40,6 @@ static const struct super_operations qnx6_sops = {
4040 .free_inode = qnx6_free_inode ,
4141 .put_super = qnx6_put_super ,
4242 .statfs = qnx6_statfs ,
43- .remount_fs = qnx6_remount ,
4443 .show_options = qnx6_show_options ,
4544};
4645
@@ -54,10 +53,12 @@ static int qnx6_show_options(struct seq_file *seq, struct dentry *root)
5453 return 0 ;
5554}
5655
57- static int qnx6_remount (struct super_block * sb , int * flags , char * data )
56+ static int qnx6_reconfigure (struct fs_context * fc )
5857{
58+ struct super_block * sb = fc -> root -> d_sb ;
59+
5960 sync_filesystem (sb );
60- * flags |= SB_RDONLY ;
61+ fc -> sb_flags |= SB_RDONLY ;
6162 return 0 ;
6263}
6364
@@ -218,39 +219,36 @@ void qnx6_superblock_debug(struct qnx6_super_block *sb, struct super_block *s)
218219#endif
219220
220221enum {
221- Opt_mmifs ,
222- Opt_err
222+ Opt_mmifs
223+ };
224+
225+ struct qnx6_context {
226+ unsigned long s_mount_opts ;
223227};
224228
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+ {}
228232};
229233
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 )
231235{
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 ;
252250 }
253- return 1 ;
251+ return 0 ;
254252}
255253
256254static 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,
293291static struct inode * qnx6_private_inode (struct super_block * s ,
294292 struct qnx6_root_node * p );
295293
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 )
297295{
298296 struct buffer_head * bh1 = NULL , * bh2 = NULL ;
299297 struct qnx6_super_block * sb1 = NULL , * sb2 = NULL ;
300298 struct qnx6_sb_info * sbi ;
299+ struct qnx6_context * ctx = fc -> fs_private ;
301300 struct inode * root ;
302301 const char * errmsg ;
303302 struct qnx6_sb_info * qs ;
304303 int ret = - EINVAL ;
305304 u64 offset ;
306305 int bootblock_offset = QNX6_BOOTBLOCK_SIZE ;
306+ int silent = fc -> sb_flags & SB_SILENT ;
307307
308308 qs = kzalloc (sizeof (struct qnx6_sb_info ), GFP_KERNEL );
309309 if (!qs )
310310 return - ENOMEM ;
311311 s -> s_fs_info = qs ;
312+ qs -> s_mount_opt = ctx -> s_mount_opts ;
312313
313314 /* Superblock always is 512 Byte long */
314315 if (!sb_set_blocksize (s , QNX6_SUPERBLOCK_SIZE )) {
315316 pr_err ("unable to set blocksize\n" );
316317 goto outnobh ;
317318 }
318319
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 ) {
325321 sb1 = qnx6_mmi_fill_super (s , silent );
326322 if (sb1 )
327323 goto mmi_success ;
@@ -632,18 +628,43 @@ static void destroy_inodecache(void)
632628 kmem_cache_destroy (qnx6_inode_cachep );
633629}
634630
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 )
637637{
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 ;
639659}
640660
641661static 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 ,
647668};
648669MODULE_ALIAS_FS ("qnx6" );
649670
0 commit comments