Skip to content

Commit

Permalink
[PATCH] uml: fix usage of kernel_errno in place of errno
Browse files Browse the repository at this point in the history
To avoid conflicts, in kernel files errno is expanded to kernel_errno, to
distinguish it from glibc errno.  In this case, the code wants to use the libc
errno but the kernel one is used; in the other usage, we return errno in place
of -errno in case of an error.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Acked-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Paolo 'Blaisorblade' Giarrusso authored and Linus Torvalds committed Feb 24, 2006
1 parent 31bc5a3 commit 07f4e2c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions arch/um/include/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ extern void os_stop_process(int pid);
extern void os_kill_process(int pid, int reap_child);
extern void os_kill_ptraced_process(int pid, int reap_child);
extern void os_usr1_process(int pid);
extern long os_ptrace_ldt(long pid, long addr, long data);

extern int os_getpid(void);
extern int os_getpgrp(void);

extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
extern void init_new_thread_signals(int altstack);
extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
Expand Down
16 changes: 16 additions & 0 deletions arch/um/os-Linux/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "irq_user.h"
#include "kern_util.h"
#include "longjmp.h"
#include "skas_ptrace.h"

#define ARBITRARY_ADDR -1
#define FAILURE_PID -1
Expand Down Expand Up @@ -100,6 +101,21 @@ void os_kill_process(int pid, int reap_child)

}

/* This is here uniquely to have access to the userspace errno, i.e. the one
* used by ptrace in case of error.
*/

long os_ptrace_ldt(long pid, long addr, long data)
{
int ret;

ret = ptrace(PTRACE_LDT, pid, addr, data);

if (ret < 0)
return -errno;
return ret;
}

/* Kill off a ptraced child by all means available. kill it normally first,
* then PTRACE_KILL it, then PTRACE_CONT it in case it's in a run state from
* which it can't exit directly.
Expand Down
9 changes: 3 additions & 6 deletions arch/um/sys-i386/ldt.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
* So we need to switch child's mm into our userspace, then
* later switch back.
*
* Note: I'm unshure: should interrupts be disabled here?
* Note: I'm unsure: should interrupts be disabled here?
*/
if(!current->active_mm || current->active_mm == &init_mm ||
mm_idp != &current->active_mm->context.skas.id)
Expand All @@ -129,9 +129,7 @@ long write_ldt_entry(struct mm_id * mm_idp, int func, struct user_desc * desc,
pid = userspace_pid[cpu];
}

res = ptrace(PTRACE_LDT, pid, 0, (unsigned long) &ldt_op);
if(res)
res = errno;
res = os_ptrace_ldt(pid, 0, (unsigned long) &ldt_op);

if(proc_mm)
put_cpu();
Expand Down Expand Up @@ -181,8 +179,7 @@ static long read_ldt_from_host(void __user * ptr, unsigned long bytecount)
*/

cpu = get_cpu();
res = ptrace(PTRACE_LDT, userspace_pid[cpu], 0,
(unsigned long) &ptrace_ldt);
res = os_ptrace_ldt(userspace_pid[cpu], 0, (unsigned long) &ptrace_ldt);
put_cpu();
if(res < 0)
goto out;
Expand Down

0 comments on commit 07f4e2c

Please sign in to comment.