diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-20 12:03:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-20 12:03:55 -0400 |
commit | 46ee9645094ad1eb5b4888882ecaa1fb87dcd2a3 (patch) | |
tree | d0a48e993568b6a2415cfc21fc06eaa2fd886429 /fs | |
parent | fa5312d9e87e7222c6c384c4e930dc149bc1178d (diff) | |
parent | 25f3a5a2854dce8b8413fd24cc9d5b9e3632be54 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
PM: PM QOS update fix
Freezer / cgroup freezer: Update stale locking comments
PM / platform_bus: Allow runtime PM by default
i2c: Fix bus-level power management callbacks
PM QOS update
PM / Hibernate: Fix block_io.c printk warning
PM / Hibernate: Group swap ops
PM / Hibernate: Move the first_sector out of swsusp_write
PM / Hibernate: Separate block_io
PM / Hibernate: Snapshot cleanup
FS / libfs: Implement simple_write_to_buffer
PM / Hibernate: document open(/dev/snapshot) side effects
PM / Runtime: Add sysfs debug files
PM: Improve device power management document
PM: Update device power management document
PM: Allow runtime_suspend methods to call pm_schedule_suspend()
PM: pm_wakeup - switch to using bool
Diffstat (limited to 'fs')
-rw-r--r-- | fs/libfs.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/fs/libfs.c b/fs/libfs.c index ea9a6cc9b35c..232bea425b09 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -547,6 +547,40 @@ ssize_t simple_read_from_buffer(void __user *to, size_t count, loff_t *ppos, | |||
547 | } | 547 | } |
548 | 548 | ||
549 | /** | 549 | /** |
550 | * simple_write_to_buffer - copy data from user space to the buffer | ||
551 | * @to: the buffer to write to | ||
552 | * @available: the size of the buffer | ||
553 | * @ppos: the current position in the buffer | ||
554 | * @from: the user space buffer to read from | ||
555 | * @count: the maximum number of bytes to read | ||
556 | * | ||
557 | * The simple_write_to_buffer() function reads up to @count bytes from the user | ||
558 | * space address starting at @from into the buffer @to at offset @ppos. | ||
559 | * | ||
560 | * On success, the number of bytes written is returned and the offset @ppos is | ||
561 | * advanced by this number, or negative value is returned on error. | ||
562 | **/ | ||
563 | ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, | ||
564 | const void __user *from, size_t count) | ||
565 | { | ||
566 | loff_t pos = *ppos; | ||
567 | size_t res; | ||
568 | |||
569 | if (pos < 0) | ||
570 | return -EINVAL; | ||
571 | if (pos >= available || !count) | ||
572 | return 0; | ||
573 | if (count > available - pos) | ||
574 | count = available - pos; | ||
575 | res = copy_from_user(to + pos, from, count); | ||
576 | if (res == count) | ||
577 | return -EFAULT; | ||
578 | count -= res; | ||
579 | *ppos = pos + count; | ||
580 | return count; | ||
581 | } | ||
582 | |||
583 | /** | ||
550 | * memory_read_from_buffer - copy data from the buffer | 584 | * memory_read_from_buffer - copy data from the buffer |
551 | * @to: the kernel space buffer to read to | 585 | * @to: the kernel space buffer to read to |
552 | * @count: the maximum number of bytes to read | 586 | * @count: the maximum number of bytes to read |
@@ -864,6 +898,7 @@ EXPORT_SYMBOL(simple_statfs); | |||
864 | EXPORT_SYMBOL(simple_sync_file); | 898 | EXPORT_SYMBOL(simple_sync_file); |
865 | EXPORT_SYMBOL(simple_unlink); | 899 | EXPORT_SYMBOL(simple_unlink); |
866 | EXPORT_SYMBOL(simple_read_from_buffer); | 900 | EXPORT_SYMBOL(simple_read_from_buffer); |
901 | EXPORT_SYMBOL(simple_write_to_buffer); | ||
867 | EXPORT_SYMBOL(memory_read_from_buffer); | 902 | EXPORT_SYMBOL(memory_read_from_buffer); |
868 | EXPORT_SYMBOL(simple_transaction_set); | 903 | EXPORT_SYMBOL(simple_transaction_set); |
869 | EXPORT_SYMBOL(simple_transaction_get); | 904 | EXPORT_SYMBOL(simple_transaction_get); |