Back to home page

OSCL-LXR

 
 

    


0001 /* file-mmu.c: ramfs MMU-based file operations
0002  *
0003  * Resizable simple ram filesystem for Linux.
0004  *
0005  * Copyright (C) 2000 Linus Torvalds.
0006  *               2000 Transmeta Corp.
0007  *
0008  * Usage limits added by David Gibson, Linuxcare Australia.
0009  * This file is released under the GPL.
0010  */
0011 
0012 /*
0013  * NOTE! This filesystem is probably most useful
0014  * not as a real filesystem, but as an example of
0015  * how virtual filesystems can be written.
0016  *
0017  * It doesn't get much simpler than this. Consider
0018  * that this file implements the full semantics of
0019  * a POSIX-compliant read-write filesystem.
0020  *
0021  * Note in particular how the filesystem does not
0022  * need to implement any data structures of its own
0023  * to keep track of the virtual data: using the VFS
0024  * caches is sufficient.
0025  */
0026 
0027 #include <linux/fs.h>
0028 #include <linux/mm.h>
0029 #include <linux/ramfs.h>
0030 #include <linux/sched.h>
0031 
0032 #include "internal.h"
0033 
0034 static unsigned long ramfs_mmu_get_unmapped_area(struct file *file,
0035         unsigned long addr, unsigned long len, unsigned long pgoff,
0036         unsigned long flags)
0037 {
0038     return current->mm->get_unmapped_area(file, addr, len, pgoff, flags);
0039 }
0040 
0041 const struct file_operations ramfs_file_operations = {
0042     .read_iter  = generic_file_read_iter,
0043     .write_iter = generic_file_write_iter,
0044     .mmap       = generic_file_mmap,
0045     .fsync      = noop_fsync,
0046     .splice_read    = generic_file_splice_read,
0047     .splice_write   = iter_file_splice_write,
0048     .llseek     = generic_file_llseek,
0049     .get_unmapped_area  = ramfs_mmu_get_unmapped_area,
0050 };
0051 
0052 const struct inode_operations ramfs_file_inode_operations = {
0053     .setattr    = simple_setattr,
0054     .getattr    = simple_getattr,
0055 };