Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk) |
Jeff Dike | c5d4bb1 | 2008-02-04 22:31:14 -0800 | [diff] [blame] | 3 | * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 4 | * Licensed under the GPL |
| 5 | */ |
| 6 | |
Jeff Dike | c5d4bb1 | 2008-02-04 22:31:14 -0800 | [diff] [blame] | 7 | /* |
| 8 | * These are here rather than tt/uaccess.c because skas mode needs them in |
Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 9 | * order to do SIGBUS recovery when a tmpfs mount runs out of room. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/string.h> |
| 13 | #include "os.h" |
| 14 | |
| 15 | void __do_copy(void *to, const void *from, int n) |
| 16 | { |
| 17 | memcpy(to, from, n); |
| 18 | } |
| 19 | |
| 20 | |
| 21 | int __do_copy_to_user(void *to, const void *from, int n, |
Jeff Dike | fab95c5 | 2007-10-16 01:27:05 -0700 | [diff] [blame] | 22 | void **fault_addr, jmp_buf **fault_catcher) |
Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 23 | { |
| 24 | unsigned long fault; |
| 25 | int faulted; |
| 26 | |
| 27 | fault = __do_user_copy(to, from, n, fault_addr, fault_catcher, |
| 28 | __do_copy, &faulted); |
Jeff Dike | c5d4bb1 | 2008-02-04 22:31:14 -0800 | [diff] [blame] | 29 | if (!faulted) |
| 30 | return 0; |
| 31 | else |
| 32 | return n - (fault - (unsigned long) to); |
Gennady Sharapov | bb57842 | 2005-11-07 00:58:50 -0800 | [diff] [blame] | 33 | } |