hc
2024-10-09 05e59e5fb0064c97a1c10921ecd549f2d4a58565
kernel/fs/romfs/super.c
....@@ -65,7 +65,7 @@
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>
....@@ -356,6 +356,7 @@
356356 }
357357
358358 i->i_mode = mode;
359
+ i->i_blocks = (i->i_size + 511) >> 9;
359360
360361 unlock_new_inode(i);
361362 return i;
....@@ -381,16 +382,9 @@
381382 /*
382383 * return a spent inode to the slab cache
383384 */
384
-static void romfs_i_callback(struct rcu_head *head)
385
+static void romfs_free_inode(struct inode *inode)
385386 {
386
- struct inode *inode = container_of(head, struct inode, i_rcu);
387
-
388387 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
389
-}
390
-
391
-static void romfs_destroy_inode(struct inode *inode)
392
-{
393
- call_rcu(&inode->i_rcu, romfs_i_callback);
394388 }
395389
396390 /*
....@@ -422,26 +416,24 @@
422416 buf->f_bfree = buf->f_bavail = buf->f_ffree;
423417 buf->f_blocks =
424418 (romfs_maxsize(dentry->d_sb) + ROMBSIZE - 1) >> ROMBSBITS;
425
- buf->f_fsid.val[0] = (u32)id;
426
- buf->f_fsid.val[1] = (u32)(id >> 32);
419
+ buf->f_fsid = u64_to_fsid(id);
427420 return 0;
428421 }
429422
430423 /*
431424 * remounting must involve read-only
432425 */
433
-static int romfs_remount(struct super_block *sb, int *flags, char *data)
426
+static int romfs_reconfigure(struct fs_context *fc)
434427 {
435
- sync_filesystem(sb);
436
- *flags |= SB_RDONLY;
428
+ sync_filesystem(fc->root->d_sb);
429
+ fc->sb_flags |= SB_RDONLY;
437430 return 0;
438431 }
439432
440433 static const struct super_operations romfs_super_ops = {
441434 .alloc_inode = romfs_alloc_inode,
442
- .destroy_inode = romfs_destroy_inode,
435
+ .free_inode = romfs_free_inode,
443436 .statfs = romfs_statfs,
444
- .remount_fs = romfs_remount,
445437 };
446438
447439 /*
....@@ -464,7 +456,7 @@
464456 /*
465457 * fill in the superblock
466458 */
467
-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)
468460 {
469461 struct romfs_super_block *rsb;
470462 struct inode *root;
....@@ -485,6 +477,8 @@
485477 sb->s_maxbytes = 0xFFFFFFFF;
486478 sb->s_magic = ROMFS_MAGIC;
487479 sb->s_flags |= SB_RDONLY | SB_NOATIME;
480
+ sb->s_time_min = 0;
481
+ sb->s_time_max = 0;
488482 sb->s_op = &romfs_super_ops;
489483
490484 #ifdef CONFIG_ROMFS_ON_MTD
....@@ -511,8 +505,8 @@
511505
512506 if (rsb->word0 != ROMSB_WORD0 || rsb->word1 != ROMSB_WORD1 ||
513507 img_size < ROMFH_SIZE) {
514
- if (!silent)
515
- pr_warn("VFS: Can't find a romfs filesystem on dev %s.\n",
508
+ if (!(fc->sb_flags & SB_SILENT))
509
+ errorf(fc, "VFS: Can't find a romfs filesystem on dev %s.\n",
516510 sb->s_id);
517511 goto error_rsb_inval;
518512 }
....@@ -525,7 +519,7 @@
525519 storage = sb->s_mtd ? "MTD" : "the block layer";
526520
527521 len = strnlen(rsb->name, ROMFS_MAXFN);
528
- if (!silent)
522
+ if (!(fc->sb_flags & SB_SILENT))
529523 pr_notice("Mounting image '%*.*s' through %s\n",
530524 (unsigned) len, (unsigned) len, rsb->name, storage);
531525
....@@ -555,21 +549,32 @@
555549 /*
556550 * get a superblock for mounting
557551 */
558
-static struct dentry *romfs_mount(struct file_system_type *fs_type,
559
- int flags, const char *dev_name,
560
- void *data)
552
+static int romfs_get_tree(struct fs_context *fc)
561553 {
562
- struct dentry *ret = ERR_PTR(-EINVAL);
554
+ int ret = -EINVAL;
563555
564556 #ifdef CONFIG_ROMFS_ON_MTD
565
- ret = mount_mtd(fs_type, flags, dev_name, data, romfs_fill_super);
557
+ ret = get_tree_mtd(fc, romfs_fill_super);
566558 #endif
567559 #ifdef CONFIG_ROMFS_ON_BLOCK
568
- if (ret == ERR_PTR(-EINVAL))
569
- ret = mount_bdev(fs_type, flags, dev_name, data,
570
- romfs_fill_super);
560
+ if (ret == -EINVAL)
561
+ ret = get_tree_bdev(fc, romfs_fill_super);
571562 #endif
572563 return ret;
564
+}
565
+
566
+static const struct fs_context_operations romfs_context_ops = {
567
+ .get_tree = romfs_get_tree,
568
+ .reconfigure = romfs_reconfigure,
569
+};
570
+
571
+/*
572
+ * Set up the filesystem mount context.
573
+ */
574
+static int romfs_init_fs_context(struct fs_context *fc)
575
+{
576
+ fc->ops = &romfs_context_ops;
577
+ return 0;
573578 }
574579
575580 /*
....@@ -594,7 +599,7 @@
594599 static struct file_system_type romfs_fs_type = {
595600 .owner = THIS_MODULE,
596601 .name = "romfs",
597
- .mount = romfs_mount,
602
+ .init_fs_context = romfs_init_fs_context,
598603 .kill_sb = romfs_kill_sb,
599604 .fs_flags = FS_REQUIRES_DEV,
600605 };
....@@ -661,3 +666,4 @@
661666 MODULE_DESCRIPTION("Direct-MTD Capable RomFS");
662667 MODULE_AUTHOR("Red Hat, Inc.");
663668 MODULE_LICENSE("GPL"); /* Actually dual-licensed, but it doesn't matter for */
669
+MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);