Commit ad0ec372 authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] filemap.c bits for uClinux

Without CONFIG_MMU we don't need to stub out mmap().  Move one function
around inside filemap.c to need just one ifdef.
parent abcb2f16
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* most "normal" filesystems (but you don't /have/ to use this: * most "normal" filesystems (but you don't /have/ to use this:
* the NFS filesystem used to do this differently, for example) * the NFS filesystem used to do this differently, for example)
*/ */
#include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/compiler.h> #include <linux/compiler.h>
...@@ -247,37 +248,6 @@ int add_to_page_cache_lru(struct page *page, ...@@ -247,37 +248,6 @@ int add_to_page_cache_lru(struct page *page,
return ret; return ret;
} }
/*
* This adds the requested page to the page cache if it isn't already there,
* and schedules an I/O to read in its contents from disk.
*/
static int FASTCALL(page_cache_read(struct file * file, unsigned long offset));
static int page_cache_read(struct file * file, unsigned long offset)
{
struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
struct page *page;
int error;
page = page_cache_alloc_cold(mapping);
if (!page)
return -ENOMEM;
error = add_to_page_cache_lru(page, mapping, offset);
if (!error) {
error = mapping->a_ops->readpage(file, page);
page_cache_release(page);
return error;
}
/*
* We arrive here in the unlikely event that someone
* raced with us and added our page to the cache first
* or we are out of memory for radix-tree nodes.
*/
page_cache_release(page);
return error == -EEXIST ? 0 : error;
}
/* /*
* In order to wait for pages to become available there must be * In order to wait for pages to become available there must be
* waitqueues associated with pages. By using a hash table of * waitqueues associated with pages. By using a hash table of
...@@ -978,6 +948,38 @@ asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count) ...@@ -978,6 +948,38 @@ asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count)
return ret; return ret;
} }
#ifdef CONFIG_MMU
/*
* This adds the requested page to the page cache if it isn't already there,
* and schedules an I/O to read in its contents from disk.
*/
static int FASTCALL(page_cache_read(struct file * file, unsigned long offset));
static int page_cache_read(struct file * file, unsigned long offset)
{
struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
struct page *page;
int error;
page = page_cache_alloc_cold(mapping);
if (!page)
return -ENOMEM;
error = add_to_page_cache_lru(page, mapping, offset);
if (!error) {
error = mapping->a_ops->readpage(file, page);
page_cache_release(page);
return error;
}
/*
* We arrive here in the unlikely event that someone
* raced with us and added our page to the cache first
* or we are out of memory for radix-tree nodes.
*/
page_cache_release(page);
return error == -EEXIST ? 0 : error;
}
/* /*
* filemap_nopage() is invoked via the vma operations vector for a * filemap_nopage() is invoked via the vma operations vector for a
* mapped memory region to read in file data during a page fault. * mapped memory region to read in file data during a page fault.
...@@ -986,7 +988,6 @@ asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count) ...@@ -986,7 +988,6 @@ asmlinkage ssize_t sys_readahead(int fd, loff_t offset, size_t count)
* it in the page cache, and handles the special cases reasonably without * it in the page cache, and handles the special cases reasonably without
* having a lot of duplicated code. * having a lot of duplicated code.
*/ */
struct page * filemap_nopage(struct vm_area_struct * area, unsigned long address, int unused) struct page * filemap_nopage(struct vm_area_struct * area, unsigned long address, int unused)
{ {
int error; int error;
...@@ -1320,6 +1321,12 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma) ...@@ -1320,6 +1321,12 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
vma->vm_ops = &generic_file_vm_ops; vma->vm_ops = &generic_file_vm_ops;
return 0; return 0;
} }
#else
int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
{
return -ENOSYS;
}
#endif /* CONFIG_MMU */
static inline struct page *__read_cache_page(struct address_space *mapping, static inline struct page *__read_cache_page(struct address_space *mapping,
unsigned long index, unsigned long index,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment