patch-2.4.21 linux-2.4.21/mm/filemap.c
Next file: linux-2.4.21/mm/highmem.c
Previous file: linux-2.4.21/lib/vsprintf.c
Back to the patch index
Back to the overall index
- Lines: 113
- Date:
2003-06-13 07:51:39.000000000 -0700
- Orig file:
linux-2.4.20/mm/filemap.c
- Orig date:
2002-11-28 15:53:15.000000000 -0800
diff -urN linux-2.4.20/mm/filemap.c linux-2.4.21/mm/filemap.c
@@ -95,9 +95,13 @@
{
struct address_space * mapping = page->mapping;
- mapping->nrpages--;
+ if (mapping->a_ops->removepage)
+ mapping->a_ops->removepage(page);
+
list_del(&page->list);
page->mapping = NULL;
+ wmb();
+ mapping->nrpages--;
}
static inline void remove_page_from_hash_queue(struct page * page)
@@ -1569,7 +1573,7 @@
chunk_size = KIO_MAX_ATOMIC_IO << 10;
retval = -EINVAL;
- if ((offset & blocksize_mask) || (count & blocksize_mask))
+ if ((offset & blocksize_mask) || (count & blocksize_mask) || ((unsigned long) buf & blocksize_mask))
goto out_free;
if (!mapping->a_ops->direct_IO)
goto out_free;
@@ -1740,7 +1744,7 @@
return written;
}
-asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
+static ssize_t common_sendfile(int out_fd, int in_fd, loff_t *offset, size_t count)
{
ssize_t retval;
struct file * in_file, * out_file;
@@ -1785,27 +1789,19 @@
retval = 0;
if (count) {
read_descriptor_t desc;
- loff_t pos = 0, *ppos;
-
- retval = -EFAULT;
- ppos = &in_file->f_pos;
- if (offset) {
- if (get_user(pos, offset))
- goto fput_out;
- ppos = &pos;
- }
+
+ if (!offset)
+ offset = &in_file->f_pos;
desc.written = 0;
desc.count = count;
desc.buf = (char *) out_file;
desc.error = 0;
- do_generic_file_read(in_file, ppos, &desc, file_send_actor);
+ do_generic_file_read(in_file, offset, &desc, file_send_actor);
retval = desc.written;
if (!retval)
retval = desc.error;
- if (offset)
- put_user(pos, offset);
}
fput_out:
@@ -1816,6 +1812,38 @@
return retval;
}
+asmlinkage ssize_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
+{
+ loff_t pos, *ppos = NULL;
+ ssize_t ret;
+ if (offset) {
+ off_t off;
+ if (unlikely(get_user(off, offset)))
+ return -EFAULT;
+ pos = off;
+ ppos = &pos;
+ }
+ ret = common_sendfile(out_fd, in_fd, ppos, count);
+ if (offset)
+ put_user((off_t)pos, offset);
+ return ret;
+}
+
+asmlinkage ssize_t sys_sendfile64(int out_fd, int in_fd, loff_t *offset, size_t count)
+{
+ loff_t pos, *ppos = NULL;
+ ssize_t ret;
+ if (offset) {
+ if (unlikely(copy_from_user(&pos, offset, sizeof(loff_t))))
+ return -EFAULT;
+ ppos = &pos;
+ }
+ ret = common_sendfile(out_fd, in_fd, ppos, count);
+ if (offset)
+ put_user(pos, offset);
+ return ret;
+}
+
static ssize_t do_readahead(struct file *file, unsigned long index, unsigned long nr)
{
struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
@@ -2940,7 +2968,7 @@
struct page *page, *cached_page;
ssize_t written;
long status = 0;
- int err;
+ ssize_t err;
unsigned bytes;
if ((ssize_t) count < 0)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)