18c2ecf20Sopenharmony_ci/* file-mmu.c: ramfs MMU-based file operations 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Resizable simple ram filesystem for Linux. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2000 Linus Torvalds. 68c2ecf20Sopenharmony_ci * 2000 Transmeta Corp. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Usage limits added by David Gibson, Linuxcare Australia. 98c2ecf20Sopenharmony_ci * This file is released under the GPL. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* 138c2ecf20Sopenharmony_ci * NOTE! This filesystem is probably most useful 148c2ecf20Sopenharmony_ci * not as a real filesystem, but as an example of 158c2ecf20Sopenharmony_ci * how virtual filesystems can be written. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * It doesn't get much simpler than this. Consider 188c2ecf20Sopenharmony_ci * that this file implements the full semantics of 198c2ecf20Sopenharmony_ci * a POSIX-compliant read-write filesystem. 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * Note in particular how the filesystem does not 228c2ecf20Sopenharmony_ci * need to implement any data structures of its own 238c2ecf20Sopenharmony_ci * to keep track of the virtual data: using the VFS 248c2ecf20Sopenharmony_ci * caches is sufficient. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#include <linux/fs.h> 288c2ecf20Sopenharmony_ci#include <linux/mm.h> 298c2ecf20Sopenharmony_ci#include <linux/ramfs.h> 308c2ecf20Sopenharmony_ci#include <linux/sched.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include "internal.h" 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic unsigned long ramfs_mmu_get_unmapped_area(struct file *file, 358c2ecf20Sopenharmony_ci unsigned long addr, unsigned long len, unsigned long pgoff, 368c2ecf20Sopenharmony_ci unsigned long flags) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci return current->mm->get_unmapped_area(file, addr, len, pgoff, flags); 398c2ecf20Sopenharmony_ci} 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciconst struct file_operations ramfs_file_operations = { 428c2ecf20Sopenharmony_ci .read_iter = generic_file_read_iter, 438c2ecf20Sopenharmony_ci .write_iter = generic_file_write_iter, 448c2ecf20Sopenharmony_ci .mmap = generic_file_mmap, 458c2ecf20Sopenharmony_ci .fsync = noop_fsync, 468c2ecf20Sopenharmony_ci .splice_read = generic_file_splice_read, 478c2ecf20Sopenharmony_ci .splice_write = iter_file_splice_write, 488c2ecf20Sopenharmony_ci .llseek = generic_file_llseek, 498c2ecf20Sopenharmony_ci .get_unmapped_area = ramfs_mmu_get_unmapped_area, 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciconst struct inode_operations ramfs_file_inode_operations = { 538c2ecf20Sopenharmony_ci .setattr = simple_setattr, 548c2ecf20Sopenharmony_ci .getattr = simple_getattr, 558c2ecf20Sopenharmony_ci}; 56