From 6b8a2eaeaf5a69bef73c3398d91d7f2bad1cc4b2 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Thu, 5 Jun 2008 22:46:21 -0700 Subject: [PATCH] --- yaml --- r: 97802 b: refs/heads/master c: 93b071139a956e51c98cdefd50a47981a4eb852e h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/libfs.c | 18 ++++++++++++++++++ trunk/include/linux/fs.h | 5 ++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index eeb15c4785ee..c2240b35b5ea 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3527fb326f07bc8e85cf66d4f987ebeea24e8e4a +refs/heads/master: 93b071139a956e51c98cdefd50a47981a4eb852e diff --git a/trunk/fs/libfs.c b/trunk/fs/libfs.c index b004dfadd891..892d41cb3382 100644 --- a/trunk/fs/libfs.c +++ b/trunk/fs/libfs.c @@ -528,6 +528,23 @@ ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos, return count; } +ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, + const void *from, size_t available) +{ + loff_t pos = *ppos; + + if (pos < 0) + return -EINVAL; + if (pos >= available) + return 0; + if (count > available - pos) + count = available - pos; + memcpy(to, from + pos, count); + *ppos = pos + count; + + return count; +} + /* * Transaction based IO. * The file expects a single write which triggers the transaction, and then @@ -800,6 +817,7 @@ EXPORT_SYMBOL(simple_statfs); EXPORT_SYMBOL(simple_sync_file); EXPORT_SYMBOL(simple_unlink); EXPORT_SYMBOL(simple_read_from_buffer); +EXPORT_SYMBOL(memory_read_from_buffer); EXPORT_SYMBOL(simple_transaction_get); EXPORT_SYMBOL(simple_transaction_read); EXPORT_SYMBOL(simple_transaction_release); diff --git a/trunk/include/linux/fs.h b/trunk/include/linux/fs.h index f413085f748e..d490779f18d9 100644 --- a/trunk/include/linux/fs.h +++ b/trunk/include/linux/fs.h @@ -2000,7 +2000,10 @@ extern int simple_fill_super(struct super_block *, int, struct tree_descr *); extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count); extern void simple_release_fs(struct vfsmount **mount, int *count); -extern ssize_t simple_read_from_buffer(void __user *, size_t, loff_t *, const void *, size_t); +extern ssize_t simple_read_from_buffer(void __user *to, size_t count, + loff_t *ppos, const void *from, size_t available); +extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos, + const void *from, size_t available); #ifdef CONFIG_MIGRATION extern int buffer_migrate_page(struct address_space *,