aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-10-16 04:27:08 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:06 -0400
commit8ca842c4b5cbc70b9180617e9f26b6ac9f40dbb9 (patch)
treefe3e4deeae82c7063a72ecb3fdcae47422d6de0e /arch
parent28078e8f9790be0854a54f06de822689ab571944 (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')
-rw-r--r--arch/um/drivers/chan_user.c37
-rw-r--r--arch/um/drivers/harddog_user.c54
-rw-r--r--arch/um/include/mconsole.h13
-rw-r--r--arch/um/include/os.h1
-rw-r--r--arch/um/include/sysdep-i386/ptrace.h3
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h152
-rw-r--r--arch/um/kernel/skas/uaccess.c134
-rw-r--r--arch/um/os-Linux/file.c11
8 files changed, 186 insertions, 219 deletions
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
index 74f22d27327d..8443d372f67c 100644
--- a/arch/um/drivers/chan_user.c
+++ b/arch/um/drivers/chan_user.c
@@ -134,12 +134,12 @@ static int winch_thread(void *arg)
134 struct winch_data *data = arg; 134 struct winch_data *data = arg;
135 sigset_t sigs; 135 sigset_t sigs;
136 int pty_fd, pipe_fd; 136 int pty_fd, pipe_fd;
137 int count, err; 137 int count;
138 char c = 1; 138 char c = 1;
139 139
140 pty_fd = data->pty_fd; 140 pty_fd = data->pty_fd;
141 pipe_fd = data->pipe_fd; 141 pipe_fd = data->pipe_fd;
142 count = os_write_file(pipe_fd, &c, sizeof(c)); 142 count = write(pipe_fd, &c, sizeof(c));
143 if (count != sizeof(c)) 143 if (count != sizeof(c))
144 printk(UM_KERN_ERR "winch_thread : failed to write " 144 printk(UM_KERN_ERR "winch_thread : failed to write "
145 "synchronization byte, err = %d\n", -count); 145 "synchronization byte, err = %d\n", -count);
@@ -167,10 +167,15 @@ static int winch_thread(void *arg)
167 exit(1); 167 exit(1);
168 } 168 }
169 169
170 err = os_new_tty_pgrp(pty_fd, os_getpid()); 170 if(ioctl(pty_fd, TIOCSCTTY, 0) < 0){
171 if (err < 0) { 171 printk(UM_KERN_ERR "winch_thread : TIOCSCTTY failed on "
172 printk(UM_KERN_ERR "winch_thread : new_tty_pgrp failed on " 172 "fd %d err = %d\n", pty_fd, errno);
173 "fd %d err = %d\n", pty_fd, -err); 173 exit(1);
174 }
175
176 if(tcsetpgrp(pty_fd, os_getpid()) < 0){
177 printk(UM_KERN_ERR "winch_thread : tcsetpgrp failed on "
178 "fd %d err = %d\n", pty_fd, errno);
174 exit(1); 179 exit(1);
175 } 180 }
176 181
@@ -180,10 +185,10 @@ static int winch_thread(void *arg)
180 * kernel semaphores. We don't use SysV semaphores because they are 185 * kernel semaphores. We don't use SysV semaphores because they are
181 * persistent. 186 * persistent.
182 */ 187 */
183 count = os_read_file(pipe_fd, &c, sizeof(c)); 188 count = read(pipe_fd, &c, sizeof(c));
184 if (count != sizeof(c)) 189 if (count != sizeof(c))
185 printk(UM_KERN_ERR "winch_thread : failed to read " 190 printk(UM_KERN_ERR "winch_thread : failed to read "
186 "synchronization byte, err = %d\n", -count); 191 "synchronization byte, err = %d\n", errno);
187 192
188 while(1) { 193 while(1) {
189 /* 194 /*
@@ -192,10 +197,10 @@ static int winch_thread(void *arg)
192 */ 197 */
193 sigsuspend(&sigs); 198 sigsuspend(&sigs);
194 199
195 count = os_write_file(pipe_fd, &c, sizeof(c)); 200 count = write(pipe_fd, &c, sizeof(c));
196 if (count != sizeof(c)) 201 if (count != sizeof(c))
197 printk(UM_KERN_ERR "winch_thread : write failed, " 202 printk(UM_KERN_ERR "winch_thread : write failed, "
198 "err = %d\n", -count); 203 "err = %d\n", errno);
199 } 204 }
200} 205}
201 206
@@ -229,11 +234,11 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out,
229 } 234 }
230 235
231 *fd_out = fds[0]; 236 *fd_out = fds[0];
232 n = os_read_file(fds[0], &c, sizeof(c)); 237 n = read(fds[0], &c, sizeof(c));
233 if (n != sizeof(c)) { 238 if (n != sizeof(c)) {
234 printk(UM_KERN_ERR "winch_tramp : failed to read " 239 printk(UM_KERN_ERR "winch_tramp : failed to read "
235 "synchronization byte\n"); 240 "synchronization byte\n");
236 printk(UM_KERN_ERR "read failed, err = %d\n", -n); 241 printk(UM_KERN_ERR "read failed, err = %d\n", errno);
237 printk(UM_KERN_ERR "fd %d will not support SIGWINCH\n", fd); 242 printk(UM_KERN_ERR "fd %d will not support SIGWINCH\n", fd);
238 err = -EINVAL; 243 err = -EINVAL;
239 goto out_close; 244 goto out_close;
@@ -248,8 +253,8 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out,
248 return err; 253 return err;
249 254
250 out_close: 255 out_close:
251 os_close_file(fds[1]); 256 close(fds[1]);
252 os_close_file(fds[0]); 257 close(fds[0]);
253 out: 258 out:
254 return err; 259 return err;
255} 260}
@@ -271,9 +276,9 @@ void register_winch(int fd, struct tty_struct *tty)
271 276
272 register_winch_irq(thread_fd, fd, thread, tty, stack); 277 register_winch_irq(thread_fd, fd, thread, tty, stack);
273 278
274 count = os_write_file(thread_fd, &c, sizeof(c)); 279 count = write(thread_fd, &c, sizeof(c));
275 if (count != sizeof(c)) 280 if (count != sizeof(c))
276 printk(UM_KERN_ERR "register_winch : failed to write " 281 printk(UM_KERN_ERR "register_winch : failed to write "
277 "synchronization byte, err = %d\n", -count); 282 "synchronization byte, err = %d\n", errno);
278 } 283 }
279} 284}
diff --git a/arch/um/drivers/harddog_user.c b/arch/um/drivers/harddog_user.c
index 19ea26f32f14..b56f8e0196a9 100644
--- a/arch/um/drivers/harddog_user.c
+++ b/arch/um/drivers/harddog_user.c
@@ -1,14 +1,13 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <stdio.h> 6#include <stdio.h>
7#include <unistd.h> 7#include <unistd.h>
8#include <errno.h> 8#include <errno.h>
9#include "user.h"
10#include "mconsole.h"
11#include "os.h" 9#include "os.h"
10#include "user.h"
12 11
13struct dog_data { 12struct dog_data {
14 int stdin; 13 int stdin;
@@ -23,10 +22,10 @@ static void pre_exec(void *d)
23 dup2(data->stdin, 0); 22 dup2(data->stdin, 0);
24 dup2(data->stdout, 1); 23 dup2(data->stdout, 1);
25 dup2(data->stdout, 2); 24 dup2(data->stdout, 2);
26 os_close_file(data->stdin); 25 close(data->stdin);
27 os_close_file(data->stdout); 26 close(data->stdout);
28 os_close_file(data->close_me[0]); 27 close(data->close_me[0]);
29 os_close_file(data->close_me[1]); 28 close(data->close_me[1]);
30} 29}
31 30
32int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock) 31int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
@@ -40,13 +39,13 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
40 char **args = NULL; 39 char **args = NULL;
41 40
42 err = os_pipe(in_fds, 1, 0); 41 err = os_pipe(in_fds, 1, 0);
43 if(err < 0){ 42 if (err < 0) {
44 printk("harddog_open - os_pipe failed, err = %d\n", -err); 43 printk("harddog_open - os_pipe failed, err = %d\n", -err);
45 goto out; 44 goto out;
46 } 45 }
47 46
48 err = os_pipe(out_fds, 1, 0); 47 err = os_pipe(out_fds, 1, 0);
49 if(err < 0){ 48 if (err < 0) {
50 printk("harddog_open - os_pipe failed, err = %d\n", -err); 49 printk("harddog_open - os_pipe failed, err = %d\n", -err);
51 goto out_close_in; 50 goto out_close_in;
52 } 51 }
@@ -56,7 +55,7 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
56 data.close_me[0] = out_fds[1]; 55 data.close_me[0] = out_fds[1];
57 data.close_me[1] = in_fds[0]; 56 data.close_me[1] = in_fds[0];
58 57
59 if(sock != NULL){ 58 if (sock != NULL) {
60 mconsole_args[2] = sock; 59 mconsole_args[2] = sock;
61 args = mconsole_args; 60 args = mconsole_args;
62 } 61 }
@@ -68,25 +67,25 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
68 67
69 pid = run_helper(pre_exec, &data, args); 68 pid = run_helper(pre_exec, &data, args);
70 69
71 os_close_file(out_fds[0]); 70 close(out_fds[0]);
72 os_close_file(in_fds[1]); 71 close(in_fds[1]);
73 72
74 if(pid < 0){ 73 if (pid < 0) {
75 err = -pid; 74 err = -pid;
76 printk("harddog_open - run_helper failed, errno = %d\n", -err); 75 printk("harddog_open - run_helper failed, errno = %d\n", -err);
77 goto out_close_out; 76 goto out_close_out;
78 } 77 }
79 78
80 n = os_read_file(in_fds[0], &c, sizeof(c)); 79 n = read(in_fds[0], &c, sizeof(c));
81 if(n == 0){ 80 if (n == 0) {
82 printk("harddog_open - EOF on watchdog pipe\n"); 81 printk("harddog_open - EOF on watchdog pipe\n");
83 helper_wait(pid); 82 helper_wait(pid);
84 err = -EIO; 83 err = -EIO;
85 goto out_close_out; 84 goto out_close_out;
86 } 85 }
87 else if(n < 0){ 86 else if (n < 0) {
88 printk("harddog_open - read of watchdog pipe failed, " 87 printk("harddog_open - read of watchdog pipe failed, "
89 "err = %d\n", -n); 88 "err = %d\n", errno);
90 helper_wait(pid); 89 helper_wait(pid);
91 err = n; 90 err = n;
92 goto out_close_out; 91 goto out_close_out;
@@ -96,19 +95,19 @@ int start_watchdog(int *in_fd_ret, int *out_fd_ret, char *sock)
96 return 0; 95 return 0;
97 96
98 out_close_in: 97 out_close_in:
99 os_close_file(in_fds[0]); 98 close(in_fds[0]);
100 os_close_file(in_fds[1]); 99 close(in_fds[1]);
101 out_close_out: 100 out_close_out:
102 os_close_file(out_fds[0]); 101 close(out_fds[0]);
103 os_close_file(out_fds[1]); 102 close(out_fds[1]);
104 out: 103 out:
105 return err; 104 return err;
106} 105}
107 106
108void stop_watchdog(int in_fd, int out_fd) 107void stop_watchdog(int in_fd, int out_fd)
109{ 108{
110 os_close_file(in_fd); 109 close(in_fd);
111 os_close_file(out_fd); 110 close(out_fd);
112} 111}
113 112
114int ping_watchdog(int fd) 113int ping_watchdog(int fd)
@@ -116,10 +115,11 @@ int ping_watchdog(int fd)
116 int n; 115 int n;
117 char c = '\n'; 116 char c = '\n';
118 117
119 n = os_write_file(fd, &c, sizeof(c)); 118 n = write(fd, &c, sizeof(c));
120 if(n != sizeof(c)){ 119 if (n != sizeof(c)) {
121 printk("ping_watchdog - write failed, err = %d\n", -n); 120 printk("ping_watchdog - write failed, ret = %d, err = %d\n",
122 if(n < 0) 121 n, errno);
122 if (n < 0)
123 return n; 123 return n;
124 return -EIO; 124 return -EIO;
125 } 125 }
diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h
index a2c35fecd1f5..c139ae1d6826 100644
--- a/arch/um/include/mconsole.h
+++ b/arch/um/include/mconsole.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org) 2 * Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
3 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) 3 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4 * Licensed under the GPL 4 * Licensed under the GPL
5 */ 5 */
6 6
@@ -96,14 +96,3 @@ extern void lock_notify(void);
96extern void unlock_notify(void); 96extern void unlock_notify(void);
97 97
98#endif 98#endif
99
100/*
101 * Overrides for Emacs so that we follow Linus's tabbing style.
102 * Emacs will notice this stuff at the end of the file and automatically
103 * adjust the settings for this buffer only. This must remain at the end
104 * of the file.
105 * ---------------------------------------------------------------------------
106 * Local variables:
107 * c-file-style: "linux"
108 * End:
109 */
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index c704851d68b7..76048ba10875 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -132,7 +132,6 @@ extern void os_print_error(int error, const char* str);
132extern int os_get_exec_close(int fd, int *close_on_exec); 132extern int os_get_exec_close(int fd, int *close_on_exec);
133extern int os_set_exec_close(int fd, int close_on_exec); 133extern int os_set_exec_close(int fd, int close_on_exec);
134extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg); 134extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
135extern int os_new_tty_pgrp(int fd, int pid);
136extern int os_get_ifname(int fd, char *namebuf); 135extern int os_get_ifname(int fd, char *namebuf);
137extern int os_set_slip(int fd); 136extern int os_set_slip(int fd);
138extern int os_set_owner(int fd, int pid); 137extern int os_set_owner(int fd, int pid);
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h
index c0019d92fc73..edb9393283b5 100644
--- a/arch/um/include/sysdep-i386/ptrace.h
+++ b/arch/um/include/sysdep-i386/ptrace.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -130,7 +130,6 @@ struct syscall_args {
130 } \ 130 } \
131 val; \ 131 val; \
132 }) 132 })
133
134 133
135#define UPT_SET(regs, reg, val) \ 134#define UPT_SET(regs, reg, val) \
136 do { \ 135 do { \
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
index ebc2fd5dc31c..2ae04480ac81 100644
--- a/arch/um/include/sysdep-x86_64/ptrace.h
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -143,87 +143,87 @@ struct syscall_args {
143}; 143};
144 144
145#define SYSCALL_ARGS(r) ((struct syscall_args) \ 145#define SYSCALL_ARGS(r) ((struct syscall_args) \
146 { .args = { UPT_SYSCALL_ARG1(r), \ 146 { .args = { UPT_SYSCALL_ARG1(r), \
147 UPT_SYSCALL_ARG2(r), \ 147 UPT_SYSCALL_ARG2(r), \
148 UPT_SYSCALL_ARG3(r), \ 148 UPT_SYSCALL_ARG3(r), \
149 UPT_SYSCALL_ARG4(r), \ 149 UPT_SYSCALL_ARG4(r), \
150 UPT_SYSCALL_ARG5(r), \ 150 UPT_SYSCALL_ARG5(r), \
151 UPT_SYSCALL_ARG6(r) } } ) 151 UPT_SYSCALL_ARG6(r) } } )
152 152
153#define UPT_REG(regs, reg) \ 153#define UPT_REG(regs, reg) \
154 ({ unsigned long val; \ 154 ({ unsigned long val; \
155 switch(reg){ \ 155 switch(reg){ \
156 case R8: val = UPT_R8(regs); break; \ 156 case R8: val = UPT_R8(regs); break; \
157 case R9: val = UPT_R9(regs); break; \ 157 case R9: val = UPT_R9(regs); break; \
158 case R10: val = UPT_R10(regs); break; \ 158 case R10: val = UPT_R10(regs); break; \
159 case R11: val = UPT_R11(regs); break; \ 159 case R11: val = UPT_R11(regs); break; \
160 case R12: val = UPT_R12(regs); break; \ 160 case R12: val = UPT_R12(regs); break; \
161 case R13: val = UPT_R13(regs); break; \ 161 case R13: val = UPT_R13(regs); break; \
162 case R14: val = UPT_R14(regs); break; \ 162 case R14: val = UPT_R14(regs); break; \
163 case R15: val = UPT_R15(regs); break; \ 163 case R15: val = UPT_R15(regs); break; \
164 case RIP: val = UPT_IP(regs); break; \ 164 case RIP: val = UPT_IP(regs); break; \
165 case RSP: val = UPT_SP(regs); break; \ 165 case RSP: val = UPT_SP(regs); break; \
166 case RAX: val = UPT_RAX(regs); break; \ 166 case RAX: val = UPT_RAX(regs); break; \
167 case RBX: val = UPT_RBX(regs); break; \ 167 case RBX: val = UPT_RBX(regs); break; \
168 case RCX: val = UPT_RCX(regs); break; \ 168 case RCX: val = UPT_RCX(regs); break; \
169 case RDX: val = UPT_RDX(regs); break; \ 169 case RDX: val = UPT_RDX(regs); break; \
170 case RSI: val = UPT_RSI(regs); break; \ 170 case RSI: val = UPT_RSI(regs); break; \
171 case RDI: val = UPT_RDI(regs); break; \ 171 case RDI: val = UPT_RDI(regs); break; \
172 case RBP: val = UPT_RBP(regs); break; \ 172 case RBP: val = UPT_RBP(regs); break; \
173 case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \ 173 case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \
174 case CS: val = UPT_CS(regs); break; \ 174 case CS: val = UPT_CS(regs); break; \
175 case SS: val = UPT_SS(regs); break; \ 175 case SS: val = UPT_SS(regs); break; \
176 case FS_BASE: val = UPT_FS_BASE(regs); break; \ 176 case FS_BASE: val = UPT_FS_BASE(regs); break; \
177 case GS_BASE: val = UPT_GS_BASE(regs); break; \ 177 case GS_BASE: val = UPT_GS_BASE(regs); break; \
178 case DS: val = UPT_DS(regs); break; \ 178 case DS: val = UPT_DS(regs); break; \
179 case ES: val = UPT_ES(regs); break; \ 179 case ES: val = UPT_ES(regs); break; \
180 case FS : val = UPT_FS (regs); break; \ 180 case FS : val = UPT_FS (regs); break; \
181 case GS: val = UPT_GS(regs); break; \ 181 case GS: val = UPT_GS(regs); break; \
182 case EFLAGS: val = UPT_EFLAGS(regs); break; \ 182 case EFLAGS: val = UPT_EFLAGS(regs); break; \
183 default : \ 183 default : \
184 panic("Bad register in UPT_REG : %d\n", reg); \ 184 panic("Bad register in UPT_REG : %d\n", reg); \
185 val = -1; \ 185 val = -1; \
186 } \ 186 } \
187 val; \ 187 val; \
188 }) 188 })
189 189
190 190
191#define UPT_SET(regs, reg, val) \ 191#define UPT_SET(regs, reg, val) \
192 ({ unsigned long __upt_val = val; \ 192 ({ unsigned long __upt_val = val; \
193 switch(reg){ \ 193 switch(reg){ \
194 case R8: UPT_R8(regs) = __upt_val; break; \ 194 case R8: UPT_R8(regs) = __upt_val; break; \
195 case R9: UPT_R9(regs) = __upt_val; break; \ 195 case R9: UPT_R9(regs) = __upt_val; break; \
196 case R10: UPT_R10(regs) = __upt_val; break; \ 196 case R10: UPT_R10(regs) = __upt_val; break; \
197 case R11: UPT_R11(regs) = __upt_val; break; \ 197 case R11: UPT_R11(regs) = __upt_val; break; \
198 case R12: UPT_R12(regs) = __upt_val; break; \ 198 case R12: UPT_R12(regs) = __upt_val; break; \
199 case R13: UPT_R13(regs) = __upt_val; break; \ 199 case R13: UPT_R13(regs) = __upt_val; break; \
200 case R14: UPT_R14(regs) = __upt_val; break; \ 200 case R14: UPT_R14(regs) = __upt_val; break; \
201 case R15: UPT_R15(regs) = __upt_val; break; \ 201 case R15: UPT_R15(regs) = __upt_val; break; \
202 case RIP: UPT_IP(regs) = __upt_val; break; \ 202 case RIP: UPT_IP(regs) = __upt_val; break; \
203 case RSP: UPT_SP(regs) = __upt_val; break; \ 203 case RSP: UPT_SP(regs) = __upt_val; break; \
204 case RAX: UPT_RAX(regs) = __upt_val; break; \ 204 case RAX: UPT_RAX(regs) = __upt_val; break; \
205 case RBX: UPT_RBX(regs) = __upt_val; break; \ 205 case RBX: UPT_RBX(regs) = __upt_val; break; \
206 case RCX: UPT_RCX(regs) = __upt_val; break; \ 206 case RCX: UPT_RCX(regs) = __upt_val; break; \
207 case RDX: UPT_RDX(regs) = __upt_val; break; \ 207 case RDX: UPT_RDX(regs) = __upt_val; break; \
208 case RSI: UPT_RSI(regs) = __upt_val; break; \ 208 case RSI: UPT_RSI(regs) = __upt_val; break; \
209 case RDI: UPT_RDI(regs) = __upt_val; break; \ 209 case RDI: UPT_RDI(regs) = __upt_val; break; \
210 case RBP: UPT_RBP(regs) = __upt_val; break; \ 210 case RBP: UPT_RBP(regs) = __upt_val; break; \
211 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \ 211 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \
212 case CS: UPT_CS(regs) = __upt_val; break; \ 212 case CS: UPT_CS(regs) = __upt_val; break; \
213 case SS: UPT_SS(regs) = __upt_val; break; \ 213 case SS: UPT_SS(regs) = __upt_val; break; \
214 case FS_BASE: UPT_FS_BASE(regs) = __upt_val; break; \ 214 case FS_BASE: UPT_FS_BASE(regs) = __upt_val; break; \
215 case GS_BASE: UPT_GS_BASE(regs) = __upt_val; break; \ 215 case GS_BASE: UPT_GS_BASE(regs) = __upt_val; break; \
216 case DS: UPT_DS(regs) = __upt_val; break; \ 216 case DS: UPT_DS(regs) = __upt_val; break; \
217 case ES: UPT_ES(regs) = __upt_val; break; \ 217 case ES: UPT_ES(regs) = __upt_val; break; \
218 case FS: UPT_FS(regs) = __upt_val; break; \ 218 case FS: UPT_FS(regs) = __upt_val; break; \
219 case GS: UPT_GS(regs) = __upt_val; break; \ 219 case GS: UPT_GS(regs) = __upt_val; break; \
220 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \ 220 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \
221 default : \ 221 default : \
222 panic("Bad register in UPT_SET : %d\n", reg); \ 222 panic("Bad register in UPT_SET : %d\n", reg); \
223 break; \ 223 break; \
224 } \ 224 } \
225 __upt_val; \ 225 __upt_val; \
226 }) 226 })
227 227
228#define UPT_SET_SYSCALL_RETURN(r, res) \ 228#define UPT_SET_SYSCALL_RETURN(r, res) \
229 REGS_SET_SYSCALL_RETURN((r)->regs, (res)) 229 REGS_SET_SYSCALL_RETURN((r)->regs, (res))
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c
index b14422e2c07c..1d8b119f2d0e 100644
--- a/arch/um/kernel/skas/uaccess.c
+++ b/arch/um/kernel/skas/uaccess.c
@@ -1,18 +1,14 @@
1/* 1/*
2 * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com) 2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/compiler.h" 6#include "linux/err.h"
7#include "linux/stddef.h"
8#include "linux/kernel.h"
9#include "linux/string.h"
10#include "linux/fs.h"
11#include "linux/hardirq.h"
12#include "linux/highmem.h" 7#include "linux/highmem.h"
8#include "linux/mm.h"
9#include "asm/current.h"
13#include "asm/page.h" 10#include "asm/page.h"
14#include "asm/pgtable.h" 11#include "asm/pgtable.h"
15#include "asm/uaccess.h"
16#include "kern_util.h" 12#include "kern_util.h"
17#include "os.h" 13#include "os.h"
18 14
@@ -27,16 +23,16 @@ static unsigned long maybe_map(unsigned long virt, int is_write)
27 void *phys = um_virt_to_phys(current, virt, &pte); 23 void *phys = um_virt_to_phys(current, virt, &pte);
28 int dummy_code; 24 int dummy_code;
29 25
30 if(IS_ERR(phys) || (is_write && !pte_write(pte))){ 26 if (IS_ERR(phys) || (is_write && !pte_write(pte))) {
31 err = handle_page_fault(virt, 0, is_write, 1, &dummy_code); 27 err = handle_page_fault(virt, 0, is_write, 1, &dummy_code);
32 if(err) 28 if (err)
33 return(-1UL); 29 return -1UL;
34 phys = um_virt_to_phys(current, virt, NULL); 30 phys = um_virt_to_phys(current, virt, NULL);
35 } 31 }
36 if(IS_ERR(phys)) 32 if (IS_ERR(phys))
37 phys = (void *) -1; 33 phys = (void *) -1;
38 34
39 return((unsigned long) phys); 35 return (unsigned long) phys;
40} 36}
41 37
42static int do_op_one_page(unsigned long addr, int len, int is_write, 38static 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,
46 int n; 42 int n;
47 43
48 addr = maybe_map(addr, is_write); 44 addr = maybe_map(addr, is_write);
49 if(addr == -1UL) 45 if (addr == -1UL)
50 return(-1); 46 return -1;
51 47
52 page = phys_to_page(addr); 48 page = phys_to_page(addr);
53 addr = (unsigned long) kmap_atomic(page, KM_UML_USERCOPY) + (addr & ~PAGE_MASK); 49 addr = (unsigned long) kmap_atomic(page, KM_UML_USERCOPY) +
50 (addr & ~PAGE_MASK);
54 51
55 n = (*op)(addr, len, arg); 52 n = (*op)(addr, len, arg);
56 53
57 kunmap_atomic(page, KM_UML_USERCOPY); 54 kunmap_atomic(page, KM_UML_USERCOPY);
58 55
59 return(n); 56 return n;
60} 57}
61 58
62static void do_buffer_op(void *jmpbuf, void *arg_ptr) 59static void do_buffer_op(void *jmpbuf, void *arg_ptr)
@@ -81,21 +78,21 @@ static void do_buffer_op(void *jmpbuf, void *arg_ptr)
81 78
82 current->thread.fault_catcher = jmpbuf; 79 current->thread.fault_catcher = jmpbuf;
83 n = do_op_one_page(addr, size, is_write, op, arg); 80 n = do_op_one_page(addr, size, is_write, op, arg);
84 if(n != 0){ 81 if (n != 0) {
85 *res = (n < 0 ? remain : 0); 82 *res = (n < 0 ? remain : 0);
86 goto out; 83 goto out;
87 } 84 }
88 85
89 addr += size; 86 addr += size;
90 remain -= size; 87 remain -= size;
91 if(remain == 0){ 88 if (remain == 0) {
92 *res = 0; 89 *res = 0;
93 goto out; 90 goto out;
94 } 91 }
95 92
96 while(addr < ((addr + remain) & PAGE_MASK)){ 93 while(addr < ((addr + remain) & PAGE_MASK)) {
97 n = do_op_one_page(addr, PAGE_SIZE, is_write, op, arg); 94 n = do_op_one_page(addr, PAGE_SIZE, is_write, op, arg);
98 if(n != 0){ 95 if (n != 0) {
99 *res = (n < 0 ? remain : 0); 96 *res = (n < 0 ? remain : 0);
100 goto out; 97 goto out;
101 } 98 }
@@ -103,13 +100,13 @@ static void do_buffer_op(void *jmpbuf, void *arg_ptr)
103 addr += PAGE_SIZE; 100 addr += PAGE_SIZE;
104 remain -= PAGE_SIZE; 101 remain -= PAGE_SIZE;
105 } 102 }
106 if(remain == 0){ 103 if (remain == 0) {
107 *res = 0; 104 *res = 0;
108 goto out; 105 goto out;
109 } 106 }
110 107
111 n = do_op_one_page(addr, remain, is_write, op, arg); 108 n = do_op_one_page(addr, remain, is_write, op, arg);
112 if(n != 0) 109 if (n != 0)
113 *res = (n < 0 ? remain : 0); 110 *res = (n < 0 ? remain : 0);
114 else *res = 0; 111 else *res = 0;
115 out: 112 out:
@@ -124,10 +121,10 @@ static int buffer_op(unsigned long addr, int len, int is_write,
124 121
125 faulted = setjmp_wrapper(do_buffer_op, addr, len, is_write, op, arg, 122 faulted = setjmp_wrapper(do_buffer_op, addr, len, is_write, op, arg,
126 &res); 123 &res);
127 if(!faulted) 124 if (!faulted)
128 return(res); 125 return res;
129 126
130 return(addr + len - (unsigned long) current->thread.fault_addr); 127 return addr + len - (unsigned long) current->thread.fault_addr;
131} 128}
132 129
133static int copy_chunk_from_user(unsigned long from, int len, void *arg) 130static 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)
136 133
137 memcpy((void *) to, (void *) from, len); 134 memcpy((void *) to, (void *) from, len);
138 *to_ptr += len; 135 *to_ptr += len;
139 return(0); 136 return 0;
140} 137}
141 138
142int copy_from_user(void *to, const void __user *from, int n) 139int copy_from_user(void *to, const void __user *from, int n)
143{ 140{
144 if(segment_eq(get_fs(), KERNEL_DS)){ 141 if (segment_eq(get_fs(), KERNEL_DS)) {
145 memcpy(to, (__force void*)from, n); 142 memcpy(to, (__force void*)from, n);
146 return(0); 143 return 0;
147 } 144 }
148 145
149 return(access_ok(VERIFY_READ, from, n) ? 146 return access_ok(VERIFY_READ, from, n) ?
150 buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to): 147 buffer_op((unsigned long) from, n, 0, copy_chunk_from_user, &to):
151 n); 148 n;
152} 149}
153 150
154static int copy_chunk_to_user(unsigned long to, int len, void *arg) 151static 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)
157 154
158 memcpy((void *) to, (void *) from, len); 155 memcpy((void *) to, (void *) from, len);
159 *from_ptr += len; 156 *from_ptr += len;
160 return(0); 157 return 0;
161} 158}
162 159
163int copy_to_user(void __user *to, const void *from, int n) 160int copy_to_user(void __user *to, const void *from, int n)
164{ 161{
165 if(segment_eq(get_fs(), KERNEL_DS)){ 162 if (segment_eq(get_fs(), KERNEL_DS)) {
166 memcpy((__force void*)to, from, n); 163 memcpy((__force void *) to, from, n);
167 return(0); 164 return 0;
168 } 165 }
169 166
170 return(access_ok(VERIFY_WRITE, to, n) ? 167 return access_ok(VERIFY_WRITE, to, n) ?
171 buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from) : 168 buffer_op((unsigned long) to, n, 1, copy_chunk_to_user, &from) :
172 n); 169 n;
173} 170}
174 171
175static int strncpy_chunk_from_user(unsigned long from, int len, void *arg) 172static 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)
181 n = strnlen(to, len); 178 n = strnlen(to, len);
182 *to_ptr += n; 179 *to_ptr += n;
183 180
184 if(n < len) 181 if (n < len)
185 return(1); 182 return 1;
186 return(0); 183 return 0;
187} 184}
188 185
189int strncpy_from_user(char *dst, const char __user *src, int count) 186int 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)
191 int n; 188 int n;
192 char *ptr = dst; 189 char *ptr = dst;
193 190
194 if(segment_eq(get_fs(), KERNEL_DS)){ 191 if (segment_eq(get_fs(), KERNEL_DS)) {
195 strncpy(dst, (__force void*)src, count); 192 strncpy(dst, (__force void *) src, count);
196 return(strnlen(dst, count)); 193 return strnlen(dst, count);
197 } 194 }
198 195
199 if(!access_ok(VERIFY_READ, src, 1)) 196 if (!access_ok(VERIFY_READ, src, 1))
200 return(-EFAULT); 197 return -EFAULT;
201 198
202 n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user, 199 n = buffer_op((unsigned long) src, count, 0, strncpy_chunk_from_user,
203 &ptr); 200 &ptr);
204 if(n != 0) 201 if (n != 0)
205 return(-EFAULT); 202 return -EFAULT;
206 return(strnlen(dst, count)); 203 return strnlen(dst, count);
207} 204}
208 205
209static int clear_chunk(unsigned long addr, int len, void *unused) 206static int clear_chunk(unsigned long addr, int len, void *unused)
210{ 207{
211 memset((void *) addr, 0, len); 208 memset((void *) addr, 0, len);
212 return(0); 209 return 0;
213} 210}
214 211
215int __clear_user(void __user *mem, int len) 212int __clear_user(void __user *mem, int len)
216{ 213{
217 return(buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL)); 214 return buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL);
218} 215}
219 216
220int clear_user(void __user *mem, int len) 217int clear_user(void __user *mem, int len)
221{ 218{
222 if(segment_eq(get_fs(), KERNEL_DS)){ 219 if (segment_eq(get_fs(), KERNEL_DS)) {
223 memset((__force void*)mem, 0, len); 220 memset((__force void*)mem, 0, len);
224 return(0); 221 return 0;
225 } 222 }
226 223
227 return(access_ok(VERIFY_WRITE, mem, len) ? 224 return access_ok(VERIFY_WRITE, mem, len) ?
228 buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len); 225 buffer_op((unsigned long) mem, len, 1, clear_chunk, NULL) : len;
229} 226}
230 227
231static int strnlen_chunk(unsigned long str, int len, void *arg) 228static 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)
235 n = strnlen((void *) str, len); 232 n = strnlen((void *) str, len);
236 *len_ptr += n; 233 *len_ptr += n;
237 234
238 if(n < len) 235 if (n < len)
239 return(1); 236 return 1;
240 return(0); 237 return 0;
241} 238}
242 239
243int strnlen_user(const void __user *str, int len) 240int strnlen_user(const void __user *str, int len)
244{ 241{
245 int count = 0, n; 242 int count = 0, n;
246 243
247 if(segment_eq(get_fs(), KERNEL_DS)) 244 if (segment_eq(get_fs(), KERNEL_DS))
248 return(strnlen((__force char*)str, len) + 1); 245 return strnlen((__force char*)str, len) + 1;
249 246
250 n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count); 247 n = buffer_op((unsigned long) str, len, 0, strnlen_chunk, &count);
251 if(n == 0) 248 if (n == 0)
252 return(count + 1); 249 return count + 1;
253 return(-EFAULT); 250 return -EFAULT;
254} 251}
255
256/*
257 * Overrides for Emacs so that we follow Linus's tabbing style.
258 * Emacs will notice this stuff at the end of the file and automatically
259 * adjust the settings for this buffer only. This must remain at the end
260 * of the file.
261 * ---------------------------------------------------------------------------
262 * Local variables:
263 * c-file-style: "linux"
264 * End:
265 */
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index d463a8205637..5f10c3031ef2 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -101,17 +101,6 @@ int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg)
101 return err; 101 return err;
102} 102}
103 103
104int os_new_tty_pgrp(int fd, int pid)
105{
106 if(ioctl(fd, TIOCSCTTY, 0) < 0)
107 return -errno;
108
109 if(tcsetpgrp(fd, pid) < 0)
110 return -errno;
111
112 return 0;
113}
114
115/* FIXME: ensure namebuf in os_get_if_name is big enough */ 104/* FIXME: ensure namebuf in os_get_if_name is big enough */
116int os_get_ifname(int fd, char* namebuf) 105int os_get_ifname(int fd, char* namebuf)
117{ 106{