.. | .. |
---|
65 | 65 | #include <linux/slab.h> |
---|
66 | 66 | #include <linux/init.h> |
---|
67 | 67 | #include <linux/blkdev.h> |
---|
68 | | -#include <linux/parser.h> |
---|
| 68 | +#include <linux/fs_context.h> |
---|
69 | 69 | #include <linux/mount.h> |
---|
70 | 70 | #include <linux/namei.h> |
---|
71 | 71 | #include <linux/statfs.h> |
---|
.. | .. |
---|
356 | 356 | } |
---|
357 | 357 | |
---|
358 | 358 | i->i_mode = mode; |
---|
| 359 | + i->i_blocks = (i->i_size + 511) >> 9; |
---|
359 | 360 | |
---|
360 | 361 | unlock_new_inode(i); |
---|
361 | 362 | return i; |
---|
.. | .. |
---|
381 | 382 | /* |
---|
382 | 383 | * return a spent inode to the slab cache |
---|
383 | 384 | */ |
---|
384 | | -static void romfs_i_callback(struct rcu_head *head) |
---|
| 385 | +static void romfs_free_inode(struct inode *inode) |
---|
385 | 386 | { |
---|
386 | | - struct inode *inode = container_of(head, struct inode, i_rcu); |
---|
387 | | - |
---|
388 | 387 | 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); |
---|
394 | 388 | } |
---|
395 | 389 | |
---|
396 | 390 | /* |
---|
.. | .. |
---|
422 | 416 | buf->f_bfree = buf->f_bavail = buf->f_ffree; |
---|
423 | 417 | buf->f_blocks = |
---|
424 | 418 | (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); |
---|
427 | 420 | return 0; |
---|
428 | 421 | } |
---|
429 | 422 | |
---|
430 | 423 | /* |
---|
431 | 424 | * remounting must involve read-only |
---|
432 | 425 | */ |
---|
433 | | -static int romfs_remount(struct super_block *sb, int *flags, char *data) |
---|
| 426 | +static int romfs_reconfigure(struct fs_context *fc) |
---|
434 | 427 | { |
---|
435 | | - sync_filesystem(sb); |
---|
436 | | - *flags |= SB_RDONLY; |
---|
| 428 | + sync_filesystem(fc->root->d_sb); |
---|
| 429 | + fc->sb_flags |= SB_RDONLY; |
---|
437 | 430 | return 0; |
---|
438 | 431 | } |
---|
439 | 432 | |
---|
440 | 433 | static const struct super_operations romfs_super_ops = { |
---|
441 | 434 | .alloc_inode = romfs_alloc_inode, |
---|
442 | | - .destroy_inode = romfs_destroy_inode, |
---|
| 435 | + .free_inode = romfs_free_inode, |
---|
443 | 436 | .statfs = romfs_statfs, |
---|
444 | | - .remount_fs = romfs_remount, |
---|
445 | 437 | }; |
---|
446 | 438 | |
---|
447 | 439 | /* |
---|
.. | .. |
---|
464 | 456 | /* |
---|
465 | 457 | * fill in the superblock |
---|
466 | 458 | */ |
---|
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) |
---|
468 | 460 | { |
---|
469 | 461 | struct romfs_super_block *rsb; |
---|
470 | 462 | struct inode *root; |
---|
.. | .. |
---|
485 | 477 | sb->s_maxbytes = 0xFFFFFFFF; |
---|
486 | 478 | sb->s_magic = ROMFS_MAGIC; |
---|
487 | 479 | sb->s_flags |= SB_RDONLY | SB_NOATIME; |
---|
| 480 | + sb->s_time_min = 0; |
---|
| 481 | + sb->s_time_max = 0; |
---|
488 | 482 | sb->s_op = &romfs_super_ops; |
---|
489 | 483 | |
---|
490 | 484 | #ifdef CONFIG_ROMFS_ON_MTD |
---|
.. | .. |
---|
511 | 505 | |
---|
512 | 506 | if (rsb->word0 != ROMSB_WORD0 || rsb->word1 != ROMSB_WORD1 || |
---|
513 | 507 | 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", |
---|
516 | 510 | sb->s_id); |
---|
517 | 511 | goto error_rsb_inval; |
---|
518 | 512 | } |
---|
.. | .. |
---|
525 | 519 | storage = sb->s_mtd ? "MTD" : "the block layer"; |
---|
526 | 520 | |
---|
527 | 521 | len = strnlen(rsb->name, ROMFS_MAXFN); |
---|
528 | | - if (!silent) |
---|
| 522 | + if (!(fc->sb_flags & SB_SILENT)) |
---|
529 | 523 | pr_notice("Mounting image '%*.*s' through %s\n", |
---|
530 | 524 | (unsigned) len, (unsigned) len, rsb->name, storage); |
---|
531 | 525 | |
---|
.. | .. |
---|
555 | 549 | /* |
---|
556 | 550 | * get a superblock for mounting |
---|
557 | 551 | */ |
---|
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) |
---|
561 | 553 | { |
---|
562 | | - struct dentry *ret = ERR_PTR(-EINVAL); |
---|
| 554 | + int ret = -EINVAL; |
---|
563 | 555 | |
---|
564 | 556 | #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); |
---|
566 | 558 | #endif |
---|
567 | 559 | #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); |
---|
571 | 562 | #endif |
---|
572 | 563 | 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; |
---|
573 | 578 | } |
---|
574 | 579 | |
---|
575 | 580 | /* |
---|
.. | .. |
---|
594 | 599 | static struct file_system_type romfs_fs_type = { |
---|
595 | 600 | .owner = THIS_MODULE, |
---|
596 | 601 | .name = "romfs", |
---|
597 | | - .mount = romfs_mount, |
---|
| 602 | + .init_fs_context = romfs_init_fs_context, |
---|
598 | 603 | .kill_sb = romfs_kill_sb, |
---|
599 | 604 | .fs_flags = FS_REQUIRES_DEV, |
---|
600 | 605 | }; |
---|
.. | .. |
---|
661 | 666 | MODULE_DESCRIPTION("Direct-MTD Capable RomFS"); |
---|
662 | 667 | MODULE_AUTHOR("Red Hat, Inc."); |
---|
663 | 668 | MODULE_LICENSE("GPL"); /* Actually dual-licensed, but it doesn't matter for */ |
---|
| 669 | +MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY); |
---|