diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-10-16 01:27:08 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 09:43:06 -0700 |
commit | 8ca842c4b5cbc70b9180617e9f26b6ac9f40dbb9 (patch) | |
tree | fe3e4deeae82c7063a72ecb3fdcae47422d6de0e /arch/um/kernel/skas/uaccess.c | |
parent | 28078e8f9790be0854a54f06de822689ab571944 (diff) |
uml: remove os_* usage from userspace files
This patch fixes some userspace files which were calling libc through the os_*
wrappers.
It turns out that there was only one user of os_new_tty_pgrp, so it can be
deleted.
There are also some style and whitespace fixes in here.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/kernel/skas/uaccess.c')
-rw-r--r-- | arch/um/kernel/skas/uaccess.c | 134 |
1 files changed, 60 insertions, 74 deletions
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c index b14422e2c07..1d8b119f2d0 100644 --- a/arch/um/kernel/skas/uaccess.c +++ b/arch/um/kernel/skas/uaccess.c @@ -1,18 +1,14 @@ /* - * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com) + * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) * Licensed under the GPL */ -#include "linux/compiler.h" -#include "linux/stddef.h" -#include "linux/kernel.h" -#include "linux/string.h" -#include "linux/fs.h" -#include "linux/hardirq.h" +#include "linux/err.h" #include "linux/highmem.h" +#include "linux/mm.h" +#include "asm/current.h" #include "asm/page.h" #include "asm/pgtable.h" -#include "asm/uaccess.h" #include "kern_util.h" #include "os.h" @@ -27,16 +23,16 @@ static unsigned long maybe_map(unsigned long virt, int is_write) void *phys = um_virt_to_phys(current, virt, &pte); int dummy_code; - if(IS_ERR(phys) || (is_write && !pte_write(pte))){ + if (IS_ERR(phys) || (is_write && !pte_write(pte))) { err = handle_page_fault(virt, 0, is_write, 1, &dummy_code); - if(err) - return(-1UL); + if (err) + return -1UL; phys = um_virt_to_phys(current, virt, NULL); } - if(IS_ERR(phys)) - phys = (void *) -1; + if (IS_ERR(phys)) + phys = (void *) -1; - return((unsigned long) phys); + return (unsigned long) phys; } static int do_op_one_page(unsigned long addr, int len, int is_write, @@ -46,17 +42,18 @@ static int do_op_one_page(unsigned long addr, int len, int is_write, int n; addr = maybe_map(addr, is_write); - if(addr == -1UL) - return(-1); + if (addr == -1UL) + return -1; page = phys_to_page(addr); - addr = (unsigned long) kmap_atomic(page, KM_UML_USERCOPY) + (addr & ~PAGE_MASK); + addr = (unsigned long) kmap_atomic(page, KM_UML_USERCOPY) + + (addr & ~PAGE_MASK); n = (*op)(addr, len, arg); kunmap_atomic(page, KM_UML_USERCOPY); - return(n); + return n; } static void do_buffer_op(void *jmpbuf, void *arg_ptr) @@ -81,21 +78,21 @@ static void do_buffer_op(void *jmpbuf, void *arg_ptr) current->thread.fault_catcher = jmpbuf; n = do_op_one_page(addr, size, is_write, op, arg); - if(n != 0){ + if (n != 0) { *res = (n < 0 ? remain : 0); goto out; } addr += size; remain -= size; - if(remain == 0){ + if (remain == 0) { *res = 0; goto out; } - while(addr < ((addr + remain) & PAGE_MASK)){ + while(addr < ((addr + remain) & PAGE_MASK)) { n = do_op_one_page(addr, PAGE_SIZE, is_write, op, arg); - if(n != 0){ + if (n != 0) { *res = (n < 0 ? remain : 0); goto out; } @@ -103,13 +100,13 @@ static void do_buffer_op(void *jmpbuf, void *arg_ptr) addr += PAGE_SIZE; remain -= PAGE_SIZE; } - if(remain == 0){ + if (remain == 0) { *res = 0; goto out; } n = do_op_one_page(addr, remain, is_write, op, arg); - if(n != 0) + if (n != 0) *res = (n < 0 ? remain : 0); else *res = 0; out: @@ -124,10 +121,10 @@ static int buffer_op(unsigned long addr, int len, int is_write, faulted = setjmp_wrapper(do_buffer_op, addr, len, is_write, op, arg, &res); - if(!faulted) - return(res); + if (!faulted) + return res; - return(addr + len - (unsigned long) current->thread.fault_addr); + return addr + len - (unsigned long) current->thread.fault_addr; } static int copy_chunk_from_user(unsigned long from, int len, void *arg) @@ -136,19 +133,19 @@ static int copy_chunk_from_user(unsigned long from, int len, void *arg) memcpy((void *) to, (void *) from, len); *to_ptr += len; - return(0); + return 0; } int copy_from_user(void *to, const void __user *from, int n) { - if(segment_eq(get_fs(), KERNEL_DS)){ + if (segment_eq(get_fs(), KERNEL_DS)) { memcpy(to, (__force void*)from, n); - return(0); + return 0; } - return(access_ok(VERIFY_READ, from, n) ? + return access_ok(VERIFY_READ, from, n) ? buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to): - n); + n; } static int copy_chunk_to_user(unsigned long to, int len, void *arg) @@ -157,19 +154,19 @@ static int copy_chunk_to_user(unsigned long to, int len, void *arg) memcpy((void *) to, (void *) from, len); *from_ptr += len; - return(0); + return 0; } int copy_to_user(void __user *to, const void *from, int n) { - if(segment_eq(get_fs(), KERNEL_DS)){ - memcpy((__force void*)to, from, n); - return(0); + if (segment_eq(get_fs(), KERNEL_DS)) { + memcpy((__force void *) to, from, n); + return 0; } - return(access_ok(VERIFY_WRITE, to, n) ? + return access_ok(VERIFY_WRITE, to, n) ? buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from) : - n); + n; } static int strncpy_chunk_from_user(unsigned long from, int len, void *arg) @@ -181,9 +178,9 @@ static int strncpy_chunk_from_user(unsigned long from, int len, void *arg) n = strnlen(to, len); *to_ptr += n; - if(n < len) - return(1); - return(0); + if (n < len) + return 1; + return 0; } int strncpy_from_user(char *dst, const char __user *src, int count) @@ -191,41 +188,41 @@ int strncpy_from_user(char *dst, const char __user *src, int count) int n; char *ptr = dst; - if(segment_eq(get_fs(), KERNEL_DS)){ - strncpy(dst, (__force void*)src, count); - return(strnlen(dst, count)); + if (segment_eq(get_fs(), KERNEL_DS)) { + strncpy(dst, (__force void *) src, count); + return strnlen(dst, count); } - if(!access_ok(VERIFY_READ, src, 1)) - return(-EFAULT); + if (!access_ok(VERIFY_READ, src, 1)) + return -EFAULT; n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user, &ptr); - if(n != 0) - return(-EFAULT); - return(strnlen(dst, count)); + if (n != 0) + return -EFAULT; + return strnlen(dst, count); } static int clear_chunk(unsigned long addr, int len, void *unused) { memset((void *) addr, 0, len); - return(0); + return 0; } int __clear_user(void __user *mem, int len) { - return(buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL)); + return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL); } int clear_user(void __user *mem, int len) { - if(segment_eq(get_fs(), KERNEL_DS)){ + if (segment_eq(get_fs(), KERNEL_DS)) { memset((__force void*)mem, 0, len); - return(0); + return 0; } - return(access_ok(VERIFY_WRITE, mem, len) ? - buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len); + return access_ok(VERIFY_WRITE, mem, len) ? + buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len; } static int strnlen_chunk(unsigned long str, int len, void *arg) @@ -235,31 +232,20 @@ static int strnlen_chunk(unsigned long str, int len, void *arg) n = strnlen((void *) str, len); *len_ptr += n; - if(n < len) - return(1); - return(0); + if (n < len) + return 1; + return 0; } int strnlen_user(const void __user *str, int len) { int count = 0, n; - if(segment_eq(get_fs(), KERNEL_DS)) - return(strnlen((__force char*)str, len) + 1); + if (segment_eq(get_fs(), KERNEL_DS)) + return strnlen((__force char*)str, len) + 1; n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count); - if(n == 0) - return(count + 1); - return(-EFAULT); + if (n == 0) + return count + 1; + return -EFAULT; } - -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ |