xref: /OK3568_Linux_fs/kernel/fs/ramfs/file-mmu.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* file-mmu.c: ramfs MMU-based file operations
2*4882a593Smuzhiyun  *
3*4882a593Smuzhiyun  * Resizable simple ram filesystem for Linux.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2000 Linus Torvalds.
6*4882a593Smuzhiyun  *               2000 Transmeta Corp.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Usage limits added by David Gibson, Linuxcare Australia.
9*4882a593Smuzhiyun  * This file is released under the GPL.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /*
13*4882a593Smuzhiyun  * NOTE! This filesystem is probably most useful
14*4882a593Smuzhiyun  * not as a real filesystem, but as an example of
15*4882a593Smuzhiyun  * how virtual filesystems can be written.
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * It doesn't get much simpler than this. Consider
18*4882a593Smuzhiyun  * that this file implements the full semantics of
19*4882a593Smuzhiyun  * a POSIX-compliant read-write filesystem.
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * Note in particular how the filesystem does not
22*4882a593Smuzhiyun  * need to implement any data structures of its own
23*4882a593Smuzhiyun  * to keep track of the virtual data: using the VFS
24*4882a593Smuzhiyun  * caches is sufficient.
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #include <linux/fs.h>
28*4882a593Smuzhiyun #include <linux/mm.h>
29*4882a593Smuzhiyun #include <linux/ramfs.h>
30*4882a593Smuzhiyun #include <linux/sched.h>
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #include "internal.h"
33*4882a593Smuzhiyun 
ramfs_mmu_get_unmapped_area(struct file * file,unsigned long addr,unsigned long len,unsigned long pgoff,unsigned long flags)34*4882a593Smuzhiyun static unsigned long ramfs_mmu_get_unmapped_area(struct file *file,
35*4882a593Smuzhiyun 		unsigned long addr, unsigned long len, unsigned long pgoff,
36*4882a593Smuzhiyun 		unsigned long flags)
37*4882a593Smuzhiyun {
38*4882a593Smuzhiyun 	return current->mm->get_unmapped_area(file, addr, len, pgoff, flags);
39*4882a593Smuzhiyun }
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun const struct file_operations ramfs_file_operations = {
42*4882a593Smuzhiyun 	.read_iter	= generic_file_read_iter,
43*4882a593Smuzhiyun 	.write_iter	= generic_file_write_iter,
44*4882a593Smuzhiyun 	.mmap		= generic_file_mmap,
45*4882a593Smuzhiyun 	.fsync		= noop_fsync,
46*4882a593Smuzhiyun 	.splice_read	= generic_file_splice_read,
47*4882a593Smuzhiyun 	.splice_write	= iter_file_splice_write,
48*4882a593Smuzhiyun 	.llseek		= generic_file_llseek,
49*4882a593Smuzhiyun 	.get_unmapped_area	= ramfs_mmu_get_unmapped_area,
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun const struct inode_operations ramfs_file_inode_operations = {
53*4882a593Smuzhiyun 	.setattr	= simple_setattr,
54*4882a593Smuzhiyun 	.getattr	= simple_getattr,
55*4882a593Smuzhiyun };
56