root / linux-user / syscall.c @ 982b4315
History | View | Annotate | Download (79.5 kB)
1 |
/*
|
---|---|
2 |
* Linux syscalls
|
3 |
*
|
4 |
* Copyright (c) 2003 Fabrice Bellard
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
19 |
*/
|
20 |
#include <stdlib.h> |
21 |
#include <stdio.h> |
22 |
#include <stdarg.h> |
23 |
#include <string.h> |
24 |
#include <elf.h> |
25 |
#include <endian.h> |
26 |
#include <errno.h> |
27 |
#include <unistd.h> |
28 |
#include <fcntl.h> |
29 |
#include <time.h> |
30 |
#include <sys/types.h> |
31 |
#include <sys/wait.h> |
32 |
#include <sys/time.h> |
33 |
#include <sys/stat.h> |
34 |
#include <sys/mount.h> |
35 |
#include <sys/resource.h> |
36 |
#include <sys/mman.h> |
37 |
#include <sys/swap.h> |
38 |
#include <signal.h> |
39 |
#include <sched.h> |
40 |
#include <sys/socket.h> |
41 |
#include <sys/uio.h> |
42 |
#include <sys/poll.h> |
43 |
#include <sys/times.h> |
44 |
//#include <sys/user.h>
|
45 |
#include <netinet/tcp.h> |
46 |
|
47 |
#define termios host_termios
|
48 |
#define winsize host_winsize
|
49 |
#define termio host_termio
|
50 |
#define sgttyb host_sgttyb /* same as target */ |
51 |
#define tchars host_tchars /* same as target */ |
52 |
#define ltchars host_ltchars /* same as target */ |
53 |
|
54 |
#include <linux/termios.h> |
55 |
#include <linux/unistd.h> |
56 |
#include <linux/utsname.h> |
57 |
#include <linux/cdrom.h> |
58 |
#include <linux/hdreg.h> |
59 |
#include <linux/soundcard.h> |
60 |
#include <linux/dirent.h> |
61 |
#include <linux/kd.h> |
62 |
|
63 |
#include "qemu.h" |
64 |
|
65 |
//#define DEBUG
|
66 |
|
67 |
#ifndef PAGE_SIZE
|
68 |
#define PAGE_SIZE 4096 |
69 |
#define PAGE_MASK ~(PAGE_SIZE - 1) |
70 |
#endif
|
71 |
|
72 |
//#include <linux/msdos_fs.h>
|
73 |
#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2]) |
74 |
#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2]) |
75 |
|
76 |
void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info); |
77 |
void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo); |
78 |
long do_sigreturn(CPUX86State *env);
|
79 |
long do_rt_sigreturn(CPUX86State *env);
|
80 |
|
81 |
#define __NR_sys_uname __NR_uname
|
82 |
#define __NR_sys_getcwd1 __NR_getcwd
|
83 |
#define __NR_sys_statfs __NR_statfs
|
84 |
#define __NR_sys_fstatfs __NR_fstatfs
|
85 |
#define __NR_sys_getdents __NR_getdents
|
86 |
#define __NR_sys_getdents64 __NR_getdents64
|
87 |
#define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo
|
88 |
|
89 |
#if defined(__alpha__) || defined (__ia64__)
|
90 |
#define __NR__llseek __NR_lseek
|
91 |
#endif
|
92 |
|
93 |
#ifdef __NR_gettid
|
94 |
_syscall0(int, gettid)
|
95 |
#else
|
96 |
static int gettid(void) { |
97 |
return -ENOSYS;
|
98 |
} |
99 |
#endif
|
100 |
_syscall1(int,sys_uname,struct new_utsname *,buf) |
101 |
_syscall2(int,sys_getcwd1,char *,buf,size_t,size) |
102 |
_syscall3(int, sys_getdents, uint, fd, struct dirent *, dirp, uint, count); |
103 |
_syscall3(int, sys_getdents64, uint, fd, struct dirent64 *, dirp, uint, count); |
104 |
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo,
|
105 |
loff_t *, res, uint, wh); |
106 |
_syscall2(int,sys_statfs,const char *,path,struct kernel_statfs *,buf) |
107 |
_syscall2(int,sys_fstatfs,int,fd,struct kernel_statfs *,buf) |
108 |
_syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo) |
109 |
#ifdef __NR_exit_group
|
110 |
_syscall1(int,exit_group,int,error_code) |
111 |
#endif
|
112 |
|
113 |
extern int personality(int); |
114 |
extern int flock(int, int); |
115 |
extern int setfsuid(int); |
116 |
extern int setfsgid(int); |
117 |
extern int setresuid(uid_t, uid_t, uid_t); |
118 |
extern int getresuid(uid_t *, uid_t *, uid_t *); |
119 |
extern int setresgid(gid_t, gid_t, gid_t); |
120 |
extern int getresgid(gid_t *, gid_t *, gid_t *); |
121 |
extern int setgroups(int, gid_t *); |
122 |
|
123 |
static inline long get_errno(long ret) |
124 |
{ |
125 |
if (ret == -1) |
126 |
return -errno;
|
127 |
else
|
128 |
return ret;
|
129 |
} |
130 |
|
131 |
static inline int is_error(long ret) |
132 |
{ |
133 |
return (unsigned long)ret >= (unsigned long)(-4096); |
134 |
} |
135 |
|
136 |
static char *target_brk; |
137 |
static char *target_original_brk; |
138 |
|
139 |
void target_set_brk(char *new_brk) |
140 |
{ |
141 |
target_brk = new_brk; |
142 |
target_original_brk = new_brk; |
143 |
} |
144 |
|
145 |
static long do_brk(char *new_brk) |
146 |
{ |
147 |
char *brk_page;
|
148 |
long mapped_addr;
|
149 |
int new_alloc_size;
|
150 |
|
151 |
if (!new_brk)
|
152 |
return (long)target_brk; |
153 |
if (new_brk < target_original_brk)
|
154 |
return -ENOMEM;
|
155 |
|
156 |
brk_page = (char *)(((unsigned long)target_brk + PAGE_SIZE - 1) & PAGE_MASK); |
157 |
|
158 |
/* If the new brk is less than this, set it and we're done... */
|
159 |
if (new_brk < brk_page) {
|
160 |
target_brk = new_brk; |
161 |
return (long)target_brk; |
162 |
} |
163 |
|
164 |
/* We need to allocate more memory after the brk... */
|
165 |
new_alloc_size = ((new_brk - brk_page + 1)+(PAGE_SIZE-1)) & PAGE_MASK; |
166 |
mapped_addr = get_errno((long)mmap((caddr_t)brk_page, new_alloc_size,
|
167 |
PROT_READ|PROT_WRITE, |
168 |
MAP_ANON|MAP_FIXED|MAP_PRIVATE, 0, 0)); |
169 |
|
170 |
if (is_error(mapped_addr)) {
|
171 |
return mapped_addr;
|
172 |
} else {
|
173 |
target_brk = new_brk; |
174 |
return (long)target_brk; |
175 |
} |
176 |
} |
177 |
|
178 |
static inline fd_set *target_to_host_fds(fd_set *fds, |
179 |
target_long *target_fds, int n)
|
180 |
{ |
181 |
#if !defined(BSWAP_NEEDED) && !defined(WORDS_BIGENDIAN)
|
182 |
return (fd_set *)target_fds;
|
183 |
#else
|
184 |
int i, b;
|
185 |
if (target_fds) {
|
186 |
FD_ZERO(fds); |
187 |
for(i = 0;i < n; i++) { |
188 |
b = (tswapl(target_fds[i / TARGET_LONG_BITS]) >> |
189 |
(i & (TARGET_LONG_BITS - 1))) & 1; |
190 |
if (b)
|
191 |
FD_SET(i, fds); |
192 |
} |
193 |
return fds;
|
194 |
} else {
|
195 |
return NULL; |
196 |
} |
197 |
#endif
|
198 |
} |
199 |
|
200 |
static inline void host_to_target_fds(target_long *target_fds, |
201 |
fd_set *fds, int n)
|
202 |
{ |
203 |
#if !defined(BSWAP_NEEDED) && !defined(WORDS_BIGENDIAN)
|
204 |
/* nothing to do */
|
205 |
#else
|
206 |
int i, nw, j, k;
|
207 |
target_long v; |
208 |
|
209 |
if (target_fds) {
|
210 |
nw = n / TARGET_LONG_BITS; |
211 |
k = 0;
|
212 |
for(i = 0;i < nw; i++) { |
213 |
v = 0;
|
214 |
for(j = 0; j < TARGET_LONG_BITS; j++) { |
215 |
v |= ((FD_ISSET(k, fds) != 0) << j);
|
216 |
k++; |
217 |
} |
218 |
target_fds[i] = tswapl(v); |
219 |
} |
220 |
} |
221 |
#endif
|
222 |
} |
223 |
|
224 |
static inline void target_to_host_timeval(struct timeval *tv, |
225 |
const struct target_timeval *target_tv) |
226 |
{ |
227 |
tv->tv_sec = tswapl(target_tv->tv_sec); |
228 |
tv->tv_usec = tswapl(target_tv->tv_usec); |
229 |
} |
230 |
|
231 |
static inline void host_to_target_timeval(struct target_timeval *target_tv, |
232 |
const struct timeval *tv) |
233 |
{ |
234 |
target_tv->tv_sec = tswapl(tv->tv_sec); |
235 |
target_tv->tv_usec = tswapl(tv->tv_usec); |
236 |
} |
237 |
|
238 |
|
239 |
static long do_select(long n, |
240 |
target_long *target_rfds, target_long *target_wfds, |
241 |
target_long *target_efds, struct target_timeval *target_tv)
|
242 |
{ |
243 |
fd_set rfds, wfds, efds; |
244 |
fd_set *rfds_ptr, *wfds_ptr, *efds_ptr; |
245 |
struct timeval tv, *tv_ptr;
|
246 |
long ret;
|
247 |
|
248 |
rfds_ptr = target_to_host_fds(&rfds, target_rfds, n); |
249 |
wfds_ptr = target_to_host_fds(&wfds, target_wfds, n); |
250 |
efds_ptr = target_to_host_fds(&efds, target_efds, n); |
251 |
|
252 |
if (target_tv) {
|
253 |
target_to_host_timeval(&tv, target_tv); |
254 |
tv_ptr = &tv; |
255 |
} else {
|
256 |
tv_ptr = NULL;
|
257 |
} |
258 |
ret = get_errno(select(n, rfds_ptr, wfds_ptr, efds_ptr, tv_ptr)); |
259 |
if (!is_error(ret)) {
|
260 |
host_to_target_fds(target_rfds, rfds_ptr, n); |
261 |
host_to_target_fds(target_wfds, wfds_ptr, n); |
262 |
host_to_target_fds(target_efds, efds_ptr, n); |
263 |
|
264 |
if (target_tv) {
|
265 |
host_to_target_timeval(target_tv, &tv); |
266 |
} |
267 |
} |
268 |
return ret;
|
269 |
} |
270 |
|
271 |
static inline void target_to_host_sockaddr(struct sockaddr *addr, |
272 |
struct target_sockaddr *target_addr,
|
273 |
socklen_t len) |
274 |
{ |
275 |
memcpy(addr, target_addr, len); |
276 |
addr->sa_family = tswap16(target_addr->sa_family); |
277 |
} |
278 |
|
279 |
static inline void host_to_target_sockaddr(struct target_sockaddr *target_addr, |
280 |
struct sockaddr *addr,
|
281 |
socklen_t len) |
282 |
{ |
283 |
memcpy(target_addr, addr, len); |
284 |
target_addr->sa_family = tswap16(addr->sa_family); |
285 |
} |
286 |
|
287 |
static inline void target_to_host_cmsg(struct msghdr *msgh, |
288 |
struct target_msghdr *target_msgh)
|
289 |
{ |
290 |
struct cmsghdr *cmsg = CMSG_FIRSTHDR(msgh);
|
291 |
struct target_cmsghdr *target_cmsg = TARGET_CMSG_FIRSTHDR(target_msgh);
|
292 |
socklen_t space = 0;
|
293 |
|
294 |
while (cmsg && target_cmsg) {
|
295 |
void *data = CMSG_DATA(cmsg);
|
296 |
void *target_data = TARGET_CMSG_DATA(target_cmsg);
|
297 |
|
298 |
int len = tswapl(target_cmsg->cmsg_len)
|
299 |
- TARGET_CMSG_ALIGN(sizeof (struct target_cmsghdr)); |
300 |
|
301 |
space += CMSG_SPACE(len); |
302 |
if (space > msgh->msg_controllen) {
|
303 |
space -= CMSG_SPACE(len); |
304 |
gemu_log("Host cmsg overflow");
|
305 |
break;
|
306 |
} |
307 |
|
308 |
cmsg->cmsg_level = tswap32(target_cmsg->cmsg_level); |
309 |
cmsg->cmsg_type = tswap32(target_cmsg->cmsg_type); |
310 |
cmsg->cmsg_len = CMSG_LEN(len); |
311 |
|
312 |
if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) {
|
313 |
gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type);
|
314 |
memcpy(data, target_data, len); |
315 |
} else {
|
316 |
int *fd = (int *)data; |
317 |
int *target_fd = (int *)target_data; |
318 |
int i, numfds = len / sizeof(int); |
319 |
|
320 |
for (i = 0; i < numfds; i++) |
321 |
fd[i] = tswap32(target_fd[i]); |
322 |
} |
323 |
|
324 |
cmsg = CMSG_NXTHDR(msgh, cmsg); |
325 |
target_cmsg = TARGET_CMSG_NXTHDR(target_msgh, target_cmsg); |
326 |
} |
327 |
|
328 |
msgh->msg_controllen = space; |
329 |
} |
330 |
|
331 |
static inline void host_to_target_cmsg(struct target_msghdr *target_msgh, |
332 |
struct msghdr *msgh)
|
333 |
{ |
334 |
struct cmsghdr *cmsg = CMSG_FIRSTHDR(msgh);
|
335 |
struct target_cmsghdr *target_cmsg = TARGET_CMSG_FIRSTHDR(target_msgh);
|
336 |
socklen_t space = 0;
|
337 |
|
338 |
while (cmsg && target_cmsg) {
|
339 |
void *data = CMSG_DATA(cmsg);
|
340 |
void *target_data = TARGET_CMSG_DATA(target_cmsg);
|
341 |
|
342 |
int len = cmsg->cmsg_len - CMSG_ALIGN(sizeof (struct cmsghdr)); |
343 |
|
344 |
space += TARGET_CMSG_SPACE(len); |
345 |
if (space > tswapl(target_msgh->msg_controllen)) {
|
346 |
space -= TARGET_CMSG_SPACE(len); |
347 |
gemu_log("Target cmsg overflow");
|
348 |
break;
|
349 |
} |
350 |
|
351 |
target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level); |
352 |
target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type); |
353 |
target_cmsg->cmsg_len = tswapl(TARGET_CMSG_LEN(len)); |
354 |
|
355 |
if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) {
|
356 |
gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type);
|
357 |
memcpy(target_data, data, len); |
358 |
} else {
|
359 |
int *fd = (int *)data; |
360 |
int *target_fd = (int *)target_data; |
361 |
int i, numfds = len / sizeof(int); |
362 |
|
363 |
for (i = 0; i < numfds; i++) |
364 |
target_fd[i] = tswap32(fd[i]); |
365 |
} |
366 |
|
367 |
cmsg = CMSG_NXTHDR(msgh, cmsg); |
368 |
target_cmsg = TARGET_CMSG_NXTHDR(target_msgh, target_cmsg); |
369 |
} |
370 |
|
371 |
msgh->msg_controllen = tswapl(space); |
372 |
} |
373 |
|
374 |
static long do_setsockopt(int sockfd, int level, int optname, |
375 |
void *optval, socklen_t optlen)
|
376 |
{ |
377 |
if (level == SOL_TCP) {
|
378 |
/* TCP options all take an 'int' value. */
|
379 |
int val;
|
380 |
|
381 |
if (optlen < sizeof(uint32_t)) |
382 |
return -EINVAL;
|
383 |
|
384 |
val = tswap32(*(uint32_t *)optval); |
385 |
return get_errno(setsockopt(sockfd, level, optname, &val, sizeof(val))); |
386 |
} |
387 |
|
388 |
else if (level != SOL_SOCKET) { |
389 |
gemu_log("Unsupported setsockopt level: %d\n", level);
|
390 |
return -ENOSYS;
|
391 |
} |
392 |
|
393 |
switch (optname) {
|
394 |
/* Options with 'int' argument. */
|
395 |
case SO_DEBUG:
|
396 |
case SO_REUSEADDR:
|
397 |
case SO_TYPE:
|
398 |
case SO_ERROR:
|
399 |
case SO_DONTROUTE:
|
400 |
case SO_BROADCAST:
|
401 |
case SO_SNDBUF:
|
402 |
case SO_RCVBUF:
|
403 |
case SO_KEEPALIVE:
|
404 |
case SO_OOBINLINE:
|
405 |
case SO_NO_CHECK:
|
406 |
case SO_PRIORITY:
|
407 |
case SO_BSDCOMPAT:
|
408 |
case SO_PASSCRED:
|
409 |
case SO_TIMESTAMP:
|
410 |
case SO_RCVLOWAT:
|
411 |
case SO_RCVTIMEO:
|
412 |
case SO_SNDTIMEO:
|
413 |
{ |
414 |
int val;
|
415 |
if (optlen < sizeof(uint32_t)) |
416 |
return -EINVAL;
|
417 |
val = tswap32(*(uint32_t *)optval); |
418 |
return get_errno(setsockopt(sockfd, level, optname, &val, sizeof(val))); |
419 |
} |
420 |
|
421 |
default:
|
422 |
gemu_log("Unsupported setsockopt SOL_SOCKET option: %d\n", optname);
|
423 |
return -ENOSYS;
|
424 |
} |
425 |
} |
426 |
|
427 |
static long do_getsockopt(int sockfd, int level, int optname, |
428 |
void *optval, socklen_t *optlen)
|
429 |
{ |
430 |
gemu_log("getsockopt not yet supported\n");
|
431 |
return -ENOSYS;
|
432 |
} |
433 |
|
434 |
static long do_socketcall(int num, int32_t *vptr) |
435 |
{ |
436 |
long ret;
|
437 |
|
438 |
switch(num) {
|
439 |
case SOCKOP_socket:
|
440 |
{ |
441 |
int domain = tswap32(vptr[0]); |
442 |
int type = tswap32(vptr[1]); |
443 |
int protocol = tswap32(vptr[2]); |
444 |
|
445 |
ret = get_errno(socket(domain, type, protocol)); |
446 |
} |
447 |
break;
|
448 |
case SOCKOP_bind:
|
449 |
{ |
450 |
int sockfd = tswap32(vptr[0]); |
451 |
void *target_addr = (void *)tswap32(vptr[1]); |
452 |
socklen_t addrlen = tswap32(vptr[2]);
|
453 |
void *addr = alloca(addrlen);
|
454 |
|
455 |
target_to_host_sockaddr(addr, target_addr, addrlen); |
456 |
ret = get_errno(bind(sockfd, addr, addrlen)); |
457 |
} |
458 |
break;
|
459 |
case SOCKOP_connect:
|
460 |
{ |
461 |
int sockfd = tswap32(vptr[0]); |
462 |
void *target_addr = (void *)tswap32(vptr[1]); |
463 |
socklen_t addrlen = tswap32(vptr[2]);
|
464 |
void *addr = alloca(addrlen);
|
465 |
|
466 |
target_to_host_sockaddr(addr, target_addr, addrlen); |
467 |
ret = get_errno(connect(sockfd, addr, addrlen)); |
468 |
} |
469 |
break;
|
470 |
case SOCKOP_listen:
|
471 |
{ |
472 |
int sockfd = tswap32(vptr[0]); |
473 |
int backlog = tswap32(vptr[1]); |
474 |
|
475 |
ret = get_errno(listen(sockfd, backlog)); |
476 |
} |
477 |
break;
|
478 |
case SOCKOP_accept:
|
479 |
{ |
480 |
int sockfd = tswap32(vptr[0]); |
481 |
void *target_addr = (void *)tswap32(vptr[1]); |
482 |
uint32_t *target_addrlen = (void *)tswap32(vptr[2]); |
483 |
socklen_t addrlen = tswap32(*target_addrlen); |
484 |
void *addr = alloca(addrlen);
|
485 |
|
486 |
ret = get_errno(accept(sockfd, addr, &addrlen)); |
487 |
if (!is_error(ret)) {
|
488 |
host_to_target_sockaddr(target_addr, addr, addrlen); |
489 |
*target_addrlen = tswap32(addrlen); |
490 |
} |
491 |
} |
492 |
break;
|
493 |
case SOCKOP_getsockname:
|
494 |
{ |
495 |
int sockfd = tswap32(vptr[0]); |
496 |
void *target_addr = (void *)tswap32(vptr[1]); |
497 |
uint32_t *target_addrlen = (void *)tswap32(vptr[2]); |
498 |
socklen_t addrlen = tswap32(*target_addrlen); |
499 |
void *addr = alloca(addrlen);
|
500 |
|
501 |
ret = get_errno(getsockname(sockfd, addr, &addrlen)); |
502 |
if (!is_error(ret)) {
|
503 |
host_to_target_sockaddr(target_addr, addr, addrlen); |
504 |
*target_addrlen = tswap32(addrlen); |
505 |
} |
506 |
} |
507 |
break;
|
508 |
case SOCKOP_getpeername:
|
509 |
{ |
510 |
int sockfd = tswap32(vptr[0]); |
511 |
void *target_addr = (void *)tswap32(vptr[1]); |
512 |
uint32_t *target_addrlen = (void *)tswap32(vptr[2]); |
513 |
socklen_t addrlen = tswap32(*target_addrlen); |
514 |
void *addr = alloca(addrlen);
|
515 |
|
516 |
ret = get_errno(getpeername(sockfd, addr, &addrlen)); |
517 |
if (!is_error(ret)) {
|
518 |
host_to_target_sockaddr(target_addr, addr, addrlen); |
519 |
*target_addrlen = tswap32(addrlen); |
520 |
} |
521 |
} |
522 |
break;
|
523 |
case SOCKOP_socketpair:
|
524 |
{ |
525 |
int domain = tswap32(vptr[0]); |
526 |
int type = tswap32(vptr[1]); |
527 |
int protocol = tswap32(vptr[2]); |
528 |
int32_t *target_tab = (void *)tswap32(vptr[3]); |
529 |
int tab[2]; |
530 |
|
531 |
ret = get_errno(socketpair(domain, type, protocol, tab)); |
532 |
if (!is_error(ret)) {
|
533 |
target_tab[0] = tswap32(tab[0]); |
534 |
target_tab[1] = tswap32(tab[1]); |
535 |
} |
536 |
} |
537 |
break;
|
538 |
case SOCKOP_send:
|
539 |
{ |
540 |
int sockfd = tswap32(vptr[0]); |
541 |
void *msg = (void *)tswap32(vptr[1]); |
542 |
size_t len = tswap32(vptr[2]);
|
543 |
int flags = tswap32(vptr[3]); |
544 |
|
545 |
ret = get_errno(send(sockfd, msg, len, flags)); |
546 |
} |
547 |
break;
|
548 |
case SOCKOP_recv:
|
549 |
{ |
550 |
int sockfd = tswap32(vptr[0]); |
551 |
void *msg = (void *)tswap32(vptr[1]); |
552 |
size_t len = tswap32(vptr[2]);
|
553 |
int flags = tswap32(vptr[3]); |
554 |
|
555 |
ret = get_errno(recv(sockfd, msg, len, flags)); |
556 |
} |
557 |
break;
|
558 |
case SOCKOP_sendto:
|
559 |
{ |
560 |
int sockfd = tswap32(vptr[0]); |
561 |
void *msg = (void *)tswap32(vptr[1]); |
562 |
size_t len = tswap32(vptr[2]);
|
563 |
int flags = tswap32(vptr[3]); |
564 |
void *target_addr = (void *)tswap32(vptr[4]); |
565 |
socklen_t addrlen = tswap32(vptr[5]);
|
566 |
void *addr = alloca(addrlen);
|
567 |
|
568 |
target_to_host_sockaddr(addr, target_addr, addrlen); |
569 |
ret = get_errno(sendto(sockfd, msg, len, flags, addr, addrlen)); |
570 |
} |
571 |
break;
|
572 |
case SOCKOP_recvfrom:
|
573 |
{ |
574 |
int sockfd = tswap32(vptr[0]); |
575 |
void *msg = (void *)tswap32(vptr[1]); |
576 |
size_t len = tswap32(vptr[2]);
|
577 |
int flags = tswap32(vptr[3]); |
578 |
void *target_addr = (void *)tswap32(vptr[4]); |
579 |
uint32_t *target_addrlen = (void *)tswap32(vptr[5]); |
580 |
socklen_t addrlen = tswap32(*target_addrlen); |
581 |
void *addr = alloca(addrlen);
|
582 |
|
583 |
ret = get_errno(recvfrom(sockfd, msg, len, flags, addr, &addrlen)); |
584 |
if (!is_error(ret)) {
|
585 |
host_to_target_sockaddr(target_addr, addr, addrlen); |
586 |
*target_addrlen = tswap32(addrlen); |
587 |
} |
588 |
} |
589 |
break;
|
590 |
case SOCKOP_shutdown:
|
591 |
{ |
592 |
int sockfd = tswap32(vptr[0]); |
593 |
int how = tswap32(vptr[1]); |
594 |
|
595 |
ret = get_errno(shutdown(sockfd, how)); |
596 |
} |
597 |
break;
|
598 |
case SOCKOP_sendmsg:
|
599 |
case SOCKOP_recvmsg:
|
600 |
{ |
601 |
int fd;
|
602 |
struct target_msghdr *msgp;
|
603 |
struct msghdr msg;
|
604 |
int flags, count, i;
|
605 |
struct iovec *vec;
|
606 |
struct target_iovec *target_vec;
|
607 |
|
608 |
msgp = (void *)tswap32(vptr[1]); |
609 |
msg.msg_name = (void *)tswapl(msgp->msg_name);
|
610 |
msg.msg_namelen = tswapl(msgp->msg_namelen); |
611 |
msg.msg_controllen = 2 * tswapl(msgp->msg_controllen);
|
612 |
msg.msg_control = alloca(msg.msg_controllen); |
613 |
msg.msg_flags = tswap32(msgp->msg_flags); |
614 |
|
615 |
count = tswapl(msgp->msg_iovlen); |
616 |
vec = alloca(count * sizeof(struct iovec)); |
617 |
target_vec = (void *)tswapl(msgp->msg_iov);
|
618 |
for(i = 0;i < count; i++) { |
619 |
vec[i].iov_base = (void *)tswapl(target_vec[i].iov_base);
|
620 |
vec[i].iov_len = tswapl(target_vec[i].iov_len); |
621 |
} |
622 |
msg.msg_iovlen = count; |
623 |
msg.msg_iov = vec; |
624 |
|
625 |
fd = tswap32(vptr[0]);
|
626 |
flags = tswap32(vptr[2]);
|
627 |
if (num == SOCKOP_sendmsg) {
|
628 |
target_to_host_cmsg(&msg, msgp); |
629 |
ret = get_errno(sendmsg(fd, &msg, flags)); |
630 |
} else {
|
631 |
ret = get_errno(recvmsg(fd, &msg, flags)); |
632 |
if (!is_error(ret))
|
633 |
host_to_target_cmsg(msgp, &msg); |
634 |
} |
635 |
} |
636 |
break;
|
637 |
case SOCKOP_setsockopt:
|
638 |
{ |
639 |
int sockfd = tswap32(vptr[0]); |
640 |
int level = tswap32(vptr[1]); |
641 |
int optname = tswap32(vptr[2]); |
642 |
void *optval = (void *)tswap32(vptr[3]); |
643 |
socklen_t optlen = tswap32(vptr[4]);
|
644 |
|
645 |
ret = do_setsockopt(sockfd, level, optname, optval, optlen); |
646 |
} |
647 |
break;
|
648 |
case SOCKOP_getsockopt:
|
649 |
{ |
650 |
int sockfd = tswap32(vptr[0]); |
651 |
int level = tswap32(vptr[1]); |
652 |
int optname = tswap32(vptr[2]); |
653 |
void *optval = (void *)tswap32(vptr[3]); |
654 |
uint32_t *target_len = (void *)tswap32(vptr[4]); |
655 |
socklen_t optlen = tswap32(*target_len); |
656 |
|
657 |
ret = do_getsockopt(sockfd, level, optname, optval, &optlen); |
658 |
if (!is_error(ret))
|
659 |
*target_len = tswap32(optlen); |
660 |
} |
661 |
break;
|
662 |
default:
|
663 |
gemu_log("Unsupported socketcall: %d\n", num);
|
664 |
ret = -ENOSYS; |
665 |
break;
|
666 |
} |
667 |
return ret;
|
668 |
} |
669 |
|
670 |
/* kernel structure types definitions */
|
671 |
#define IFNAMSIZ 16 |
672 |
|
673 |
#define STRUCT(name, list...) STRUCT_ ## name, |
674 |
#define STRUCT_SPECIAL(name) STRUCT_ ## name, |
675 |
enum {
|
676 |
#include "syscall_types.h" |
677 |
}; |
678 |
#undef STRUCT
|
679 |
#undef STRUCT_SPECIAL
|
680 |
|
681 |
#define STRUCT(name, list...) const argtype struct_ ## name ## _def[] = { list, TYPE_NULL }; |
682 |
#define STRUCT_SPECIAL(name)
|
683 |
#include "syscall_types.h" |
684 |
#undef STRUCT
|
685 |
#undef STRUCT_SPECIAL
|
686 |
|
687 |
typedef struct IOCTLEntry { |
688 |
int target_cmd;
|
689 |
int host_cmd;
|
690 |
const char *name; |
691 |
int access;
|
692 |
const argtype arg_type[5]; |
693 |
} IOCTLEntry; |
694 |
|
695 |
#define IOC_R 0x0001 |
696 |
#define IOC_W 0x0002 |
697 |
#define IOC_RW (IOC_R | IOC_W)
|
698 |
|
699 |
#define MAX_STRUCT_SIZE 4096 |
700 |
|
701 |
const IOCTLEntry ioctl_entries[] = {
|
702 |
#define IOCTL(cmd, access, types...) \
|
703 |
{ TARGET_ ## cmd, cmd, #cmd, access, { types } }, |
704 |
#include "ioctls.h" |
705 |
{ 0, 0, }, |
706 |
}; |
707 |
|
708 |
static long do_ioctl(long fd, long cmd, long arg) |
709 |
{ |
710 |
const IOCTLEntry *ie;
|
711 |
const argtype *arg_type;
|
712 |
long ret;
|
713 |
uint8_t buf_temp[MAX_STRUCT_SIZE]; |
714 |
|
715 |
ie = ioctl_entries; |
716 |
for(;;) {
|
717 |
if (ie->target_cmd == 0) { |
718 |
gemu_log("Unsupported ioctl: cmd=0x%04lx\n", cmd);
|
719 |
return -ENOSYS;
|
720 |
} |
721 |
if (ie->target_cmd == cmd)
|
722 |
break;
|
723 |
ie++; |
724 |
} |
725 |
arg_type = ie->arg_type; |
726 |
#if defined(DEBUG)
|
727 |
gemu_log("ioctl: cmd=0x%04lx (%s)\n", cmd, ie->name);
|
728 |
#endif
|
729 |
switch(arg_type[0]) { |
730 |
case TYPE_NULL:
|
731 |
/* no argument */
|
732 |
ret = get_errno(ioctl(fd, ie->host_cmd)); |
733 |
break;
|
734 |
case TYPE_PTRVOID:
|
735 |
case TYPE_INT:
|
736 |
/* int argment */
|
737 |
ret = get_errno(ioctl(fd, ie->host_cmd, arg)); |
738 |
break;
|
739 |
case TYPE_PTR:
|
740 |
arg_type++; |
741 |
switch(ie->access) {
|
742 |
case IOC_R:
|
743 |
ret = get_errno(ioctl(fd, ie->host_cmd, buf_temp)); |
744 |
if (!is_error(ret)) {
|
745 |
thunk_convert((void *)arg, buf_temp, arg_type, THUNK_TARGET);
|
746 |
} |
747 |
break;
|
748 |
case IOC_W:
|
749 |
thunk_convert(buf_temp, (void *)arg, arg_type, THUNK_HOST);
|
750 |
ret = get_errno(ioctl(fd, ie->host_cmd, buf_temp)); |
751 |
break;
|
752 |
default:
|
753 |
case IOC_RW:
|
754 |
thunk_convert(buf_temp, (void *)arg, arg_type, THUNK_HOST);
|
755 |
ret = get_errno(ioctl(fd, ie->host_cmd, buf_temp)); |
756 |
if (!is_error(ret)) {
|
757 |
thunk_convert((void *)arg, buf_temp, arg_type, THUNK_TARGET);
|
758 |
} |
759 |
break;
|
760 |
} |
761 |
break;
|
762 |
default:
|
763 |
gemu_log("Unsupported ioctl type: cmd=0x%04lx type=%d\n", cmd, arg_type[0]); |
764 |
ret = -ENOSYS; |
765 |
break;
|
766 |
} |
767 |
return ret;
|
768 |
} |
769 |
|
770 |
bitmask_transtbl iflag_tbl[] = { |
771 |
{ TARGET_IGNBRK, TARGET_IGNBRK, IGNBRK, IGNBRK }, |
772 |
{ TARGET_BRKINT, TARGET_BRKINT, BRKINT, BRKINT }, |
773 |
{ TARGET_IGNPAR, TARGET_IGNPAR, IGNPAR, IGNPAR }, |
774 |
{ TARGET_PARMRK, TARGET_PARMRK, PARMRK, PARMRK }, |
775 |
{ TARGET_INPCK, TARGET_INPCK, INPCK, INPCK }, |
776 |
{ TARGET_ISTRIP, TARGET_ISTRIP, ISTRIP, ISTRIP }, |
777 |
{ TARGET_INLCR, TARGET_INLCR, INLCR, INLCR }, |
778 |
{ TARGET_IGNCR, TARGET_IGNCR, IGNCR, IGNCR }, |
779 |
{ TARGET_ICRNL, TARGET_ICRNL, ICRNL, ICRNL }, |
780 |
{ TARGET_IUCLC, TARGET_IUCLC, IUCLC, IUCLC }, |
781 |
{ TARGET_IXON, TARGET_IXON, IXON, IXON }, |
782 |
{ TARGET_IXANY, TARGET_IXANY, IXANY, IXANY }, |
783 |
{ TARGET_IXOFF, TARGET_IXOFF, IXOFF, IXOFF }, |
784 |
{ TARGET_IMAXBEL, TARGET_IMAXBEL, IMAXBEL, IMAXBEL }, |
785 |
{ 0, 0, 0, 0 } |
786 |
}; |
787 |
|
788 |
bitmask_transtbl oflag_tbl[] = { |
789 |
{ TARGET_OPOST, TARGET_OPOST, OPOST, OPOST }, |
790 |
{ TARGET_OLCUC, TARGET_OLCUC, OLCUC, OLCUC }, |
791 |
{ TARGET_ONLCR, TARGET_ONLCR, ONLCR, ONLCR }, |
792 |
{ TARGET_OCRNL, TARGET_OCRNL, OCRNL, OCRNL }, |
793 |
{ TARGET_ONOCR, TARGET_ONOCR, ONOCR, ONOCR }, |
794 |
{ TARGET_ONLRET, TARGET_ONLRET, ONLRET, ONLRET }, |
795 |
{ TARGET_OFILL, TARGET_OFILL, OFILL, OFILL }, |
796 |
{ TARGET_OFDEL, TARGET_OFDEL, OFDEL, OFDEL }, |
797 |
{ TARGET_NLDLY, TARGET_NL0, NLDLY, NL0 }, |
798 |
{ TARGET_NLDLY, TARGET_NL1, NLDLY, NL1 }, |
799 |
{ TARGET_CRDLY, TARGET_CR0, CRDLY, CR0 }, |
800 |
{ TARGET_CRDLY, TARGET_CR1, CRDLY, CR1 }, |
801 |
{ TARGET_CRDLY, TARGET_CR2, CRDLY, CR2 }, |
802 |
{ TARGET_CRDLY, TARGET_CR3, CRDLY, CR3 }, |
803 |
{ TARGET_TABDLY, TARGET_TAB0, TABDLY, TAB0 }, |
804 |
{ TARGET_TABDLY, TARGET_TAB1, TABDLY, TAB1 }, |
805 |
{ TARGET_TABDLY, TARGET_TAB2, TABDLY, TAB2 }, |
806 |
{ TARGET_TABDLY, TARGET_TAB3, TABDLY, TAB3 }, |
807 |
{ TARGET_BSDLY, TARGET_BS0, BSDLY, BS0 }, |
808 |
{ TARGET_BSDLY, TARGET_BS1, BSDLY, BS1 }, |
809 |
{ TARGET_VTDLY, TARGET_VT0, VTDLY, VT0 }, |
810 |
{ TARGET_VTDLY, TARGET_VT1, VTDLY, VT1 }, |
811 |
{ TARGET_FFDLY, TARGET_FF0, FFDLY, FF0 }, |
812 |
{ TARGET_FFDLY, TARGET_FF1, FFDLY, FF1 }, |
813 |
{ 0, 0, 0, 0 } |
814 |
}; |
815 |
|
816 |
bitmask_transtbl cflag_tbl[] = { |
817 |
{ TARGET_CBAUD, TARGET_B0, CBAUD, B0 }, |
818 |
{ TARGET_CBAUD, TARGET_B50, CBAUD, B50 }, |
819 |
{ TARGET_CBAUD, TARGET_B75, CBAUD, B75 }, |
820 |
{ TARGET_CBAUD, TARGET_B110, CBAUD, B110 }, |
821 |
{ TARGET_CBAUD, TARGET_B134, CBAUD, B134 }, |
822 |
{ TARGET_CBAUD, TARGET_B150, CBAUD, B150 }, |
823 |
{ TARGET_CBAUD, TARGET_B200, CBAUD, B200 }, |
824 |
{ TARGET_CBAUD, TARGET_B300, CBAUD, B300 }, |
825 |
{ TARGET_CBAUD, TARGET_B600, CBAUD, B600 }, |
826 |
{ TARGET_CBAUD, TARGET_B1200, CBAUD, B1200 }, |
827 |
{ TARGET_CBAUD, TARGET_B1800, CBAUD, B1800 }, |
828 |
{ TARGET_CBAUD, TARGET_B2400, CBAUD, B2400 }, |
829 |
{ TARGET_CBAUD, TARGET_B4800, CBAUD, B4800 }, |
830 |
{ TARGET_CBAUD, TARGET_B9600, CBAUD, B9600 }, |
831 |
{ TARGET_CBAUD, TARGET_B19200, CBAUD, B19200 }, |
832 |
{ TARGET_CBAUD, TARGET_B38400, CBAUD, B38400 }, |
833 |
{ TARGET_CBAUD, TARGET_B57600, CBAUD, B57600 }, |
834 |
{ TARGET_CBAUD, TARGET_B115200, CBAUD, B115200 }, |
835 |
{ TARGET_CBAUD, TARGET_B230400, CBAUD, B230400 }, |
836 |
{ TARGET_CBAUD, TARGET_B460800, CBAUD, B460800 }, |
837 |
{ TARGET_CSIZE, TARGET_CS5, CSIZE, CS5 }, |
838 |
{ TARGET_CSIZE, TARGET_CS6, CSIZE, CS6 }, |
839 |
{ TARGET_CSIZE, TARGET_CS7, CSIZE, CS7 }, |
840 |
{ TARGET_CSIZE, TARGET_CS8, CSIZE, CS8 }, |
841 |
{ TARGET_CSTOPB, TARGET_CSTOPB, CSTOPB, CSTOPB }, |
842 |
{ TARGET_CREAD, TARGET_CREAD, CREAD, CREAD }, |
843 |
{ TARGET_PARENB, TARGET_PARENB, PARENB, PARENB }, |
844 |
{ TARGET_PARODD, TARGET_PARODD, PARODD, PARODD }, |
845 |
{ TARGET_HUPCL, TARGET_HUPCL, HUPCL, HUPCL }, |
846 |
{ TARGET_CLOCAL, TARGET_CLOCAL, CLOCAL, CLOCAL }, |
847 |
{ TARGET_CRTSCTS, TARGET_CRTSCTS, CRTSCTS, CRTSCTS }, |
848 |
{ 0, 0, 0, 0 } |
849 |
}; |
850 |
|
851 |
bitmask_transtbl lflag_tbl[] = { |
852 |
{ TARGET_ISIG, TARGET_ISIG, ISIG, ISIG }, |
853 |
{ TARGET_ICANON, TARGET_ICANON, ICANON, ICANON }, |
854 |
{ TARGET_XCASE, TARGET_XCASE, XCASE, XCASE }, |
855 |
{ TARGET_ECHO, TARGET_ECHO, ECHO, ECHO }, |
856 |
{ TARGET_ECHOE, TARGET_ECHOE, ECHOE, ECHOE }, |
857 |
{ TARGET_ECHOK, TARGET_ECHOK, ECHOK, ECHOK }, |
858 |
{ TARGET_ECHONL, TARGET_ECHONL, ECHONL, ECHONL }, |
859 |
{ TARGET_NOFLSH, TARGET_NOFLSH, NOFLSH, NOFLSH }, |
860 |
{ TARGET_TOSTOP, TARGET_TOSTOP, TOSTOP, TOSTOP }, |
861 |
{ TARGET_ECHOCTL, TARGET_ECHOCTL, ECHOCTL, ECHOCTL }, |
862 |
{ TARGET_ECHOPRT, TARGET_ECHOPRT, ECHOPRT, ECHOPRT }, |
863 |
{ TARGET_ECHOKE, TARGET_ECHOKE, ECHOKE, ECHOKE }, |
864 |
{ TARGET_FLUSHO, TARGET_FLUSHO, FLUSHO, FLUSHO }, |
865 |
{ TARGET_PENDIN, TARGET_PENDIN, PENDIN, PENDIN }, |
866 |
{ TARGET_IEXTEN, TARGET_IEXTEN, IEXTEN, IEXTEN }, |
867 |
{ 0, 0, 0, 0 } |
868 |
}; |
869 |
|
870 |
static void target_to_host_termios (void *dst, const void *src) |
871 |
{ |
872 |
struct host_termios *host = dst;
|
873 |
const struct target_termios *target = src; |
874 |
|
875 |
host->c_iflag = |
876 |
target_to_host_bitmask(tswap32(target->c_iflag), iflag_tbl); |
877 |
host->c_oflag = |
878 |
target_to_host_bitmask(tswap32(target->c_oflag), oflag_tbl); |
879 |
host->c_cflag = |
880 |
target_to_host_bitmask(tswap32(target->c_cflag), cflag_tbl); |
881 |
host->c_lflag = |
882 |
target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl); |
883 |
host->c_line = target->c_line; |
884 |
|
885 |
host->c_cc[VINTR] = target->c_cc[TARGET_VINTR]; |
886 |
host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT]; |
887 |
host->c_cc[VERASE] = target->c_cc[TARGET_VERASE]; |
888 |
host->c_cc[VKILL] = target->c_cc[TARGET_VKILL]; |
889 |
host->c_cc[VEOF] = target->c_cc[TARGET_VEOF]; |
890 |
host->c_cc[VTIME] = target->c_cc[TARGET_VTIME]; |
891 |
host->c_cc[VMIN] = target->c_cc[TARGET_VMIN]; |
892 |
host->c_cc[VSWTC] = target->c_cc[TARGET_VSWTC]; |
893 |
host->c_cc[VSTART] = target->c_cc[TARGET_VSTART]; |
894 |
host->c_cc[VSTOP] = target->c_cc[TARGET_VSTOP]; |
895 |
host->c_cc[VSUSP] = target->c_cc[TARGET_VSUSP]; |
896 |
host->c_cc[VEOL] = target->c_cc[TARGET_VEOL]; |
897 |
host->c_cc[VREPRINT] = target->c_cc[TARGET_VREPRINT]; |
898 |
host->c_cc[VDISCARD] = target->c_cc[TARGET_VDISCARD]; |
899 |
host->c_cc[VWERASE] = target->c_cc[TARGET_VWERASE]; |
900 |
host->c_cc[VLNEXT] = target->c_cc[TARGET_VLNEXT]; |
901 |
host->c_cc[VEOL2] = target->c_cc[TARGET_VEOL2]; |
902 |
} |
903 |
|
904 |
static void host_to_target_termios (void *dst, const void *src) |
905 |
{ |
906 |
struct target_termios *target = dst;
|
907 |
const struct host_termios *host = src; |
908 |
|
909 |
target->c_iflag = |
910 |
tswap32(host_to_target_bitmask(host->c_iflag, iflag_tbl)); |
911 |
target->c_oflag = |
912 |
tswap32(host_to_target_bitmask(host->c_oflag, oflag_tbl)); |
913 |
target->c_cflag = |
914 |
tswap32(host_to_target_bitmask(host->c_cflag, cflag_tbl)); |
915 |
target->c_lflag = |
916 |
tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl)); |
917 |
target->c_line = host->c_line; |
918 |
|
919 |
target->c_cc[TARGET_VINTR] = host->c_cc[VINTR]; |
920 |
target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT]; |
921 |
target->c_cc[TARGET_VERASE] = host->c_cc[VERASE]; |
922 |
target->c_cc[TARGET_VKILL] = host->c_cc[VKILL]; |
923 |
target->c_cc[TARGET_VEOF] = host->c_cc[VEOF]; |
924 |
target->c_cc[TARGET_VTIME] = host->c_cc[VTIME]; |
925 |
target->c_cc[TARGET_VMIN] = host->c_cc[VMIN]; |
926 |
target->c_cc[TARGET_VSWTC] = host->c_cc[VSWTC]; |
927 |
target->c_cc[TARGET_VSTART] = host->c_cc[VSTART]; |
928 |
target->c_cc[TARGET_VSTOP] = host->c_cc[VSTOP]; |
929 |
target->c_cc[TARGET_VSUSP] = host->c_cc[VSUSP]; |
930 |
target->c_cc[TARGET_VEOL] = host->c_cc[VEOL]; |
931 |
target->c_cc[TARGET_VREPRINT] = host->c_cc[VREPRINT]; |
932 |
target->c_cc[TARGET_VDISCARD] = host->c_cc[VDISCARD]; |
933 |
target->c_cc[TARGET_VWERASE] = host->c_cc[VWERASE]; |
934 |
target->c_cc[TARGET_VLNEXT] = host->c_cc[VLNEXT]; |
935 |
target->c_cc[TARGET_VEOL2] = host->c_cc[VEOL2]; |
936 |
} |
937 |
|
938 |
StructEntry struct_termios_def = { |
939 |
.convert = { host_to_target_termios, target_to_host_termios }, |
940 |
.size = { sizeof(struct target_termios), sizeof(struct host_termios) }, |
941 |
.align = { __alignof__(struct target_termios), __alignof__(struct host_termios) }, |
942 |
}; |
943 |
|
944 |
#ifdef TARGET_I386
|
945 |
|
946 |
/* NOTE: there is really one LDT for all the threads */
|
947 |
uint8_t *ldt_table; |
948 |
|
949 |
static int read_ldt(void *ptr, unsigned long bytecount) |
950 |
{ |
951 |
int size;
|
952 |
|
953 |
if (!ldt_table)
|
954 |
return 0; |
955 |
size = TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE; |
956 |
if (size > bytecount)
|
957 |
size = bytecount; |
958 |
memcpy(ptr, ldt_table, size); |
959 |
return size;
|
960 |
} |
961 |
|
962 |
/* XXX: add locking support */
|
963 |
static int write_ldt(CPUX86State *env, |
964 |
void *ptr, unsigned long bytecount, int oldmode) |
965 |
{ |
966 |
struct target_modify_ldt_ldt_s ldt_info;
|
967 |
int seg_32bit, contents, read_exec_only, limit_in_pages;
|
968 |
int seg_not_present, useable;
|
969 |
uint32_t *lp, entry_1, entry_2; |
970 |
|
971 |
if (bytecount != sizeof(ldt_info)) |
972 |
return -EINVAL;
|
973 |
memcpy(&ldt_info, ptr, sizeof(ldt_info));
|
974 |
tswap32s(&ldt_info.entry_number); |
975 |
tswapls((long *)&ldt_info.base_addr);
|
976 |
tswap32s(&ldt_info.limit); |
977 |
tswap32s(&ldt_info.flags); |
978 |
|
979 |
if (ldt_info.entry_number >= TARGET_LDT_ENTRIES)
|
980 |
return -EINVAL;
|
981 |
seg_32bit = ldt_info.flags & 1;
|
982 |
contents = (ldt_info.flags >> 1) & 3; |
983 |
read_exec_only = (ldt_info.flags >> 3) & 1; |
984 |
limit_in_pages = (ldt_info.flags >> 4) & 1; |
985 |
seg_not_present = (ldt_info.flags >> 5) & 1; |
986 |
useable = (ldt_info.flags >> 6) & 1; |
987 |
|
988 |
if (contents == 3) { |
989 |
if (oldmode)
|
990 |
return -EINVAL;
|
991 |
if (seg_not_present == 0) |
992 |
return -EINVAL;
|
993 |
} |
994 |
/* allocate the LDT */
|
995 |
if (!ldt_table) {
|
996 |
ldt_table = malloc(TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE); |
997 |
if (!ldt_table)
|
998 |
return -ENOMEM;
|
999 |
memset(ldt_table, 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
|
1000 |
env->ldt.base = ldt_table; |
1001 |
env->ldt.limit = 0xffff;
|
1002 |
} |
1003 |
|
1004 |
/* NOTE: same code as Linux kernel */
|
1005 |
/* Allow LDTs to be cleared by the user. */
|
1006 |
if (ldt_info.base_addr == 0 && ldt_info.limit == 0) { |
1007 |
if (oldmode ||
|
1008 |
(contents == 0 &&
|
1009 |
read_exec_only == 1 &&
|
1010 |
seg_32bit == 0 &&
|
1011 |
limit_in_pages == 0 &&
|
1012 |
seg_not_present == 1 &&
|
1013 |
useable == 0 )) {
|
1014 |
entry_1 = 0;
|
1015 |
entry_2 = 0;
|
1016 |
goto install;
|
1017 |
} |
1018 |
} |
1019 |
|
1020 |
entry_1 = ((ldt_info.base_addr & 0x0000ffff) << 16) | |
1021 |
(ldt_info.limit & 0x0ffff);
|
1022 |
entry_2 = (ldt_info.base_addr & 0xff000000) |
|
1023 |
((ldt_info.base_addr & 0x00ff0000) >> 16) | |
1024 |
(ldt_info.limit & 0xf0000) |
|
1025 |
((read_exec_only ^ 1) << 9) | |
1026 |
(contents << 10) |
|
1027 |
((seg_not_present ^ 1) << 15) | |
1028 |
(seg_32bit << 22) |
|
1029 |
(limit_in_pages << 23) |
|
1030 |
0x7000;
|
1031 |
if (!oldmode)
|
1032 |
entry_2 |= (useable << 20);
|
1033 |
|
1034 |
/* Install the new entry ... */
|
1035 |
install:
|
1036 |
lp = (uint32_t *)(ldt_table + (ldt_info.entry_number << 3));
|
1037 |
lp[0] = tswap32(entry_1);
|
1038 |
lp[1] = tswap32(entry_2);
|
1039 |
return 0; |
1040 |
} |
1041 |
|
1042 |
/* specific and weird i386 syscalls */
|
1043 |
int do_modify_ldt(CPUX86State *env, int func, void *ptr, unsigned long bytecount) |
1044 |
{ |
1045 |
int ret = -ENOSYS;
|
1046 |
|
1047 |
switch (func) {
|
1048 |
case 0: |
1049 |
ret = read_ldt(ptr, bytecount); |
1050 |
break;
|
1051 |
case 1: |
1052 |
ret = write_ldt(env, ptr, bytecount, 1);
|
1053 |
break;
|
1054 |
case 0x11: |
1055 |
ret = write_ldt(env, ptr, bytecount, 0);
|
1056 |
break;
|
1057 |
} |
1058 |
return ret;
|
1059 |
} |
1060 |
|
1061 |
/* vm86 emulation */
|
1062 |
|
1063 |
#define SAFE_MASK (0xDD5) |
1064 |
|
1065 |
int do_vm86(CPUX86State *env, long subfunction, |
1066 |
struct target_vm86plus_struct * target_v86)
|
1067 |
{ |
1068 |
TaskState *ts = env->opaque; |
1069 |
int ret;
|
1070 |
|
1071 |
switch (subfunction) {
|
1072 |
case TARGET_VM86_REQUEST_IRQ:
|
1073 |
case TARGET_VM86_FREE_IRQ:
|
1074 |
case TARGET_VM86_GET_IRQ_BITS:
|
1075 |
case TARGET_VM86_GET_AND_RESET_IRQ:
|
1076 |
gemu_log("qemu: unsupported vm86 subfunction (%ld)\n", subfunction);
|
1077 |
ret = -EINVAL; |
1078 |
goto out;
|
1079 |
case TARGET_VM86_PLUS_INSTALL_CHECK:
|
1080 |
/* NOTE: on old vm86 stuff this will return the error
|
1081 |
from verify_area(), because the subfunction is
|
1082 |
interpreted as (invalid) address to vm86_struct.
|
1083 |
So the installation check works.
|
1084 |
*/
|
1085 |
ret = 0;
|
1086 |
goto out;
|
1087 |
} |
1088 |
|
1089 |
ts->target_v86 = target_v86; |
1090 |
/* save current CPU regs */
|
1091 |
ts->vm86_saved_regs.eax = 0; /* default vm86 syscall return code */ |
1092 |
ts->vm86_saved_regs.ebx = env->regs[R_EBX]; |
1093 |
ts->vm86_saved_regs.ecx = env->regs[R_ECX]; |
1094 |
ts->vm86_saved_regs.edx = env->regs[R_EDX]; |
1095 |
ts->vm86_saved_regs.esi = env->regs[R_ESI]; |
1096 |
ts->vm86_saved_regs.edi = env->regs[R_EDI]; |
1097 |
ts->vm86_saved_regs.ebp = env->regs[R_EBP]; |
1098 |
ts->vm86_saved_regs.esp = env->regs[R_ESP]; |
1099 |
ts->vm86_saved_regs.eflags = env->eflags; |
1100 |
ts->vm86_saved_regs.eip = env->eip; |
1101 |
ts->vm86_saved_regs.cs = env->segs[R_CS]; |
1102 |
ts->vm86_saved_regs.ss = env->segs[R_SS]; |
1103 |
ts->vm86_saved_regs.ds = env->segs[R_DS]; |
1104 |
ts->vm86_saved_regs.es = env->segs[R_ES]; |
1105 |
ts->vm86_saved_regs.fs = env->segs[R_FS]; |
1106 |
ts->vm86_saved_regs.gs = env->segs[R_GS]; |
1107 |
|
1108 |
/* build vm86 CPU state */
|
1109 |
env->eflags = (env->eflags & ~SAFE_MASK) | |
1110 |
(tswap32(target_v86->regs.eflags) & SAFE_MASK) | VM_MASK; |
1111 |
|
1112 |
env->regs[R_EBX] = tswap32(target_v86->regs.ebx); |
1113 |
env->regs[R_ECX] = tswap32(target_v86->regs.ecx); |
1114 |
env->regs[R_EDX] = tswap32(target_v86->regs.edx); |
1115 |
env->regs[R_ESI] = tswap32(target_v86->regs.esi); |
1116 |
env->regs[R_EDI] = tswap32(target_v86->regs.edi); |
1117 |
env->regs[R_EBP] = tswap32(target_v86->regs.ebp); |
1118 |
env->regs[R_ESP] = tswap32(target_v86->regs.esp); |
1119 |
env->eip = tswap32(target_v86->regs.eip); |
1120 |
cpu_x86_load_seg(env, R_CS, tswap16(target_v86->regs.cs)); |
1121 |
cpu_x86_load_seg(env, R_SS, tswap16(target_v86->regs.ss)); |
1122 |
cpu_x86_load_seg(env, R_DS, tswap16(target_v86->regs.ds)); |
1123 |
cpu_x86_load_seg(env, R_ES, tswap16(target_v86->regs.es)); |
1124 |
cpu_x86_load_seg(env, R_FS, tswap16(target_v86->regs.fs)); |
1125 |
cpu_x86_load_seg(env, R_GS, tswap16(target_v86->regs.gs)); |
1126 |
ret = tswap32(target_v86->regs.eax); /* eax will be restored at
|
1127 |
the end of the syscall */
|
1128 |
/* now the virtual CPU is ready for vm86 execution ! */
|
1129 |
out:
|
1130 |
return ret;
|
1131 |
} |
1132 |
|
1133 |
/* this stack is the equivalent of the kernel stack associated with a
|
1134 |
thread/process */
|
1135 |
#define NEW_STACK_SIZE 8192 |
1136 |
|
1137 |
static int clone_func(void *arg) |
1138 |
{ |
1139 |
CPUX86State *env = arg; |
1140 |
cpu_loop(env); |
1141 |
/* never exits */
|
1142 |
return 0; |
1143 |
} |
1144 |
|
1145 |
int do_fork(CPUX86State *env, unsigned int flags, unsigned long newsp) |
1146 |
{ |
1147 |
int ret;
|
1148 |
TaskState *ts; |
1149 |
uint8_t *new_stack; |
1150 |
CPUX86State *new_env; |
1151 |
|
1152 |
if (flags & CLONE_VM) {
|
1153 |
if (!newsp)
|
1154 |
newsp = env->regs[R_ESP]; |
1155 |
ts = malloc(sizeof(TaskState) + NEW_STACK_SIZE);
|
1156 |
memset(ts, 0, sizeof(TaskState)); |
1157 |
new_stack = ts->stack; |
1158 |
ts->used = 1;
|
1159 |
/* add in task state list */
|
1160 |
ts->next = first_task_state; |
1161 |
first_task_state = ts; |
1162 |
/* we create a new CPU instance. */
|
1163 |
new_env = cpu_x86_init(); |
1164 |
memcpy(new_env, env, sizeof(CPUX86State));
|
1165 |
new_env->regs[R_ESP] = newsp; |
1166 |
new_env->regs[R_EAX] = 0;
|
1167 |
new_env->opaque = ts; |
1168 |
#ifdef __ia64__
|
1169 |
ret = clone2(clone_func, new_stack + NEW_STACK_SIZE, flags, new_env); |
1170 |
#else
|
1171 |
ret = clone(clone_func, new_stack + NEW_STACK_SIZE, flags, new_env); |
1172 |
#endif
|
1173 |
} else {
|
1174 |
/* if no CLONE_VM, we consider it is a fork */
|
1175 |
if ((flags & ~CSIGNAL) != 0) |
1176 |
return -EINVAL;
|
1177 |
ret = fork(); |
1178 |
} |
1179 |
return ret;
|
1180 |
} |
1181 |
|
1182 |
#endif
|
1183 |
|
1184 |
#define high2lowuid(x) (x)
|
1185 |
#define high2lowgid(x) (x)
|
1186 |
#define low2highuid(x) (x)
|
1187 |
#define low2highgid(x) (x)
|
1188 |
|
1189 |
void syscall_init(void) |
1190 |
{ |
1191 |
#define STRUCT(name, list...) thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def); |
1192 |
#define STRUCT_SPECIAL(name) thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def); |
1193 |
#include "syscall_types.h" |
1194 |
#undef STRUCT
|
1195 |
#undef STRUCT_SPECIAL
|
1196 |
} |
1197 |
|
1198 |
long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, |
1199 |
long arg4, long arg5, long arg6) |
1200 |
{ |
1201 |
long ret;
|
1202 |
struct stat st;
|
1203 |
struct kernel_statfs *stfs;
|
1204 |
|
1205 |
#ifdef DEBUG
|
1206 |
gemu_log("syscall %d\n", num);
|
1207 |
#endif
|
1208 |
switch(num) {
|
1209 |
case TARGET_NR_exit:
|
1210 |
#ifdef HAVE_GPROF
|
1211 |
_mcleanup(); |
1212 |
#endif
|
1213 |
/* XXX: should free thread stack and CPU env */
|
1214 |
_exit(arg1); |
1215 |
ret = 0; /* avoid warning */ |
1216 |
break;
|
1217 |
case TARGET_NR_read:
|
1218 |
ret = get_errno(read(arg1, (void *)arg2, arg3));
|
1219 |
break;
|
1220 |
case TARGET_NR_write:
|
1221 |
ret = get_errno(write(arg1, (void *)arg2, arg3));
|
1222 |
break;
|
1223 |
case TARGET_NR_open:
|
1224 |
ret = get_errno(open(path((const char *)arg1), arg2, arg3)); |
1225 |
break;
|
1226 |
case TARGET_NR_close:
|
1227 |
ret = get_errno(close(arg1)); |
1228 |
break;
|
1229 |
case TARGET_NR_brk:
|
1230 |
ret = do_brk((char *)arg1);
|
1231 |
break;
|
1232 |
case TARGET_NR_fork:
|
1233 |
ret = get_errno(do_fork(cpu_env, SIGCHLD, 0));
|
1234 |
break;
|
1235 |
case TARGET_NR_waitpid:
|
1236 |
{ |
1237 |
int *status = (int *)arg2; |
1238 |
ret = get_errno(waitpid(arg1, status, arg3)); |
1239 |
if (!is_error(ret) && status)
|
1240 |
tswapls((long *)&status);
|
1241 |
} |
1242 |
break;
|
1243 |
case TARGET_NR_creat:
|
1244 |
ret = get_errno(creat((const char *)arg1, arg2)); |
1245 |
break;
|
1246 |
case TARGET_NR_link:
|
1247 |
ret = get_errno(link((const char *)arg1, (const char *)arg2)); |
1248 |
break;
|
1249 |
case TARGET_NR_unlink:
|
1250 |
ret = get_errno(unlink((const char *)arg1)); |
1251 |
break;
|
1252 |
case TARGET_NR_execve:
|
1253 |
{ |
1254 |
char **argp, **envp;
|
1255 |
int argc, envc;
|
1256 |
uint32_t *p; |
1257 |
char **q;
|
1258 |
|
1259 |
argc = 0;
|
1260 |
for (p = (void *)arg2; *p; p++) |
1261 |
argc++; |
1262 |
envc = 0;
|
1263 |
for (p = (void *)arg3; *p; p++) |
1264 |
envc++; |
1265 |
|
1266 |
argp = alloca((argc + 1) * sizeof(void *)); |
1267 |
envp = alloca((envc + 1) * sizeof(void *)); |
1268 |
|
1269 |
for (p = (void *)arg2, q = argp; *p; p++, q++) |
1270 |
*q = (void *)tswap32(*p);
|
1271 |
*q = NULL;
|
1272 |
|
1273 |
for (p = (void *)arg3, q = envp; *p; p++, q++) |
1274 |
*q = (void *)tswap32(*p);
|
1275 |
*q = NULL;
|
1276 |
|
1277 |
ret = get_errno(execve((const char *)arg1, argp, envp)); |
1278 |
} |
1279 |
break;
|
1280 |
case TARGET_NR_chdir:
|
1281 |
ret = get_errno(chdir((const char *)arg1)); |
1282 |
break;
|
1283 |
case TARGET_NR_time:
|
1284 |
{ |
1285 |
int *time_ptr = (int *)arg1; |
1286 |
ret = get_errno(time((time_t *)time_ptr)); |
1287 |
if (!is_error(ret) && time_ptr)
|
1288 |
tswap32s(time_ptr); |
1289 |
} |
1290 |
break;
|
1291 |
case TARGET_NR_mknod:
|
1292 |
ret = get_errno(mknod((const char *)arg1, arg2, arg3)); |
1293 |
break;
|
1294 |
case TARGET_NR_chmod:
|
1295 |
ret = get_errno(chmod((const char *)arg1, arg2)); |
1296 |
break;
|
1297 |
case TARGET_NR_lchown:
|
1298 |
ret = get_errno(chown((const char *)arg1, arg2, arg3)); |
1299 |
break;
|
1300 |
case TARGET_NR_break:
|
1301 |
goto unimplemented;
|
1302 |
case TARGET_NR_oldstat:
|
1303 |
goto unimplemented;
|
1304 |
case TARGET_NR_lseek:
|
1305 |
ret = get_errno(lseek(arg1, arg2, arg3)); |
1306 |
break;
|
1307 |
case TARGET_NR_getpid:
|
1308 |
ret = get_errno(getpid()); |
1309 |
break;
|
1310 |
case TARGET_NR_mount:
|
1311 |
/* need to look at the data field */
|
1312 |
goto unimplemented;
|
1313 |
case TARGET_NR_umount:
|
1314 |
ret = get_errno(umount((const char *)arg1)); |
1315 |
break;
|
1316 |
case TARGET_NR_setuid:
|
1317 |
ret = get_errno(setuid(low2highuid(arg1))); |
1318 |
break;
|
1319 |
case TARGET_NR_getuid:
|
1320 |
ret = get_errno(getuid()); |
1321 |
break;
|
1322 |
case TARGET_NR_stime:
|
1323 |
{ |
1324 |
int *time_ptr = (int *)arg1; |
1325 |
if (time_ptr)
|
1326 |
tswap32s(time_ptr); |
1327 |
ret = get_errno(stime((time_t *)time_ptr)); |
1328 |
} |
1329 |
break;
|
1330 |
case TARGET_NR_ptrace:
|
1331 |
goto unimplemented;
|
1332 |
case TARGET_NR_alarm:
|
1333 |
ret = alarm(arg1); |
1334 |
break;
|
1335 |
case TARGET_NR_oldfstat:
|
1336 |
goto unimplemented;
|
1337 |
case TARGET_NR_pause:
|
1338 |
ret = get_errno(pause()); |
1339 |
break;
|
1340 |
case TARGET_NR_utime:
|
1341 |
goto unimplemented;
|
1342 |
case TARGET_NR_stty:
|
1343 |
goto unimplemented;
|
1344 |
case TARGET_NR_gtty:
|
1345 |
goto unimplemented;
|
1346 |
case TARGET_NR_access:
|
1347 |
ret = get_errno(access((const char *)arg1, arg2)); |
1348 |
break;
|
1349 |
case TARGET_NR_nice:
|
1350 |
ret = get_errno(nice(arg1)); |
1351 |
break;
|
1352 |
case TARGET_NR_ftime:
|
1353 |
goto unimplemented;
|
1354 |
case TARGET_NR_sync:
|
1355 |
sync(); |
1356 |
ret = 0;
|
1357 |
break;
|
1358 |
case TARGET_NR_kill:
|
1359 |
ret = get_errno(kill(arg1, arg2)); |
1360 |
break;
|
1361 |
case TARGET_NR_rename:
|
1362 |
ret = get_errno(rename((const char *)arg1, (const char *)arg2)); |
1363 |
break;
|
1364 |
case TARGET_NR_mkdir:
|
1365 |
ret = get_errno(mkdir((const char *)arg1, arg2)); |
1366 |
break;
|
1367 |
case TARGET_NR_rmdir:
|
1368 |
ret = get_errno(rmdir((const char *)arg1)); |
1369 |
break;
|
1370 |
case TARGET_NR_dup:
|
1371 |
ret = get_errno(dup(arg1)); |
1372 |
break;
|
1373 |
case TARGET_NR_pipe:
|
1374 |
{ |
1375 |
int *pipe_ptr = (int *)arg1; |
1376 |
ret = get_errno(pipe(pipe_ptr)); |
1377 |
if (!is_error(ret)) {
|
1378 |
tswap32s(&pipe_ptr[0]);
|
1379 |
tswap32s(&pipe_ptr[1]);
|
1380 |
} |
1381 |
} |
1382 |
break;
|
1383 |
case TARGET_NR_times:
|
1384 |
{ |
1385 |
struct target_tms *tmsp = (void *)arg1; |
1386 |
struct tms tms;
|
1387 |
ret = get_errno(times(&tms)); |
1388 |
if (tmsp) {
|
1389 |
tmsp->tms_utime = tswapl(tms.tms_utime); |
1390 |
tmsp->tms_stime = tswapl(tms.tms_stime); |
1391 |
tmsp->tms_cutime = tswapl(tms.tms_cutime); |
1392 |
tmsp->tms_cstime = tswapl(tms.tms_cstime); |
1393 |
} |
1394 |
} |
1395 |
break;
|
1396 |
case TARGET_NR_prof:
|
1397 |
goto unimplemented;
|
1398 |
case TARGET_NR_setgid:
|
1399 |
ret = get_errno(setgid(low2highgid(arg1))); |
1400 |
break;
|
1401 |
case TARGET_NR_getgid:
|
1402 |
ret = get_errno(getgid()); |
1403 |
break;
|
1404 |
case TARGET_NR_signal:
|
1405 |
goto unimplemented;
|
1406 |
case TARGET_NR_geteuid:
|
1407 |
ret = get_errno(geteuid()); |
1408 |
break;
|
1409 |
case TARGET_NR_getegid:
|
1410 |
ret = get_errno(getegid()); |
1411 |
break;
|
1412 |
case TARGET_NR_acct:
|
1413 |
goto unimplemented;
|
1414 |
case TARGET_NR_umount2:
|
1415 |
ret = get_errno(umount2((const char *)arg1, arg2)); |
1416 |
break;
|
1417 |
case TARGET_NR_lock:
|
1418 |
goto unimplemented;
|
1419 |
case TARGET_NR_ioctl:
|
1420 |
ret = do_ioctl(arg1, arg2, arg3); |
1421 |
break;
|
1422 |
case TARGET_NR_fcntl:
|
1423 |
{ |
1424 |
struct flock fl;
|
1425 |
struct target_flock *target_fl = (void *)arg3; |
1426 |
|
1427 |
switch(arg2) {
|
1428 |
case TARGET_F_GETLK:
|
1429 |
ret = get_errno(fcntl(arg1, arg2, &fl)); |
1430 |
if (ret == 0) { |
1431 |
target_fl->l_type = tswap16(fl.l_type); |
1432 |
target_fl->l_whence = tswap16(fl.l_whence); |
1433 |
target_fl->l_start = tswapl(fl.l_start); |
1434 |
target_fl->l_len = tswapl(fl.l_len); |
1435 |
target_fl->l_pid = tswapl(fl.l_pid); |
1436 |
} |
1437 |
break;
|
1438 |
|
1439 |
case TARGET_F_SETLK:
|
1440 |
case TARGET_F_SETLKW:
|
1441 |
fl.l_type = tswap16(target_fl->l_type); |
1442 |
fl.l_whence = tswap16(target_fl->l_whence); |
1443 |
fl.l_start = tswapl(target_fl->l_start); |
1444 |
fl.l_len = tswapl(target_fl->l_len); |
1445 |
fl.l_pid = tswapl(target_fl->l_pid); |
1446 |
ret = get_errno(fcntl(arg1, arg2, &fl)); |
1447 |
break;
|
1448 |
|
1449 |
case TARGET_F_GETLK64:
|
1450 |
case TARGET_F_SETLK64:
|
1451 |
case TARGET_F_SETLKW64:
|
1452 |
goto unimplemented;
|
1453 |
default:
|
1454 |
ret = get_errno(fcntl(arg1, arg2, arg3)); |
1455 |
break;
|
1456 |
} |
1457 |
break;
|
1458 |
} |
1459 |
case TARGET_NR_mpx:
|
1460 |
goto unimplemented;
|
1461 |
case TARGET_NR_setpgid:
|
1462 |
ret = get_errno(setpgid(arg1, arg2)); |
1463 |
break;
|
1464 |
case TARGET_NR_ulimit:
|
1465 |
goto unimplemented;
|
1466 |
case TARGET_NR_oldolduname:
|
1467 |
goto unimplemented;
|
1468 |
case TARGET_NR_umask:
|
1469 |
ret = get_errno(umask(arg1)); |
1470 |
break;
|
1471 |
case TARGET_NR_chroot:
|
1472 |
ret = get_errno(chroot((const char *)arg1)); |
1473 |
break;
|
1474 |
case TARGET_NR_ustat:
|
1475 |
goto unimplemented;
|
1476 |
case TARGET_NR_dup2:
|
1477 |
ret = get_errno(dup2(arg1, arg2)); |
1478 |
break;
|
1479 |
case TARGET_NR_getppid:
|
1480 |
ret = get_errno(getppid()); |
1481 |
break;
|
1482 |
case TARGET_NR_getpgrp:
|
1483 |
ret = get_errno(getpgrp()); |
1484 |
break;
|
1485 |
case TARGET_NR_setsid:
|
1486 |
ret = get_errno(setsid()); |
1487 |
break;
|
1488 |
case TARGET_NR_sigaction:
|
1489 |
{ |
1490 |
struct target_old_sigaction *old_act = (void *)arg2; |
1491 |
struct target_old_sigaction *old_oact = (void *)arg3; |
1492 |
struct target_sigaction act, oact, *pact;
|
1493 |
if (old_act) {
|
1494 |
act._sa_handler = old_act->_sa_handler; |
1495 |
target_siginitset(&act.sa_mask, old_act->sa_mask); |
1496 |
act.sa_flags = old_act->sa_flags; |
1497 |
act.sa_restorer = old_act->sa_restorer; |
1498 |
pact = &act; |
1499 |
} else {
|
1500 |
pact = NULL;
|
1501 |
} |
1502 |
ret = get_errno(do_sigaction(arg1, pact, &oact)); |
1503 |
if (!is_error(ret) && old_oact) {
|
1504 |
old_oact->_sa_handler = oact._sa_handler; |
1505 |
old_oact->sa_mask = oact.sa_mask.sig[0];
|
1506 |
old_oact->sa_flags = oact.sa_flags; |
1507 |
old_oact->sa_restorer = oact.sa_restorer; |
1508 |
} |
1509 |
} |
1510 |
break;
|
1511 |
case TARGET_NR_rt_sigaction:
|
1512 |
ret = get_errno(do_sigaction(arg1, (void *)arg2, (void *)arg3)); |
1513 |
break;
|
1514 |
case TARGET_NR_sgetmask:
|
1515 |
{ |
1516 |
sigset_t cur_set; |
1517 |
target_ulong target_set; |
1518 |
sigprocmask(0, NULL, &cur_set); |
1519 |
host_to_target_old_sigset(&target_set, &cur_set); |
1520 |
ret = target_set; |
1521 |
} |
1522 |
break;
|
1523 |
case TARGET_NR_ssetmask:
|
1524 |
{ |
1525 |
sigset_t set, oset, cur_set; |
1526 |
target_ulong target_set = arg1; |
1527 |
sigprocmask(0, NULL, &cur_set); |
1528 |
target_to_host_old_sigset(&set, &target_set); |
1529 |
sigorset(&set, &set, &cur_set); |
1530 |
sigprocmask(SIG_SETMASK, &set, &oset); |
1531 |
host_to_target_old_sigset(&target_set, &oset); |
1532 |
ret = target_set; |
1533 |
} |
1534 |
break;
|
1535 |
case TARGET_NR_sigprocmask:
|
1536 |
{ |
1537 |
int how = arg1;
|
1538 |
sigset_t set, oldset, *set_ptr; |
1539 |
target_ulong *pset = (void *)arg2, *poldset = (void *)arg3; |
1540 |
|
1541 |
if (pset) {
|
1542 |
switch(how) {
|
1543 |
case TARGET_SIG_BLOCK:
|
1544 |
how = SIG_BLOCK; |
1545 |
break;
|
1546 |
case TARGET_SIG_UNBLOCK:
|
1547 |
how = SIG_UNBLOCK; |
1548 |
break;
|
1549 |
case TARGET_SIG_SETMASK:
|
1550 |
how = SIG_SETMASK; |
1551 |
break;
|
1552 |
default:
|
1553 |
ret = -EINVAL; |
1554 |
goto fail;
|
1555 |
} |
1556 |
target_to_host_old_sigset(&set, pset); |
1557 |
set_ptr = &set; |
1558 |
} else {
|
1559 |
how = 0;
|
1560 |
set_ptr = NULL;
|
1561 |
} |
1562 |
ret = get_errno(sigprocmask(arg1, set_ptr, &oldset)); |
1563 |
if (!is_error(ret) && poldset) {
|
1564 |
host_to_target_old_sigset(poldset, &oldset); |
1565 |
} |
1566 |
} |
1567 |
break;
|
1568 |
case TARGET_NR_rt_sigprocmask:
|
1569 |
{ |
1570 |
int how = arg1;
|
1571 |
sigset_t set, oldset, *set_ptr; |
1572 |
target_sigset_t *pset = (void *)arg2;
|
1573 |
target_sigset_t *poldset = (void *)arg3;
|
1574 |
|
1575 |
if (pset) {
|
1576 |
switch(how) {
|
1577 |
case TARGET_SIG_BLOCK:
|
1578 |
how = SIG_BLOCK; |
1579 |
break;
|
1580 |
case TARGET_SIG_UNBLOCK:
|
1581 |
how = SIG_UNBLOCK; |
1582 |
break;
|
1583 |
case TARGET_SIG_SETMASK:
|
1584 |
how = SIG_SETMASK; |
1585 |
break;
|
1586 |
default:
|
1587 |
ret = -EINVAL; |
1588 |
goto fail;
|
1589 |
} |
1590 |
target_to_host_sigset(&set, pset); |
1591 |
set_ptr = &set; |
1592 |
} else {
|
1593 |
how = 0;
|
1594 |
set_ptr = NULL;
|
1595 |
} |
1596 |
ret = get_errno(sigprocmask(how, set_ptr, &oldset)); |
1597 |
if (!is_error(ret) && poldset) {
|
1598 |
host_to_target_sigset(poldset, &oldset); |
1599 |
} |
1600 |
} |
1601 |
break;
|
1602 |
case TARGET_NR_sigpending:
|
1603 |
{ |
1604 |
sigset_t set; |
1605 |
ret = get_errno(sigpending(&set)); |
1606 |
if (!is_error(ret)) {
|
1607 |
host_to_target_old_sigset((target_ulong *)arg1, &set); |
1608 |
} |
1609 |
} |
1610 |
break;
|
1611 |
case TARGET_NR_rt_sigpending:
|
1612 |
{ |
1613 |
sigset_t set; |
1614 |
ret = get_errno(sigpending(&set)); |
1615 |
if (!is_error(ret)) {
|
1616 |
host_to_target_sigset((target_sigset_t *)arg1, &set); |
1617 |
} |
1618 |
} |
1619 |
break;
|
1620 |
case TARGET_NR_sigsuspend:
|
1621 |
{ |
1622 |
sigset_t set; |
1623 |
target_to_host_old_sigset(&set, (target_ulong *)arg1); |
1624 |
ret = get_errno(sigsuspend(&set)); |
1625 |
} |
1626 |
break;
|
1627 |
case TARGET_NR_rt_sigsuspend:
|
1628 |
{ |
1629 |
sigset_t set; |
1630 |
target_to_host_sigset(&set, (target_sigset_t *)arg1); |
1631 |
ret = get_errno(sigsuspend(&set)); |
1632 |
} |
1633 |
break;
|
1634 |
case TARGET_NR_rt_sigtimedwait:
|
1635 |
{ |
1636 |
target_sigset_t *target_set = (void *)arg1;
|
1637 |
target_siginfo_t *target_uinfo = (void *)arg2;
|
1638 |
struct target_timespec *target_uts = (void *)arg3; |
1639 |
sigset_t set; |
1640 |
struct timespec uts, *puts;
|
1641 |
siginfo_t uinfo; |
1642 |
|
1643 |
target_to_host_sigset(&set, target_set); |
1644 |
if (target_uts) {
|
1645 |
puts = &uts; |
1646 |
puts->tv_sec = tswapl(target_uts->tv_sec); |
1647 |
puts->tv_nsec = tswapl(target_uts->tv_nsec); |
1648 |
} else {
|
1649 |
puts = NULL;
|
1650 |
} |
1651 |
ret = get_errno(sigtimedwait(&set, &uinfo, puts)); |
1652 |
if (!is_error(ret) && target_uinfo) {
|
1653 |
host_to_target_siginfo(target_uinfo, &uinfo); |
1654 |
} |
1655 |
} |
1656 |
break;
|
1657 |
case TARGET_NR_rt_sigqueueinfo:
|
1658 |
{ |
1659 |
siginfo_t uinfo; |
1660 |
target_to_host_siginfo(&uinfo, (target_siginfo_t *)arg3); |
1661 |
ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo)); |
1662 |
} |
1663 |
break;
|
1664 |
case TARGET_NR_sigreturn:
|
1665 |
/* NOTE: ret is eax, so not transcoding must be done */
|
1666 |
ret = do_sigreturn(cpu_env); |
1667 |
break;
|
1668 |
case TARGET_NR_rt_sigreturn:
|
1669 |
/* NOTE: ret is eax, so not transcoding must be done */
|
1670 |
ret = do_rt_sigreturn(cpu_env); |
1671 |
break;
|
1672 |
case TARGET_NR_setreuid:
|
1673 |
ret = get_errno(setreuid(arg1, arg2)); |
1674 |
break;
|
1675 |
case TARGET_NR_setregid:
|
1676 |
ret = get_errno(setregid(arg1, arg2)); |
1677 |
break;
|
1678 |
case TARGET_NR_sethostname:
|
1679 |
ret = get_errno(sethostname((const char *)arg1, arg2)); |
1680 |
break;
|
1681 |
case TARGET_NR_setrlimit:
|
1682 |
{ |
1683 |
/* XXX: convert resource ? */
|
1684 |
int resource = arg1;
|
1685 |
struct target_rlimit *target_rlim = (void *)arg2; |
1686 |
struct rlimit rlim;
|
1687 |
rlim.rlim_cur = tswapl(target_rlim->rlim_cur); |
1688 |
rlim.rlim_max = tswapl(target_rlim->rlim_max); |
1689 |
ret = get_errno(setrlimit(resource, &rlim)); |
1690 |
} |
1691 |
break;
|
1692 |
case TARGET_NR_getrlimit:
|
1693 |
{ |
1694 |
/* XXX: convert resource ? */
|
1695 |
int resource = arg1;
|
1696 |
struct target_rlimit *target_rlim = (void *)arg2; |
1697 |
struct rlimit rlim;
|
1698 |
|
1699 |
ret = get_errno(getrlimit(resource, &rlim)); |
1700 |
if (!is_error(ret)) {
|
1701 |
target_rlim->rlim_cur = tswapl(rlim.rlim_cur); |
1702 |
target_rlim->rlim_max = tswapl(rlim.rlim_max); |
1703 |
} |
1704 |
} |
1705 |
break;
|
1706 |
case TARGET_NR_getrusage:
|
1707 |
goto unimplemented;
|
1708 |
case TARGET_NR_gettimeofday:
|
1709 |
{ |
1710 |
struct target_timeval *target_tv = (void *)arg1; |
1711 |
struct timeval tv;
|
1712 |
ret = get_errno(gettimeofday(&tv, NULL));
|
1713 |
if (!is_error(ret)) {
|
1714 |
host_to_target_timeval(target_tv, &tv); |
1715 |
} |
1716 |
} |
1717 |
break;
|
1718 |
case TARGET_NR_settimeofday:
|
1719 |
{ |
1720 |
struct target_timeval *target_tv = (void *)arg1; |
1721 |
struct timeval tv;
|
1722 |
target_to_host_timeval(&tv, target_tv); |
1723 |
ret = get_errno(settimeofday(&tv, NULL));
|
1724 |
} |
1725 |
break;
|
1726 |
case TARGET_NR_getgroups:
|
1727 |
{ |
1728 |
int gidsetsize = arg1;
|
1729 |
uint16_t *target_grouplist = (void *)arg2;
|
1730 |
gid_t *grouplist; |
1731 |
int i;
|
1732 |
|
1733 |
grouplist = alloca(gidsetsize * sizeof(gid_t));
|
1734 |
ret = get_errno(getgroups(gidsetsize, grouplist)); |
1735 |
if (!is_error(ret)) {
|
1736 |
for(i = 0;i < gidsetsize; i++) |
1737 |
target_grouplist[i] = tswap16(grouplist[i]); |
1738 |
} |
1739 |
} |
1740 |
break;
|
1741 |
case TARGET_NR_setgroups:
|
1742 |
{ |
1743 |
int gidsetsize = arg1;
|
1744 |
uint16_t *target_grouplist = (void *)arg2;
|
1745 |
gid_t *grouplist; |
1746 |
int i;
|
1747 |
|
1748 |
grouplist = alloca(gidsetsize * sizeof(gid_t));
|
1749 |
for(i = 0;i < gidsetsize; i++) |
1750 |
grouplist[i] = tswap16(target_grouplist[i]); |
1751 |
ret = get_errno(setgroups(gidsetsize, grouplist)); |
1752 |
} |
1753 |
break;
|
1754 |
case TARGET_NR_select:
|
1755 |
goto unimplemented;
|
1756 |
case TARGET_NR_symlink:
|
1757 |
ret = get_errno(symlink((const char *)arg1, (const char *)arg2)); |
1758 |
break;
|
1759 |
case TARGET_NR_oldlstat:
|
1760 |
goto unimplemented;
|
1761 |
case TARGET_NR_readlink:
|
1762 |
ret = get_errno(readlink(path((const char *)arg1), (char *)arg2, arg3)); |
1763 |
break;
|
1764 |
case TARGET_NR_uselib:
|
1765 |
goto unimplemented;
|
1766 |
case TARGET_NR_swapon:
|
1767 |
ret = get_errno(swapon((const char *)arg1, arg2)); |
1768 |
break;
|
1769 |
case TARGET_NR_reboot:
|
1770 |
goto unimplemented;
|
1771 |
case TARGET_NR_readdir:
|
1772 |
goto unimplemented;
|
1773 |
#ifdef TARGET_I386
|
1774 |
case TARGET_NR_mmap:
|
1775 |
{ |
1776 |
uint32_t v1, v2, v3, v4, v5, v6, *vptr; |
1777 |
vptr = (uint32_t *)arg1; |
1778 |
v1 = tswap32(vptr[0]);
|
1779 |
v2 = tswap32(vptr[1]);
|
1780 |
v3 = tswap32(vptr[2]);
|
1781 |
v4 = tswap32(vptr[3]);
|
1782 |
v5 = tswap32(vptr[4]);
|
1783 |
v6 = tswap32(vptr[5]);
|
1784 |
ret = get_errno((long)mmap((void *)v1, v2, v3, v4, v5, v6)); |
1785 |
} |
1786 |
break;
|
1787 |
#endif
|
1788 |
#ifdef TARGET_I386
|
1789 |
case TARGET_NR_mmap2:
|
1790 |
#else
|
1791 |
case TARGET_NR_mmap:
|
1792 |
#endif
|
1793 |
ret = get_errno((long)mmap((void *)arg1, arg2, arg3, arg4, arg5, arg6)); |
1794 |
break;
|
1795 |
case TARGET_NR_munmap:
|
1796 |
ret = get_errno(munmap((void *)arg1, arg2));
|
1797 |
break;
|
1798 |
case TARGET_NR_mprotect:
|
1799 |
ret = get_errno(mprotect((void *)arg1, arg2, arg3));
|
1800 |
break;
|
1801 |
case TARGET_NR_mremap:
|
1802 |
ret = get_errno((long)mremap((void *)arg1, arg2, arg3, arg4)); |
1803 |
break;
|
1804 |
case TARGET_NR_msync:
|
1805 |
ret = get_errno(msync((void *)arg1, arg2, arg3));
|
1806 |
break;
|
1807 |
case TARGET_NR_mlock:
|
1808 |
ret = get_errno(mlock((void *)arg1, arg2));
|
1809 |
break;
|
1810 |
case TARGET_NR_munlock:
|
1811 |
ret = get_errno(munlock((void *)arg1, arg2));
|
1812 |
break;
|
1813 |
case TARGET_NR_mlockall:
|
1814 |
ret = get_errno(mlockall(arg1)); |
1815 |
break;
|
1816 |
case TARGET_NR_munlockall:
|
1817 |
ret = get_errno(munlockall()); |
1818 |
break;
|
1819 |
case TARGET_NR_truncate:
|
1820 |
ret = get_errno(truncate((const char *)arg1, arg2)); |
1821 |
break;
|
1822 |
case TARGET_NR_ftruncate:
|
1823 |
ret = get_errno(ftruncate(arg1, arg2)); |
1824 |
break;
|
1825 |
case TARGET_NR_fchmod:
|
1826 |
ret = get_errno(fchmod(arg1, arg2)); |
1827 |
break;
|
1828 |
case TARGET_NR_fchown:
|
1829 |
ret = get_errno(fchown(arg1, arg2, arg3)); |
1830 |
break;
|
1831 |
case TARGET_NR_getpriority:
|
1832 |
ret = get_errno(getpriority(arg1, arg2)); |
1833 |
break;
|
1834 |
case TARGET_NR_setpriority:
|
1835 |
ret = get_errno(setpriority(arg1, arg2, arg3)); |
1836 |
break;
|
1837 |
case TARGET_NR_profil:
|
1838 |
goto unimplemented;
|
1839 |
case TARGET_NR_statfs:
|
1840 |
stfs = (void *)arg2;
|
1841 |
ret = get_errno(sys_statfs(path((const char *)arg1), stfs)); |
1842 |
convert_statfs:
|
1843 |
if (!is_error(ret)) {
|
1844 |
tswap32s(&stfs->f_type); |
1845 |
tswap32s(&stfs->f_bsize); |
1846 |
tswap32s(&stfs->f_blocks); |
1847 |
tswap32s(&stfs->f_bfree); |
1848 |
tswap32s(&stfs->f_bavail); |
1849 |
tswap32s(&stfs->f_files); |
1850 |
tswap32s(&stfs->f_ffree); |
1851 |
tswap32s(&stfs->f_fsid.val[0]);
|
1852 |
tswap32s(&stfs->f_fsid.val[1]);
|
1853 |
tswap32s(&stfs->f_namelen); |
1854 |
} |
1855 |
break;
|
1856 |
case TARGET_NR_fstatfs:
|
1857 |
stfs = (void *)arg2;
|
1858 |
ret = get_errno(sys_fstatfs(arg1, stfs)); |
1859 |
goto convert_statfs;
|
1860 |
case TARGET_NR_ioperm:
|
1861 |
goto unimplemented;
|
1862 |
case TARGET_NR_socketcall:
|
1863 |
ret = do_socketcall(arg1, (int32_t *)arg2); |
1864 |
break;
|
1865 |
case TARGET_NR_syslog:
|
1866 |
goto unimplemented;
|
1867 |
case TARGET_NR_setitimer:
|
1868 |
{ |
1869 |
struct target_itimerval *target_value = (void *)arg2; |
1870 |
struct target_itimerval *target_ovalue = (void *)arg3; |
1871 |
struct itimerval value, ovalue, *pvalue;
|
1872 |
|
1873 |
if (target_value) {
|
1874 |
pvalue = &value; |
1875 |
target_to_host_timeval(&pvalue->it_interval, |
1876 |
&target_value->it_interval); |
1877 |
target_to_host_timeval(&pvalue->it_value, |
1878 |
&target_value->it_value); |
1879 |
} else {
|
1880 |
pvalue = NULL;
|
1881 |
} |
1882 |
ret = get_errno(setitimer(arg1, pvalue, &ovalue)); |
1883 |
if (!is_error(ret) && target_ovalue) {
|
1884 |
host_to_target_timeval(&target_ovalue->it_interval, |
1885 |
&ovalue.it_interval); |
1886 |
host_to_target_timeval(&target_ovalue->it_value, |
1887 |
&ovalue.it_value); |
1888 |
} |
1889 |
} |
1890 |
break;
|
1891 |
case TARGET_NR_getitimer:
|
1892 |
{ |
1893 |
struct target_itimerval *target_value = (void *)arg2; |
1894 |
struct itimerval value;
|
1895 |
|
1896 |
ret = get_errno(getitimer(arg1, &value)); |
1897 |
if (!is_error(ret) && target_value) {
|
1898 |
host_to_target_timeval(&target_value->it_interval, |
1899 |
&value.it_interval); |
1900 |
host_to_target_timeval(&target_value->it_value, |
1901 |
&value.it_value); |
1902 |
} |
1903 |
} |
1904 |
break;
|
1905 |
case TARGET_NR_stat:
|
1906 |
ret = get_errno(stat(path((const char *)arg1), &st)); |
1907 |
goto do_stat;
|
1908 |
case TARGET_NR_lstat:
|
1909 |
ret = get_errno(lstat(path((const char *)arg1), &st)); |
1910 |
goto do_stat;
|
1911 |
case TARGET_NR_fstat:
|
1912 |
{ |
1913 |
ret = get_errno(fstat(arg1, &st)); |
1914 |
do_stat:
|
1915 |
if (!is_error(ret)) {
|
1916 |
struct target_stat *target_st = (void *)arg2; |
1917 |
target_st->st_dev = tswap16(st.st_dev); |
1918 |
target_st->st_ino = tswapl(st.st_ino); |
1919 |
target_st->st_mode = tswap16(st.st_mode); |
1920 |
target_st->st_nlink = tswap16(st.st_nlink); |
1921 |
target_st->st_uid = tswap16(st.st_uid); |
1922 |
target_st->st_gid = tswap16(st.st_gid); |
1923 |
target_st->st_rdev = tswap16(st.st_rdev); |
1924 |
target_st->st_size = tswapl(st.st_size); |
1925 |
target_st->st_blksize = tswapl(st.st_blksize); |
1926 |
target_st->st_blocks = tswapl(st.st_blocks); |
1927 |
target_st->target_st_atime = tswapl(st.st_atime); |
1928 |
target_st->target_st_mtime = tswapl(st.st_mtime); |
1929 |
target_st->target_st_ctime = tswapl(st.st_ctime); |
1930 |
} |
1931 |
} |
1932 |
break;
|
1933 |
case TARGET_NR_olduname:
|
1934 |
goto unimplemented;
|
1935 |
case TARGET_NR_iopl:
|
1936 |
goto unimplemented;
|
1937 |
case TARGET_NR_vhangup:
|
1938 |
ret = get_errno(vhangup()); |
1939 |
break;
|
1940 |
case TARGET_NR_idle:
|
1941 |
goto unimplemented;
|
1942 |
case TARGET_NR_wait4:
|
1943 |
{ |
1944 |
int status;
|
1945 |
target_long *status_ptr = (void *)arg2;
|
1946 |
struct rusage rusage, *rusage_ptr;
|
1947 |
struct target_rusage *target_rusage = (void *)arg4; |
1948 |
if (target_rusage)
|
1949 |
rusage_ptr = &rusage; |
1950 |
else
|
1951 |
rusage_ptr = NULL;
|
1952 |
ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr)); |
1953 |
if (!is_error(ret)) {
|
1954 |
if (status_ptr)
|
1955 |
*status_ptr = tswap32(status); |
1956 |
if (target_rusage) {
|
1957 |
target_rusage->ru_utime.tv_sec = tswapl(rusage.ru_utime.tv_sec); |
1958 |
target_rusage->ru_utime.tv_usec = tswapl(rusage.ru_utime.tv_usec); |
1959 |
target_rusage->ru_stime.tv_sec = tswapl(rusage.ru_stime.tv_sec); |
1960 |
target_rusage->ru_stime.tv_usec = tswapl(rusage.ru_stime.tv_usec); |
1961 |
target_rusage->ru_maxrss = tswapl(rusage.ru_maxrss); |
1962 |
target_rusage->ru_ixrss = tswapl(rusage.ru_ixrss); |
1963 |
target_rusage->ru_idrss = tswapl(rusage.ru_idrss); |
1964 |
target_rusage->ru_isrss = tswapl(rusage.ru_isrss); |
1965 |
target_rusage->ru_minflt = tswapl(rusage.ru_minflt); |
1966 |
target_rusage->ru_majflt = tswapl(rusage.ru_majflt); |
1967 |
target_rusage->ru_nswap = tswapl(rusage.ru_nswap); |
1968 |
target_rusage->ru_inblock = tswapl(rusage.ru_inblock); |
1969 |
target_rusage->ru_oublock = tswapl(rusage.ru_oublock); |
1970 |
target_rusage->ru_msgsnd = tswapl(rusage.ru_msgsnd); |
1971 |
target_rusage->ru_msgrcv = tswapl(rusage.ru_msgrcv); |
1972 |
target_rusage->ru_nsignals = tswapl(rusage.ru_nsignals); |
1973 |
target_rusage->ru_nvcsw = tswapl(rusage.ru_nvcsw); |
1974 |
target_rusage->ru_nivcsw = tswapl(rusage.ru_nivcsw); |
1975 |
} |
1976 |
} |
1977 |
} |
1978 |
break;
|
1979 |
case TARGET_NR_swapoff:
|
1980 |
ret = get_errno(swapoff((const char *)arg1)); |
1981 |
break;
|
1982 |
case TARGET_NR_sysinfo:
|
1983 |
goto unimplemented;
|
1984 |
case TARGET_NR_ipc:
|
1985 |
goto unimplemented;
|
1986 |
case TARGET_NR_fsync:
|
1987 |
ret = get_errno(fsync(arg1)); |
1988 |
break;
|
1989 |
case TARGET_NR_clone:
|
1990 |
ret = get_errno(do_fork(cpu_env, arg1, arg2)); |
1991 |
break;
|
1992 |
#ifdef __NR_exit_group
|
1993 |
/* new thread calls */
|
1994 |
case TARGET_NR_exit_group:
|
1995 |
ret = get_errno(exit_group(arg1)); |
1996 |
break;
|
1997 |
#endif
|
1998 |
case TARGET_NR_setdomainname:
|
1999 |
ret = get_errno(setdomainname((const char *)arg1, arg2)); |
2000 |
break;
|
2001 |
case TARGET_NR_uname:
|
2002 |
/* no need to transcode because we use the linux syscall */
|
2003 |
ret = get_errno(sys_uname((struct new_utsname *)arg1));
|
2004 |
break;
|
2005 |
#ifdef TARGET_I386
|
2006 |
case TARGET_NR_modify_ldt:
|
2007 |
ret = get_errno(do_modify_ldt(cpu_env, arg1, (void *)arg2, arg3));
|
2008 |
break;
|
2009 |
case TARGET_NR_vm86old:
|
2010 |
goto unimplemented;
|
2011 |
case TARGET_NR_vm86:
|
2012 |
ret = do_vm86(cpu_env, arg1, (void *)arg2);
|
2013 |
break;
|
2014 |
#endif
|
2015 |
case TARGET_NR_adjtimex:
|
2016 |
goto unimplemented;
|
2017 |
case TARGET_NR_create_module:
|
2018 |
case TARGET_NR_init_module:
|
2019 |
case TARGET_NR_delete_module:
|
2020 |
case TARGET_NR_get_kernel_syms:
|
2021 |
goto unimplemented;
|
2022 |
case TARGET_NR_quotactl:
|
2023 |
goto unimplemented;
|
2024 |
case TARGET_NR_getpgid:
|
2025 |
ret = get_errno(getpgid(arg1)); |
2026 |
break;
|
2027 |
case TARGET_NR_fchdir:
|
2028 |
ret = get_errno(fchdir(arg1)); |
2029 |
break;
|
2030 |
case TARGET_NR_bdflush:
|
2031 |
goto unimplemented;
|
2032 |
case TARGET_NR_sysfs:
|
2033 |
goto unimplemented;
|
2034 |
case TARGET_NR_personality:
|
2035 |
ret = get_errno(personality(arg1)); |
2036 |
break;
|
2037 |
case TARGET_NR_afs_syscall:
|
2038 |
goto unimplemented;
|
2039 |
case TARGET_NR_setfsuid:
|
2040 |
ret = get_errno(setfsuid(arg1)); |
2041 |
break;
|
2042 |
case TARGET_NR_setfsgid:
|
2043 |
ret = get_errno(setfsgid(arg1)); |
2044 |
break;
|
2045 |
case TARGET_NR__llseek:
|
2046 |
{ |
2047 |
int64_t res; |
2048 |
ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5)); |
2049 |
*(int64_t *)arg4 = tswap64(res); |
2050 |
} |
2051 |
break;
|
2052 |
case TARGET_NR_getdents:
|
2053 |
#if TARGET_LONG_SIZE != 4 |
2054 |
#error not supported
|
2055 |
#endif
|
2056 |
{ |
2057 |
struct dirent *dirp = (void *)arg2; |
2058 |
long count = arg3;
|
2059 |
|
2060 |
ret = get_errno(sys_getdents(arg1, dirp, count)); |
2061 |
if (!is_error(ret)) {
|
2062 |
struct dirent *de;
|
2063 |
int len = ret;
|
2064 |
int reclen;
|
2065 |
de = dirp; |
2066 |
while (len > 0) { |
2067 |
reclen = de->d_reclen; |
2068 |
if (reclen > len)
|
2069 |
break;
|
2070 |
de->d_reclen = tswap16(reclen); |
2071 |
tswapls(&de->d_ino); |
2072 |
tswapls(&de->d_off); |
2073 |
de = (struct dirent *)((char *)de + reclen); |
2074 |
len -= reclen; |
2075 |
} |
2076 |
} |
2077 |
} |
2078 |
break;
|
2079 |
case TARGET_NR_getdents64:
|
2080 |
{ |
2081 |
struct dirent64 *dirp = (void *)arg2; |
2082 |
long count = arg3;
|
2083 |
ret = get_errno(sys_getdents64(arg1, dirp, count)); |
2084 |
if (!is_error(ret)) {
|
2085 |
struct dirent64 *de;
|
2086 |
int len = ret;
|
2087 |
int reclen;
|
2088 |
de = dirp; |
2089 |
while (len > 0) { |
2090 |
reclen = de->d_reclen; |
2091 |
if (reclen > len)
|
2092 |
break;
|
2093 |
de->d_reclen = tswap16(reclen); |
2094 |
tswap64s(&de->d_ino); |
2095 |
tswap64s(&de->d_off); |
2096 |
de = (struct dirent64 *)((char *)de + reclen); |
2097 |
len -= reclen; |
2098 |
} |
2099 |
} |
2100 |
} |
2101 |
break;
|
2102 |
case TARGET_NR__newselect:
|
2103 |
ret = do_select(arg1, (void *)arg2, (void *)arg3, (void *)arg4, |
2104 |
(void *)arg5);
|
2105 |
break;
|
2106 |
case TARGET_NR_poll:
|
2107 |
{ |
2108 |
struct target_pollfd *target_pfd = (void *)arg1; |
2109 |
unsigned int nfds = arg2; |
2110 |
int timeout = arg3;
|
2111 |
struct pollfd *pfd;
|
2112 |
unsigned int i; |
2113 |
|
2114 |
pfd = alloca(sizeof(struct pollfd) * nfds); |
2115 |
for(i = 0; i < nfds; i++) { |
2116 |
pfd[i].fd = tswap32(target_pfd[i].fd); |
2117 |
pfd[i].events = tswap16(target_pfd[i].events); |
2118 |
} |
2119 |
ret = get_errno(poll(pfd, nfds, timeout)); |
2120 |
if (!is_error(ret)) {
|
2121 |
for(i = 0; i < nfds; i++) { |
2122 |
target_pfd[i].revents = tswap16(pfd[i].revents); |
2123 |
} |
2124 |
} |
2125 |
} |
2126 |
break;
|
2127 |
case TARGET_NR_flock:
|
2128 |
/* NOTE: the flock constant seems to be the same for every
|
2129 |
Linux platform */
|
2130 |
ret = get_errno(flock(arg1, arg2)); |
2131 |
break;
|
2132 |
case TARGET_NR_readv:
|
2133 |
{ |
2134 |
int count = arg3;
|
2135 |
int i;
|
2136 |
struct iovec *vec;
|
2137 |
struct target_iovec *target_vec = (void *)arg2; |
2138 |
|
2139 |
vec = alloca(count * sizeof(struct iovec)); |
2140 |
for(i = 0;i < count; i++) { |
2141 |
vec[i].iov_base = (void *)tswapl(target_vec[i].iov_base);
|
2142 |
vec[i].iov_len = tswapl(target_vec[i].iov_len); |
2143 |
} |
2144 |
ret = get_errno(readv(arg1, vec, count)); |
2145 |
} |
2146 |
break;
|
2147 |
case TARGET_NR_writev:
|
2148 |
{ |
2149 |
int count = arg3;
|
2150 |
int i;
|
2151 |
struct iovec *vec;
|
2152 |
struct target_iovec *target_vec = (void *)arg2; |
2153 |
|
2154 |
vec = alloca(count * sizeof(struct iovec)); |
2155 |
for(i = 0;i < count; i++) { |
2156 |
vec[i].iov_base = (void *)tswapl(target_vec[i].iov_base);
|
2157 |
vec[i].iov_len = tswapl(target_vec[i].iov_len); |
2158 |
} |
2159 |
ret = get_errno(writev(arg1, vec, count)); |
2160 |
} |
2161 |
break;
|
2162 |
case TARGET_NR_getsid:
|
2163 |
ret = get_errno(getsid(arg1)); |
2164 |
break;
|
2165 |
case TARGET_NR_fdatasync:
|
2166 |
ret = get_errno(fdatasync(arg1)); |
2167 |
break;
|
2168 |
case TARGET_NR__sysctl:
|
2169 |
goto unimplemented;
|
2170 |
case TARGET_NR_sched_setparam:
|
2171 |
{ |
2172 |
struct sched_param *target_schp = (void *)arg2; |
2173 |
struct sched_param schp;
|
2174 |
schp.sched_priority = tswap32(target_schp->sched_priority); |
2175 |
ret = get_errno(sched_setparam(arg1, &schp)); |
2176 |
} |
2177 |
break;
|
2178 |
case TARGET_NR_sched_getparam:
|
2179 |
{ |
2180 |
struct sched_param *target_schp = (void *)arg2; |
2181 |
struct sched_param schp;
|
2182 |
ret = get_errno(sched_getparam(arg1, &schp)); |
2183 |
if (!is_error(ret)) {
|
2184 |
target_schp->sched_priority = tswap32(schp.sched_priority); |
2185 |
} |
2186 |
} |
2187 |
break;
|
2188 |
case TARGET_NR_sched_setscheduler:
|
2189 |
{ |
2190 |
struct sched_param *target_schp = (void *)arg3; |
2191 |
struct sched_param schp;
|
2192 |
schp.sched_priority = tswap32(target_schp->sched_priority); |
2193 |
ret = get_errno(sched_setscheduler(arg1, arg2, &schp)); |
2194 |
} |
2195 |
break;
|
2196 |
case TARGET_NR_sched_getscheduler:
|
2197 |
ret = get_errno(sched_getscheduler(arg1)); |
2198 |
break;
|
2199 |
case TARGET_NR_sched_yield:
|
2200 |
ret = get_errno(sched_yield()); |
2201 |
break;
|
2202 |
case TARGET_NR_sched_get_priority_max:
|
2203 |
ret = get_errno(sched_get_priority_max(arg1)); |
2204 |
break;
|
2205 |
case TARGET_NR_sched_get_priority_min:
|
2206 |
ret = get_errno(sched_get_priority_min(arg1)); |
2207 |
break;
|
2208 |
case TARGET_NR_sched_rr_get_interval:
|
2209 |
{ |
2210 |
struct target_timespec *target_ts = (void *)arg2; |
2211 |
struct timespec ts;
|
2212 |
ret = get_errno(sched_rr_get_interval(arg1, &ts)); |
2213 |
if (!is_error(ret)) {
|
2214 |
target_ts->tv_sec = tswapl(ts.tv_sec); |
2215 |
target_ts->tv_nsec = tswapl(ts.tv_nsec); |
2216 |
} |
2217 |
} |
2218 |
break;
|
2219 |
case TARGET_NR_nanosleep:
|
2220 |
{ |
2221 |
struct target_timespec *target_req = (void *)arg1; |
2222 |
struct target_timespec *target_rem = (void *)arg2; |
2223 |
struct timespec req, rem;
|
2224 |
req.tv_sec = tswapl(target_req->tv_sec); |
2225 |
req.tv_nsec = tswapl(target_req->tv_nsec); |
2226 |
ret = get_errno(nanosleep(&req, &rem)); |
2227 |
if (target_rem) {
|
2228 |
target_rem->tv_sec = tswapl(rem.tv_sec); |
2229 |
target_rem->tv_nsec = tswapl(rem.tv_nsec); |
2230 |
} |
2231 |
} |
2232 |
break;
|
2233 |
case TARGET_NR_setresuid:
|
2234 |
ret = get_errno(setresuid(low2highuid(arg1), |
2235 |
low2highuid(arg2), |
2236 |
low2highuid(arg3))); |
2237 |
break;
|
2238 |
case TARGET_NR_getresuid:
|
2239 |
{ |
2240 |
int ruid, euid, suid;
|
2241 |
ret = get_errno(getresuid(&ruid, &euid, &suid)); |
2242 |
if (!is_error(ret)) {
|
2243 |
*(uint16_t *)arg1 = tswap16(high2lowuid(ruid)); |
2244 |
*(uint16_t *)arg2 = tswap16(high2lowuid(euid)); |
2245 |
*(uint16_t *)arg3 = tswap16(high2lowuid(suid)); |
2246 |
} |
2247 |
} |
2248 |
break;
|
2249 |
case TARGET_NR_setresgid:
|
2250 |
ret = get_errno(setresgid(low2highgid(arg1), |
2251 |
low2highgid(arg2), |
2252 |
low2highgid(arg3))); |
2253 |
break;
|
2254 |
case TARGET_NR_getresgid:
|
2255 |
{ |
2256 |
int rgid, egid, sgid;
|
2257 |
ret = get_errno(getresgid(&rgid, &egid, &sgid)); |
2258 |
if (!is_error(ret)) {
|
2259 |
*(uint16_t *)arg1 = high2lowgid(tswap16(rgid)); |
2260 |
*(uint16_t *)arg2 = high2lowgid(tswap16(egid)); |
2261 |
*(uint16_t *)arg3 = high2lowgid(tswap16(sgid)); |
2262 |
} |
2263 |
} |
2264 |
break;
|
2265 |
case TARGET_NR_query_module:
|
2266 |
goto unimplemented;
|
2267 |
case TARGET_NR_nfsservctl:
|
2268 |
goto unimplemented;
|
2269 |
case TARGET_NR_prctl:
|
2270 |
goto unimplemented;
|
2271 |
case TARGET_NR_pread:
|
2272 |
goto unimplemented;
|
2273 |
case TARGET_NR_pwrite:
|
2274 |
goto unimplemented;
|
2275 |
case TARGET_NR_chown:
|
2276 |
ret = get_errno(chown((const char *)arg1, arg2, arg3)); |
2277 |
break;
|
2278 |
case TARGET_NR_getcwd:
|
2279 |
ret = get_errno(sys_getcwd1((char *)arg1, arg2));
|
2280 |
break;
|
2281 |
case TARGET_NR_capget:
|
2282 |
goto unimplemented;
|
2283 |
case TARGET_NR_capset:
|
2284 |
goto unimplemented;
|
2285 |
case TARGET_NR_sigaltstack:
|
2286 |
goto unimplemented;
|
2287 |
case TARGET_NR_sendfile:
|
2288 |
goto unimplemented;
|
2289 |
case TARGET_NR_getpmsg:
|
2290 |
goto unimplemented;
|
2291 |
case TARGET_NR_putpmsg:
|
2292 |
goto unimplemented;
|
2293 |
case TARGET_NR_vfork:
|
2294 |
ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD, 0));
|
2295 |
break;
|
2296 |
case TARGET_NR_ugetrlimit:
|
2297 |
{ |
2298 |
struct rlimit rlim;
|
2299 |
ret = get_errno(getrlimit(arg1, &rlim)); |
2300 |
if (!is_error(ret)) {
|
2301 |
struct target_rlimit *target_rlim = (void *)arg2; |
2302 |
target_rlim->rlim_cur = tswapl(rlim.rlim_cur); |
2303 |
target_rlim->rlim_max = tswapl(rlim.rlim_max); |
2304 |
} |
2305 |
break;
|
2306 |
} |
2307 |
case TARGET_NR_truncate64:
|
2308 |
goto unimplemented;
|
2309 |
case TARGET_NR_ftruncate64:
|
2310 |
goto unimplemented;
|
2311 |
case TARGET_NR_stat64:
|
2312 |
ret = get_errno(stat(path((const char *)arg1), &st)); |
2313 |
goto do_stat64;
|
2314 |
case TARGET_NR_lstat64:
|
2315 |
ret = get_errno(lstat(path((const char *)arg1), &st)); |
2316 |
goto do_stat64;
|
2317 |
case TARGET_NR_fstat64:
|
2318 |
{ |
2319 |
ret = get_errno(fstat(arg1, &st)); |
2320 |
do_stat64:
|
2321 |
if (!is_error(ret)) {
|
2322 |
struct target_stat64 *target_st = (void *)arg2; |
2323 |
memset(target_st, 0, sizeof(struct target_stat64)); |
2324 |
target_st->st_dev = tswap16(st.st_dev); |
2325 |
target_st->st_ino = tswap64(st.st_ino); |
2326 |
#ifdef TARGET_STAT64_HAS_BROKEN_ST_INO
|
2327 |
target_st->__st_ino = tswapl(st.st_ino); |
2328 |
#endif
|
2329 |
target_st->st_mode = tswap32(st.st_mode); |
2330 |
target_st->st_nlink = tswap32(st.st_nlink); |
2331 |
target_st->st_uid = tswapl(st.st_uid); |
2332 |
target_st->st_gid = tswapl(st.st_gid); |
2333 |
target_st->st_rdev = tswap16(st.st_rdev); |
2334 |
/* XXX: better use of kernel struct */
|
2335 |
target_st->st_size = tswap64(st.st_size); |
2336 |
target_st->st_blksize = tswapl(st.st_blksize); |
2337 |
target_st->st_blocks = tswapl(st.st_blocks); |
2338 |
target_st->target_st_atime = tswapl(st.st_atime); |
2339 |
target_st->target_st_mtime = tswapl(st.st_mtime); |
2340 |
target_st->target_st_ctime = tswapl(st.st_ctime); |
2341 |
} |
2342 |
} |
2343 |
break;
|
2344 |
|
2345 |
case TARGET_NR_lchown32:
|
2346 |
ret = get_errno(lchown((const char *)arg1, arg2, arg3)); |
2347 |
break;
|
2348 |
case TARGET_NR_getuid32:
|
2349 |
ret = get_errno(getuid()); |
2350 |
break;
|
2351 |
case TARGET_NR_getgid32:
|
2352 |
ret = get_errno(getgid()); |
2353 |
break;
|
2354 |
case TARGET_NR_geteuid32:
|
2355 |
ret = get_errno(geteuid()); |
2356 |
break;
|
2357 |
case TARGET_NR_getegid32:
|
2358 |
ret = get_errno(getegid()); |
2359 |
break;
|
2360 |
case TARGET_NR_setreuid32:
|
2361 |
ret = get_errno(setreuid(arg1, arg2)); |
2362 |
break;
|
2363 |
case TARGET_NR_setregid32:
|
2364 |
ret = get_errno(setregid(arg1, arg2)); |
2365 |
break;
|
2366 |
case TARGET_NR_getgroups32:
|
2367 |
goto unimplemented;
|
2368 |
case TARGET_NR_setgroups32:
|
2369 |
goto unimplemented;
|
2370 |
case TARGET_NR_fchown32:
|
2371 |
ret = get_errno(fchown(arg1, arg2, arg3)); |
2372 |
break;
|
2373 |
case TARGET_NR_setresuid32:
|
2374 |
ret = get_errno(setresuid(arg1, arg2, arg3)); |
2375 |
break;
|
2376 |
case TARGET_NR_getresuid32:
|
2377 |
{ |
2378 |
int ruid, euid, suid;
|
2379 |
ret = get_errno(getresuid(&ruid, &euid, &suid)); |
2380 |
if (!is_error(ret)) {
|
2381 |
*(uint32_t *)arg1 = tswap32(ruid); |
2382 |
*(uint32_t *)arg2 = tswap32(euid); |
2383 |
*(uint32_t *)arg3 = tswap32(suid); |
2384 |
} |
2385 |
} |
2386 |
break;
|
2387 |
case TARGET_NR_setresgid32:
|
2388 |
ret = get_errno(setresgid(arg1, arg2, arg3)); |
2389 |
break;
|
2390 |
case TARGET_NR_getresgid32:
|
2391 |
{ |
2392 |
int rgid, egid, sgid;
|
2393 |
ret = get_errno(getresgid(&rgid, &egid, &sgid)); |
2394 |
if (!is_error(ret)) {
|
2395 |
*(uint32_t *)arg1 = tswap32(rgid); |
2396 |
*(uint32_t *)arg2 = tswap32(egid); |
2397 |
*(uint32_t *)arg3 = tswap32(sgid); |
2398 |
} |
2399 |
} |
2400 |
break;
|
2401 |
case TARGET_NR_chown32:
|
2402 |
ret = get_errno(chown((const char *)arg1, arg2, arg3)); |
2403 |
break;
|
2404 |
case TARGET_NR_setuid32:
|
2405 |
ret = get_errno(setuid(arg1)); |
2406 |
break;
|
2407 |
case TARGET_NR_setgid32:
|
2408 |
ret = get_errno(setgid(arg1)); |
2409 |
break;
|
2410 |
case TARGET_NR_setfsuid32:
|
2411 |
ret = get_errno(setfsuid(arg1)); |
2412 |
break;
|
2413 |
case TARGET_NR_setfsgid32:
|
2414 |
ret = get_errno(setfsgid(arg1)); |
2415 |
break;
|
2416 |
case TARGET_NR_pivot_root:
|
2417 |
goto unimplemented;
|
2418 |
case TARGET_NR_mincore:
|
2419 |
goto unimplemented;
|
2420 |
case TARGET_NR_madvise:
|
2421 |
goto unimplemented;
|
2422 |
#if TARGET_LONG_BITS == 32 |
2423 |
case TARGET_NR_fcntl64:
|
2424 |
{ |
2425 |
struct flock64 fl;
|
2426 |
struct target_flock64 *target_fl = (void *)arg3; |
2427 |
|
2428 |
switch(arg2) {
|
2429 |
case F_GETLK64:
|
2430 |
ret = get_errno(fcntl(arg1, arg2, &fl)); |
2431 |
if (ret == 0) { |
2432 |
target_fl->l_type = tswap16(fl.l_type); |
2433 |
target_fl->l_whence = tswap16(fl.l_whence); |
2434 |
target_fl->l_start = tswap64(fl.l_start); |
2435 |
target_fl->l_len = tswap64(fl.l_len); |
2436 |
target_fl->l_pid = tswapl(fl.l_pid); |
2437 |
} |
2438 |
break;
|
2439 |
|
2440 |
case F_SETLK64:
|
2441 |
case F_SETLKW64:
|
2442 |
fl.l_type = tswap16(target_fl->l_type); |
2443 |
fl.l_whence = tswap16(target_fl->l_whence); |
2444 |
fl.l_start = tswap64(target_fl->l_start); |
2445 |
fl.l_len = tswap64(target_fl->l_len); |
2446 |
fl.l_pid = tswapl(target_fl->l_pid); |
2447 |
ret = get_errno(fcntl(arg1, arg2, &fl)); |
2448 |
break;
|
2449 |
default:
|
2450 |
ret = get_errno(fcntl(arg1, arg2, arg3)); |
2451 |
break;
|
2452 |
} |
2453 |
break;
|
2454 |
} |
2455 |
#endif
|
2456 |
case TARGET_NR_security:
|
2457 |
goto unimplemented;
|
2458 |
case TARGET_NR_gettid:
|
2459 |
ret = get_errno(gettid()); |
2460 |
break;
|
2461 |
case TARGET_NR_readahead:
|
2462 |
goto unimplemented;
|
2463 |
case TARGET_NR_setxattr:
|
2464 |
case TARGET_NR_lsetxattr:
|
2465 |
case TARGET_NR_fsetxattr:
|
2466 |
case TARGET_NR_getxattr:
|
2467 |
case TARGET_NR_lgetxattr:
|
2468 |
case TARGET_NR_fgetxattr:
|
2469 |
case TARGET_NR_listxattr:
|
2470 |
case TARGET_NR_llistxattr:
|
2471 |
case TARGET_NR_flistxattr:
|
2472 |
case TARGET_NR_removexattr:
|
2473 |
case TARGET_NR_lremovexattr:
|
2474 |
case TARGET_NR_fremovexattr:
|
2475 |
goto unimplemented_nowarn;
|
2476 |
case TARGET_NR_set_thread_area:
|
2477 |
case TARGET_NR_get_thread_area:
|
2478 |
goto unimplemented_nowarn;
|
2479 |
default:
|
2480 |
unimplemented:
|
2481 |
gemu_log("qemu: Unsupported syscall: %d\n", num);
|
2482 |
unimplemented_nowarn:
|
2483 |
ret = -ENOSYS; |
2484 |
break;
|
2485 |
} |
2486 |
fail:
|
2487 |
return ret;
|
2488 |
} |
2489 |
|