blob: dd33f040c52631bb1c5b5dd1a0b659b8e9693f4b [file] [log] [blame]
Gennady Sharapovbb578422005-11-07 00:58:50 -08001/*
2 * Copyright (C) 2001 Chris Emerson (cemerson@chiark.greenend.org.uk)
Jeff Dikec5d4bb12008-02-04 22:31:14 -08003 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
Gennady Sharapovbb578422005-11-07 00:58:50 -08004 * Licensed under the GPL
5 */
6
Jeff Dikec5d4bb12008-02-04 22:31:14 -08007/*
8 * These are here rather than tt/uaccess.c because skas mode needs them in
Gennady Sharapovbb578422005-11-07 00:58:50 -08009 * 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
WANG Cong99764fa2008-07-23 21:28:49 -070015static void __do_copy(void *to, const void *from, int n)
Gennady Sharapovbb578422005-11-07 00:58:50 -080016{
17 memcpy(to, from, n);
18}
19
20
21int __do_copy_to_user(void *to, const void *from, int n,
Jeff Dikefab95c52007-10-16 01:27:05 -070022 void **fault_addr, jmp_buf **fault_catcher)
Gennady Sharapovbb578422005-11-07 00:58:50 -080023{
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 Dikec5d4bb12008-02-04 22:31:14 -080029 if (!faulted)
30 return 0;
31 else
32 return n - (fault - (unsigned long) to);
Gennady Sharapovbb578422005-11-07 00:58:50 -080033}