Lines Matching +full:super +full:- +full:set

26 #include <linux/mtd/super.h>
37 * cramfs super-block data in memory
52 return sb->s_fs_info; in CRAMFS_SB()
65 #define OFFSET(x) ((x)->i_ino)
69 if (!cino->offset) in cramino()
71 if (!cino->size) in cramino()
76 * cramfs_inode->offset is set to a non zero value for entries in cramino()
79 switch (cino->mode & S_IFMT) { in cramino()
83 return cino->offset << 2; in cramino()
98 return ERR_PTR(-ENOMEM); in get_cramfs_inode()
99 if (!(inode->i_state & I_NEW)) in get_cramfs_inode()
102 switch (cramfs_inode->mode & S_IFMT) { in get_cramfs_inode()
104 inode->i_fop = &generic_ro_fops; in get_cramfs_inode()
105 inode->i_data.a_ops = &cramfs_aops; in get_cramfs_inode()
107 CRAMFS_SB(sb)->flags & CRAMFS_FLAG_EXT_BLOCK_POINTERS && in get_cramfs_inode()
108 CRAMFS_SB(sb)->linear_phys_addr) in get_cramfs_inode()
109 inode->i_fop = &cramfs_physmem_fops; in get_cramfs_inode()
112 inode->i_op = &cramfs_dir_inode_operations; in get_cramfs_inode()
113 inode->i_fop = &cramfs_directory_operations; in get_cramfs_inode()
116 inode->i_op = &page_symlink_inode_operations; in get_cramfs_inode()
118 inode->i_data.a_ops = &cramfs_aops; in get_cramfs_inode()
121 init_special_inode(inode, cramfs_inode->mode, in get_cramfs_inode()
122 old_decode_dev(cramfs_inode->size)); in get_cramfs_inode()
125 inode->i_mode = cramfs_inode->mode; in get_cramfs_inode()
126 i_uid_write(inode, cramfs_inode->uid); in get_cramfs_inode()
127 i_gid_write(inode, cramfs_inode->gid); in get_cramfs_inode()
130 if (!(inode->i_ino & 3)) { in get_cramfs_inode()
131 inode->i_size = cramfs_inode->size; in get_cramfs_inode()
132 inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1; in get_cramfs_inode()
138 /* inode->i_nlink is left 1 - arguably wrong for directories, in get_cramfs_inode()
141 without -noleaf option. */ in get_cramfs_inode()
150 * with the rom-image, because the way the filesystem is set
156 * worry about end-of-buffer issues even when decompressing a full
163 /* NEXT_BUFFER(): Loop over [0..(READ_BUFFERS-1)]. */
186 struct address_space *mapping = sb->s_bdev->bd_mapping; in cramfs_blkdev_read()
196 offset &= PAGE_SIZE - 1; in cramfs_blkdev_read()
206 blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_SHIFT; in cramfs_blkdev_read()
214 devsize = bdev_nr_bytes(sb->s_bdev) >> PAGE_SHIFT; in cramfs_blkdev_read()
261 if (len > sbi->size || offset > sbi->size - len) in cramfs_direct_read()
263 return sbi->linear_virt_addr + offset; in cramfs_direct_read()
275 if (IS_ENABLED(CONFIG_CRAMFS_MTD) && sbi->linear_virt_addr) in cramfs_read()
290 struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb); in cramfs_get_block_range()
299 blockptrs = (u32 *)(sbi->linear_virt_addr + OFFSET(inode) + pgoff * 4); in cramfs_get_block_range()
309 pgoff+i, pgoff + *pages - 1, in cramfs_get_block_range()
331 struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb); in cramfs_last_page_is_shared()
335 partial = offset_in_page(inode->i_size); in cramfs_last_page_is_shared()
338 last_page = inode->i_size >> PAGE_SHIFT; in cramfs_last_page_is_shared()
339 blockptrs = (u32 *)(sbi->linear_virt_addr + OFFSET(inode)); in cramfs_last_page_is_shared()
342 tail_data = sbi->linear_virt_addr + blockaddr + partial; in cramfs_last_page_is_shared()
343 return memchr_inv(tail_data, 0, PAGE_SIZE - partial) ? true : false; in cramfs_last_page_is_shared()
349 struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb); in cramfs_physmem_mmap()
351 unsigned long address, pgoff = vma->vm_pgoff; in cramfs_physmem_mmap()
360 * Now try to pre-populate ptes for this vma with a direct in cramfs_physmem_mmap()
366 if (vma->vm_flags & VM_WRITE) in cramfs_physmem_mmap()
369 max_pages = (inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT; in cramfs_physmem_mmap()
373 pages = min(vma_pages(vma), max_pages - pgoff); in cramfs_physmem_mmap()
379 address = sbi->linear_phys_addr + offset; in cramfs_physmem_mmap()
387 pages--; in cramfs_physmem_mmap()
398 * make it distinguishable from a non-direct mapping in cramfs_physmem_mmap()
402 ret = remap_pfn_range(vma, vma->vm_start, address >> PAGE_SHIFT, in cramfs_physmem_mmap()
403 pages * PAGE_SIZE, vma->vm_page_prot); in cramfs_physmem_mmap()
416 vmf = vmf_insert_mixed(vma, vma->vm_start + off, pfn); in cramfs_physmem_mmap()
425 pgoff, address, pages, vma_pages(vma), vma->vm_start, in cramfs_physmem_mmap()
426 (unsigned long long)pgprot_val(vma->vm_page_prot)); in cramfs_physmem_mmap()
440 return is_nommu_shared_mapping(vma->vm_flags) ? 0 : -ENOSYS; in cramfs_physmem_mmap()
448 struct super_block *sb = inode->i_sb; in cramfs_physmem_get_unmapped_area()
452 pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; in cramfs_physmem_get_unmapped_area()
453 max_pages = (inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT; in cramfs_physmem_get_unmapped_area()
454 if (pgoff >= max_pages || pages > max_pages - pgoff) in cramfs_physmem_get_unmapped_area()
455 return -EINVAL; in cramfs_physmem_get_unmapped_area()
459 return -ENOSYS; in cramfs_physmem_get_unmapped_area()
460 addr = sbi->linear_phys_addr + offset; in cramfs_physmem_get_unmapped_area()
491 if (IS_ENABLED(CONFIG_CRAMFS_MTD) && sb->s_mtd) { in cramfs_kill_sb()
492 if (sbi && sbi->mtd_point_size) in cramfs_kill_sb()
493 mtd_unpoint(sb->s_mtd, 0, sbi->mtd_point_size); in cramfs_kill_sb()
494 put_mtd_device(sb->s_mtd); in cramfs_kill_sb()
495 sb->s_mtd = NULL; in cramfs_kill_sb()
496 } else if (IS_ENABLED(CONFIG_CRAMFS_BLOCKDEV) && sb->s_bdev) { in cramfs_kill_sb()
497 sync_blockdev(sb->s_bdev); in cramfs_kill_sb()
498 bdev_fput(sb->s_bdev_file); in cramfs_kill_sb()
505 sync_filesystem(fc->root->d_sb); in cramfs_reconfigure()
506 fc->sb_flags |= SB_RDONLY; in cramfs_reconfigure()
511 struct cramfs_super *super) in cramfs_read_super() argument
515 bool silent = fc->sb_flags & SB_SILENT; in cramfs_read_super()
518 sbi->size = PAGE_SIZE; in cramfs_read_super()
522 memcpy(super, cramfs_read(sb, 0, sizeof(*super)), sizeof(*super)); in cramfs_read_super()
526 if (super->magic != CRAMFS_MAGIC) { in cramfs_read_super()
528 if (super->magic == CRAMFS_MAGIC_WEND) { in cramfs_read_super()
531 return -EINVAL; in cramfs_read_super()
536 memcpy(super, in cramfs_read_super()
537 cramfs_read(sb, 512, sizeof(*super)), in cramfs_read_super()
538 sizeof(*super)); in cramfs_read_super()
540 if (super->magic != CRAMFS_MAGIC) { in cramfs_read_super()
541 if (super->magic == CRAMFS_MAGIC_WEND && !silent) in cramfs_read_super()
545 return -EINVAL; in cramfs_read_super()
550 if (super->flags & ~CRAMFS_SUPPORTED_FLAGS) { in cramfs_read_super()
552 return -EINVAL; in cramfs_read_super()
556 if (!S_ISDIR(super->root.mode)) { in cramfs_read_super()
558 return -EINVAL; in cramfs_read_super()
560 /* correct strange, hard-coded permissions of mkcramfs */ in cramfs_read_super()
561 super->root.mode |= 0555; in cramfs_read_super()
563 root_offset = super->root.offset << 2; in cramfs_read_super()
564 if (super->flags & CRAMFS_FLAG_FSID_VERSION_2) { in cramfs_read_super()
565 sbi->size = super->size; in cramfs_read_super()
566 sbi->blocks = super->fsid.blocks; in cramfs_read_super()
567 sbi->files = super->fsid.files; in cramfs_read_super()
569 sbi->size = 1<<28; in cramfs_read_super()
570 sbi->blocks = 0; in cramfs_read_super()
571 sbi->files = 0; in cramfs_read_super()
573 sbi->magic = super->magic; in cramfs_read_super()
574 sbi->flags = super->flags; in cramfs_read_super()
577 else if (!(super->flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) && in cramfs_read_super()
582 return -EINVAL; in cramfs_read_super()
593 /* Set it all up.. */ in cramfs_finalize_super()
594 sb->s_flags |= SB_RDONLY; in cramfs_finalize_super()
595 sb->s_time_min = 0; in cramfs_finalize_super()
596 sb->s_time_max = 0; in cramfs_finalize_super()
597 sb->s_op = &cramfs_ops; in cramfs_finalize_super()
601 sb->s_root = d_make_root(root); in cramfs_finalize_super()
602 if (!sb->s_root) in cramfs_finalize_super()
603 return -ENOMEM; in cramfs_finalize_super()
610 struct cramfs_super super; in cramfs_blkdev_fill_super() local
615 return -ENOMEM; in cramfs_blkdev_fill_super()
616 sb->s_fs_info = sbi; in cramfs_blkdev_fill_super()
620 buffer_blocknr[i] = -1; in cramfs_blkdev_fill_super()
622 err = cramfs_read_super(sb, fc, &super); in cramfs_blkdev_fill_super()
625 return cramfs_finalize_super(sb, &super.root); in cramfs_blkdev_fill_super()
631 struct cramfs_super super; in cramfs_mtd_fill_super() local
636 return -ENOMEM; in cramfs_mtd_fill_super()
637 sb->s_fs_info = sbi; in cramfs_mtd_fill_super()
640 err = mtd_point(sb->s_mtd, 0, PAGE_SIZE, &sbi->mtd_point_size, in cramfs_mtd_fill_super()
641 &sbi->linear_virt_addr, &sbi->linear_phys_addr); in cramfs_mtd_fill_super()
642 if (err || sbi->mtd_point_size != PAGE_SIZE) { in cramfs_mtd_fill_super()
644 sb->s_mtd->name); in cramfs_mtd_fill_super()
645 return err ? : -ENODATA; in cramfs_mtd_fill_super()
649 &sbi->linear_phys_addr); in cramfs_mtd_fill_super()
650 err = cramfs_read_super(sb, fc, &super); in cramfs_mtd_fill_super()
656 sb->s_mtd->name, sbi->size/1024); in cramfs_mtd_fill_super()
657 mtd_unpoint(sb->s_mtd, 0, PAGE_SIZE); in cramfs_mtd_fill_super()
658 err = mtd_point(sb->s_mtd, 0, sbi->size, &sbi->mtd_point_size, in cramfs_mtd_fill_super()
659 &sbi->linear_virt_addr, &sbi->linear_phys_addr); in cramfs_mtd_fill_super()
660 if (err || sbi->mtd_point_size != sbi->size) { in cramfs_mtd_fill_super()
662 sb->s_mtd->name); in cramfs_mtd_fill_super()
663 return err ? : -ENODATA; in cramfs_mtd_fill_super()
666 return cramfs_finalize_super(sb, &super.root); in cramfs_mtd_fill_super()
671 struct super_block *sb = dentry->d_sb; in cramfs_statfs()
674 if (sb->s_bdev) in cramfs_statfs()
675 id = huge_encode_dev(sb->s_bdev->bd_dev); in cramfs_statfs()
676 else if (sb->s_dev) in cramfs_statfs()
677 id = huge_encode_dev(sb->s_dev); in cramfs_statfs()
679 buf->f_type = CRAMFS_MAGIC; in cramfs_statfs()
680 buf->f_bsize = PAGE_SIZE; in cramfs_statfs()
681 buf->f_blocks = CRAMFS_SB(sb)->blocks; in cramfs_statfs()
682 buf->f_bfree = 0; in cramfs_statfs()
683 buf->f_bavail = 0; in cramfs_statfs()
684 buf->f_files = CRAMFS_SB(sb)->files; in cramfs_statfs()
685 buf->f_ffree = 0; in cramfs_statfs()
686 buf->f_fsid = u64_to_fsid(id); in cramfs_statfs()
687 buf->f_namelen = CRAMFS_MAXPATHLEN; in cramfs_statfs()
697 struct super_block *sb = inode->i_sb; in cramfs_readdir()
702 if (ctx->pos >= inode->i_size) in cramfs_readdir()
704 offset = ctx->pos; in cramfs_readdir()
705 /* Directory entries are always 4-byte aligned */ in cramfs_readdir()
707 return -EINVAL; in cramfs_readdir()
711 return -ENOMEM; in cramfs_readdir()
713 while (offset < inode->i_size) { in cramfs_readdir()
727 * and the name padded out to 4-byte boundaries in cramfs_readdir()
730 namelen = de->namelen << 2; in cramfs_readdir()
733 mode = de->mode; in cramfs_readdir()
739 return -EIO; in cramfs_readdir()
741 if (buf[namelen-1]) in cramfs_readdir()
743 namelen--; in cramfs_readdir()
748 ctx->pos = offset = nextoffset; in cramfs_readdir()
764 sorted = CRAMFS_SB(dir->i_sb)->flags & CRAMFS_FLAG_SORTED_DIRS; in cramfs_lookup()
765 while (offset < dir->i_size) { in cramfs_lookup()
771 de = cramfs_read(dir->i_sb, dir_off, sizeof(*de)+CRAMFS_MAXPATHLEN); in cramfs_lookup()
775 if (sorted && (dentry->d_name.name[0] < name[0])) in cramfs_lookup()
778 namelen = de->namelen << 2; in cramfs_lookup()
782 if (((dentry->d_name.len + 3) & ~3) != namelen) in cramfs_lookup()
787 inode = ERR_PTR(-EIO); in cramfs_lookup()
790 if (name[namelen-1]) in cramfs_lookup()
792 namelen--; in cramfs_lookup()
794 if (namelen != dentry->d_name.len) in cramfs_lookup()
796 retval = memcmp(dentry->d_name.name, name, namelen); in cramfs_lookup()
800 inode = get_cramfs_inode(dir->i_sb, de, dir_off); in cramfs_lookup()
814 struct inode *inode = folio->mapping->host; in cramfs_read_folio()
820 maxblock = (inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT; in cramfs_read_folio()
824 if (folio->index < maxblock) { in cramfs_read_folio()
825 struct super_block *sb = inode->i_sb; in cramfs_read_folio()
826 u32 blkptr_offset = OFFSET(inode) + folio->index * 4; in cramfs_read_folio()
847 if (folio->index == maxblock - 1) in cramfs_read_folio()
849 offset_in_page(inode->i_size); in cramfs_read_folio()
864 if (folio->index) in cramfs_read_folio()
866 cramfs_read(sb, blkptr_offset - 4, 4); in cramfs_read_folio()
882 block_len = block_ptr - block_start; in cramfs_read_folio()
908 memset(pgdata + bytes_filled, 0, PAGE_SIZE - bytes_filled); in cramfs_read_folio()
945 int ret = -ENOPROTOOPT; in cramfs_get_tree()
963 * Set up the filesystem mount context.
967 fc->ops = &cramfs_context_ops; in cramfs_init_fs_context()