6565#include <linux/slab.h>
6666#include <linux/init.h>
6767#include <linux/blkdev.h>
68- #include <linux/parser .h>
68+ #include <linux/fs_context .h>
6969#include <linux/mount.h>
7070#include <linux/namei.h>
7171#include <linux/statfs.h>
@@ -423,18 +423,17 @@ static int romfs_statfs(struct dentry *dentry, struct kstatfs *buf)
423423/*
424424 * remounting must involve read-only
425425 */
426- static int romfs_remount (struct super_block * sb , int * flags , char * data )
426+ static int romfs_reconfigure (struct fs_context * fc )
427427{
428- sync_filesystem (sb );
429- * flags |= SB_RDONLY ;
428+ sync_filesystem (fc -> root -> d_sb );
429+ fc -> sb_flags |= SB_RDONLY ;
430430 return 0 ;
431431}
432432
433433static const struct super_operations romfs_super_ops = {
434434 .alloc_inode = romfs_alloc_inode ,
435435 .free_inode = romfs_free_inode ,
436436 .statfs = romfs_statfs ,
437- .remount_fs = romfs_remount ,
438437};
439438
440439/*
@@ -457,7 +456,7 @@ static __u32 romfs_checksum(const void *data, int size)
457456/*
458457 * fill in the superblock
459458 */
460- static int romfs_fill_super (struct super_block * sb , void * data , int silent )
459+ static int romfs_fill_super (struct super_block * sb , struct fs_context * fc )
461460{
462461 struct romfs_super_block * rsb ;
463462 struct inode * root ;
@@ -504,8 +503,8 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
504503
505504 if (rsb -> word0 != ROMSB_WORD0 || rsb -> word1 != ROMSB_WORD1 ||
506505 img_size < ROMFH_SIZE ) {
507- if (!silent )
508- pr_warn ( "VFS: Can't find a romfs filesystem on dev %s.\n" ,
506+ if (!( fc -> sb_flags & SB_SILENT ) )
507+ errorf ( fc , "VFS: Can't find a romfs filesystem on dev %s.\n" ,
509508 sb -> s_id );
510509 goto error_rsb_inval ;
511510 }
@@ -518,7 +517,7 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
518517 storage = sb -> s_mtd ? "MTD" : "the block layer" ;
519518
520519 len = strnlen (rsb -> name , ROMFS_MAXFN );
521- if (!silent )
520+ if (!( fc -> sb_flags & SB_SILENT ) )
522521 pr_notice ("Mounting image '%*.*s' through %s\n" ,
523522 (unsigned ) len , (unsigned ) len , rsb -> name , storage );
524523
@@ -548,23 +547,34 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
548547/*
549548 * get a superblock for mounting
550549 */
551- static struct dentry * romfs_mount (struct file_system_type * fs_type ,
552- int flags , const char * dev_name ,
553- void * data )
550+ static int romfs_get_tree (struct fs_context * fc )
554551{
555- struct dentry * ret = ERR_PTR ( - EINVAL ) ;
552+ int ret = - EINVAL ;
556553
557554#ifdef CONFIG_ROMFS_ON_MTD
558- ret = mount_mtd ( fs_type , flags , dev_name , data , romfs_fill_super );
555+ ret = get_tree_mtd ( fc , romfs_fill_super );
559556#endif
560557#ifdef CONFIG_ROMFS_ON_BLOCK
561- if (ret == ERR_PTR (- EINVAL ))
562- ret = mount_bdev (fs_type , flags , dev_name , data ,
563- romfs_fill_super );
558+ if (ret == - EINVAL )
559+ ret = get_tree_bdev (fc , romfs_fill_super );
564560#endif
565561 return ret ;
566562}
567563
564+ static const struct fs_context_operations romfs_context_ops = {
565+ .get_tree = romfs_get_tree ,
566+ .reconfigure = romfs_reconfigure ,
567+ };
568+
569+ /*
570+ * Set up the filesystem mount context.
571+ */
572+ static int romfs_init_fs_context (struct fs_context * fc )
573+ {
574+ fc -> ops = & romfs_context_ops ;
575+ return 0 ;
576+ }
577+
568578/*
569579 * destroy a romfs superblock in the appropriate manner
570580 */
@@ -587,7 +597,7 @@ static void romfs_kill_sb(struct super_block *sb)
587597static struct file_system_type romfs_fs_type = {
588598 .owner = THIS_MODULE ,
589599 .name = "romfs" ,
590- .mount = romfs_mount ,
600+ .init_fs_context = romfs_init_fs_context ,
591601 .kill_sb = romfs_kill_sb ,
592602 .fs_flags = FS_REQUIRES_DEV ,
593603};
0 commit comments