24
24
#include <linux/blkdev.h>
25
25
#include <linux/mtd/mtd.h>
26
26
#include <linux/mtd/super.h>
27
+ #include <linux/fs_context.h>
27
28
#include <linux/slab.h>
28
29
#include <linux/vfs.h>
29
30
#include <linux/mutex.h>
@@ -506,18 +507,19 @@ static void cramfs_kill_sb(struct super_block *sb)
506
507
kfree (sbi );
507
508
}
508
509
509
- static int cramfs_remount (struct super_block * sb , int * flags , char * data )
510
+ static int cramfs_reconfigure (struct fs_context * fc )
510
511
{
511
- sync_filesystem (sb );
512
- * flags |= SB_RDONLY ;
512
+ sync_filesystem (fc -> root -> d_sb );
513
+ fc -> sb_flags |= SB_RDONLY ;
513
514
return 0 ;
514
515
}
515
516
516
- static int cramfs_read_super (struct super_block * sb ,
517
- struct cramfs_super * super , int silent )
517
+ static int cramfs_read_super (struct super_block * sb , struct fs_context * fc ,
518
+ struct cramfs_super * super )
518
519
{
519
520
struct cramfs_sb_info * sbi = CRAMFS_SB (sb );
520
521
unsigned long root_offset ;
522
+ bool silent = fc -> sb_flags & SB_SILENT ;
521
523
522
524
/* We don't know the real size yet */
523
525
sbi -> size = PAGE_SIZE ;
@@ -532,7 +534,7 @@ static int cramfs_read_super(struct super_block *sb,
532
534
/* check for wrong endianness */
533
535
if (super -> magic == CRAMFS_MAGIC_WEND ) {
534
536
if (!silent )
535
- pr_err ( " wrong endianness\n " );
537
+ errorf ( fc , "cramfs: wrong endianness" );
536
538
return - EINVAL ;
537
539
}
538
540
@@ -544,22 +546,22 @@ static int cramfs_read_super(struct super_block *sb,
544
546
mutex_unlock (& read_mutex );
545
547
if (super -> magic != CRAMFS_MAGIC ) {
546
548
if (super -> magic == CRAMFS_MAGIC_WEND && !silent )
547
- pr_err ( " wrong endianness\n " );
549
+ errorf ( fc , "cramfs: wrong endianness" );
548
550
else if (!silent )
549
- pr_err ( " wrong magic\n " );
551
+ errorf ( fc , "cramfs: wrong magic" );
550
552
return - EINVAL ;
551
553
}
552
554
}
553
555
554
556
/* get feature flags first */
555
557
if (super -> flags & ~CRAMFS_SUPPORTED_FLAGS ) {
556
- pr_err ( " unsupported filesystem features\n " );
558
+ errorf ( fc , "cramfs: unsupported filesystem features" );
557
559
return - EINVAL ;
558
560
}
559
561
560
562
/* Check that the root inode is in a sane state */
561
563
if (!S_ISDIR (super -> root .mode )) {
562
- pr_err ( " root is not a directory\n " );
564
+ errorf ( fc , "cramfs: root is not a directory" );
563
565
return - EINVAL ;
564
566
}
565
567
/* correct strange, hard-coded permissions of mkcramfs */
@@ -578,12 +580,12 @@ static int cramfs_read_super(struct super_block *sb,
578
580
sbi -> magic = super -> magic ;
579
581
sbi -> flags = super -> flags ;
580
582
if (root_offset == 0 )
581
- pr_info ( " empty filesystem" );
583
+ infof ( fc , "cramfs: empty filesystem" );
582
584
else if (!(super -> flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET ) &&
583
585
((root_offset != sizeof (struct cramfs_super )) &&
584
586
(root_offset != 512 + sizeof (struct cramfs_super ))))
585
587
{
586
- pr_err ( " bad root offset %lu\n " , root_offset );
588
+ errorf ( fc , "cramfs: bad root offset %lu" , root_offset );
587
589
return - EINVAL ;
588
590
}
589
591
@@ -607,8 +609,7 @@ static int cramfs_finalize_super(struct super_block *sb,
607
609
return 0 ;
608
610
}
609
611
610
- static int cramfs_blkdev_fill_super (struct super_block * sb , void * data ,
611
- int silent )
612
+ static int cramfs_blkdev_fill_super (struct super_block * sb , struct fs_context * fc )
612
613
{
613
614
struct cramfs_sb_info * sbi ;
614
615
struct cramfs_super super ;
@@ -623,14 +624,13 @@ static int cramfs_blkdev_fill_super(struct super_block *sb, void *data,
623
624
for (i = 0 ; i < READ_BUFFERS ; i ++ )
624
625
buffer_blocknr [i ] = -1 ;
625
626
626
- err = cramfs_read_super (sb , & super , silent );
627
+ err = cramfs_read_super (sb , fc , & super );
627
628
if (err )
628
629
return err ;
629
630
return cramfs_finalize_super (sb , & super .root );
630
631
}
631
632
632
- static int cramfs_mtd_fill_super (struct super_block * sb , void * data ,
633
- int silent )
633
+ static int cramfs_mtd_fill_super (struct super_block * sb , struct fs_context * fc )
634
634
{
635
635
struct cramfs_sb_info * sbi ;
636
636
struct cramfs_super super ;
@@ -652,7 +652,7 @@ static int cramfs_mtd_fill_super(struct super_block *sb, void *data,
652
652
653
653
pr_info ("checking physical address %pap for linear cramfs image\n" ,
654
654
& sbi -> linear_phys_addr );
655
- err = cramfs_read_super (sb , & super , silent );
655
+ err = cramfs_read_super (sb , fc , & super );
656
656
if (err )
657
657
return err ;
658
658
@@ -947,32 +947,41 @@ static const struct inode_operations cramfs_dir_inode_operations = {
947
947
};
948
948
949
949
static const struct super_operations cramfs_ops = {
950
- .remount_fs = cramfs_remount ,
951
950
.statfs = cramfs_statfs ,
952
951
};
953
952
954
- static struct dentry * cramfs_mount (struct file_system_type * fs_type , int flags ,
955
- const char * dev_name , void * data )
953
+ static int cramfs_get_tree (struct fs_context * fc )
956
954
{
957
- struct dentry * ret = ERR_PTR ( - ENOPROTOOPT ) ;
955
+ int ret = - ENOPROTOOPT ;
958
956
959
957
if (IS_ENABLED (CONFIG_CRAMFS_MTD )) {
960
- ret = mount_mtd (fs_type , flags , dev_name , data ,
961
- cramfs_mtd_fill_super );
962
- if (!IS_ERR (ret ))
958
+ ret = get_tree_mtd (fc , cramfs_mtd_fill_super );
959
+ if (ret < 0 )
963
960
return ret ;
964
961
}
965
- if (IS_ENABLED (CONFIG_CRAMFS_BLOCKDEV )) {
966
- ret = mount_bdev (fs_type , flags , dev_name , data ,
967
- cramfs_blkdev_fill_super );
968
- }
962
+ if (IS_ENABLED (CONFIG_CRAMFS_BLOCKDEV ))
963
+ ret = get_tree_bdev (fc , cramfs_blkdev_fill_super );
969
964
return ret ;
970
965
}
971
966
967
+ static const struct fs_context_operations cramfs_context_ops = {
968
+ .get_tree = cramfs_get_tree ,
969
+ .reconfigure = cramfs_reconfigure ,
970
+ };
971
+
972
+ /*
973
+ * Set up the filesystem mount context.
974
+ */
975
+ static int cramfs_init_fs_context (struct fs_context * fc )
976
+ {
977
+ fc -> ops = & cramfs_context_ops ;
978
+ return 0 ;
979
+ }
980
+
972
981
static struct file_system_type cramfs_fs_type = {
973
982
.owner = THIS_MODULE ,
974
983
.name = "cramfs" ,
975
- .mount = cramfs_mount ,
984
+ .init_fs_context = cramfs_init_fs_context ,
976
985
.kill_sb = cramfs_kill_sb ,
977
986
.fs_flags = FS_REQUIRES_DEV ,
978
987
};
0 commit comments