Revision 9de5e440 linux-user/syscall.c
b/linux-user/syscall.c | ||
---|---|---|
38 | 38 |
#include <sched.h> |
39 | 39 |
#include <sys/socket.h> |
40 | 40 |
#include <sys/uio.h> |
41 |
#include <sys/poll.h> |
|
41 | 42 |
//#include <sys/user.h> |
42 | 43 |
|
43 | 44 |
#define termios host_termios |
... | ... | |
68 | 69 |
#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2]) |
69 | 70 |
#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2]) |
70 | 71 |
|
71 |
#include "syscall_defs.h" |
|
72 |
|
|
73 |
#ifdef TARGET_I386 |
|
74 |
#include "cpu-i386.h" |
|
75 |
#include "syscall-i386.h" |
|
76 |
#endif |
|
77 |
|
|
78 |
void host_to_target_siginfo(target_siginfo_t *tinfo, siginfo_t *info); |
|
79 |
void target_to_host_siginfo(siginfo_t *info, target_siginfo_t *tinfo); |
|
72 |
void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info); |
|
73 |
void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo); |
|
80 | 74 |
long do_sigreturn(CPUX86State *env); |
81 | 75 |
long do_rt_sigreturn(CPUX86State *env); |
82 | 76 |
|
... | ... | |
106 | 100 |
_syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo) |
107 | 101 |
|
108 | 102 |
extern int personality(int); |
103 |
extern int flock(int, int); |
|
104 |
extern int setfsuid(int); |
|
105 |
extern int setfsgid(int); |
|
109 | 106 |
|
110 | 107 |
static inline long get_errno(long ret) |
111 | 108 |
{ |
... | ... | |
437 | 434 |
ie++; |
438 | 435 |
} |
439 | 436 |
arg_type = ie->arg_type; |
440 |
#ifdef DEBUG
|
|
437 |
#if defined(DEBUG)
|
|
441 | 438 |
gemu_log("ioctl: cmd=0x%04lx (%s)\n", cmd, ie->name); |
442 | 439 |
#endif |
443 | 440 |
switch(arg_type[0]) { |
... | ... | |
1244 | 1241 |
ret = get_errno(sethostname((const char *)arg1, arg2)); |
1245 | 1242 |
break; |
1246 | 1243 |
case TARGET_NR_setrlimit: |
1247 |
goto unimplemented; |
|
1244 |
{ |
|
1245 |
/* XXX: convert resource ? */ |
|
1246 |
int resource = arg1; |
|
1247 |
struct target_rlimit *target_rlim = (void *)arg2; |
|
1248 |
struct rlimit rlim; |
|
1249 |
rlim.rlim_cur = tswapl(target_rlim->rlim_cur); |
|
1250 |
rlim.rlim_max = tswapl(target_rlim->rlim_max); |
|
1251 |
ret = get_errno(setrlimit(resource, &rlim)); |
|
1252 |
} |
|
1253 |
break; |
|
1248 | 1254 |
case TARGET_NR_getrlimit: |
1249 |
goto unimplemented; |
|
1255 |
{ |
|
1256 |
/* XXX: convert resource ? */ |
|
1257 |
int resource = arg1; |
|
1258 |
struct target_rlimit *target_rlim = (void *)arg2; |
|
1259 |
struct rlimit rlim; |
|
1260 |
|
|
1261 |
ret = get_errno(getrlimit(resource, &rlim)); |
|
1262 |
if (!is_error(ret)) { |
|
1263 |
target_rlim->rlim_cur = tswapl(rlim.rlim_cur); |
|
1264 |
target_rlim->rlim_max = tswapl(rlim.rlim_max); |
|
1265 |
} |
|
1266 |
} |
|
1267 |
break; |
|
1250 | 1268 |
case TARGET_NR_getrusage: |
1251 | 1269 |
goto unimplemented; |
1252 | 1270 |
case TARGET_NR_gettimeofday: |
... | ... | |
1317 | 1335 |
case TARGET_NR_munmap: |
1318 | 1336 |
ret = get_errno(munmap((void *)arg1, arg2)); |
1319 | 1337 |
break; |
1338 |
case TARGET_NR_mprotect: |
|
1339 |
ret = get_errno(mprotect((void *)arg1, arg2, arg3)); |
|
1340 |
break; |
|
1341 |
case TARGET_NR_mremap: |
|
1342 |
ret = get_errno((long)mremap((void *)arg1, arg2, arg3, arg4)); |
|
1343 |
break; |
|
1344 |
case TARGET_NR_msync: |
|
1345 |
ret = get_errno(msync((void *)arg1, arg2, arg3)); |
|
1346 |
break; |
|
1347 |
case TARGET_NR_mlock: |
|
1348 |
ret = get_errno(mlock((void *)arg1, arg2)); |
|
1349 |
break; |
|
1350 |
case TARGET_NR_munlock: |
|
1351 |
ret = get_errno(munlock((void *)arg1, arg2)); |
|
1352 |
break; |
|
1353 |
case TARGET_NR_mlockall: |
|
1354 |
ret = get_errno(mlockall(arg1)); |
|
1355 |
break; |
|
1356 |
case TARGET_NR_munlockall: |
|
1357 |
ret = get_errno(munlockall()); |
|
1358 |
break; |
|
1320 | 1359 |
case TARGET_NR_truncate: |
1321 | 1360 |
ret = get_errno(truncate((const char *)arg1, arg2)); |
1322 | 1361 |
break; |
... | ... | |
1506 | 1545 |
#endif |
1507 | 1546 |
case TARGET_NR_adjtimex: |
1508 | 1547 |
goto unimplemented; |
1509 |
case TARGET_NR_mprotect: |
|
1510 |
ret = get_errno(mprotect((void *)arg1, arg2, arg3)); |
|
1511 |
break; |
|
1512 | 1548 |
case TARGET_NR_create_module: |
1513 | 1549 |
case TARGET_NR_init_module: |
1514 | 1550 |
case TARGET_NR_delete_module: |
... | ... | |
1532 | 1568 |
case TARGET_NR_afs_syscall: |
1533 | 1569 |
goto unimplemented; |
1534 | 1570 |
case TARGET_NR_setfsuid: |
1535 |
goto unimplemented; |
|
1571 |
ret = get_errno(setfsuid(arg1)); |
|
1572 |
break; |
|
1536 | 1573 |
case TARGET_NR_setfsgid: |
1537 |
goto unimplemented; |
|
1574 |
ret = get_errno(setfsgid(arg1)); |
|
1575 |
break; |
|
1538 | 1576 |
case TARGET_NR__llseek: |
1539 | 1577 |
{ |
1540 | 1578 |
int64_t res; |
... | ... | |
1596 | 1634 |
ret = do_select(arg1, (void *)arg2, (void *)arg3, (void *)arg4, |
1597 | 1635 |
(void *)arg5); |
1598 | 1636 |
break; |
1637 |
case TARGET_NR_poll: |
|
1638 |
{ |
|
1639 |
struct target_pollfd *target_pfd = (void *)arg1; |
|
1640 |
unsigned int nfds = arg2; |
|
1641 |
int timeout = arg3; |
|
1642 |
struct pollfd *pfd; |
|
1643 |
int i; |
|
1644 |
|
|
1645 |
pfd = alloca(sizeof(struct pollfd) * nfds); |
|
1646 |
for(i = 0; i < nfds; i++) { |
|
1647 |
pfd->fd = tswap32(target_pfd->fd); |
|
1648 |
pfd->events = tswap16(target_pfd->events); |
|
1649 |
} |
|
1650 |
ret = get_errno(poll(pfd, nfds, timeout)); |
|
1651 |
if (!is_error(ret)) { |
|
1652 |
for(i = 0; i < nfds; i++) { |
|
1653 |
target_pfd->revents = tswap16(pfd->revents); |
|
1654 |
} |
|
1655 |
} |
|
1656 |
} |
|
1657 |
break; |
|
1599 | 1658 |
case TARGET_NR_flock: |
1600 |
goto unimplemented;
|
|
1601 |
case TARGET_NR_msync:
|
|
1602 |
ret = get_errno(msync((void *)arg1, arg2, arg3));
|
|
1659 |
/* NOTE: the flock constant seems to be the same for every
|
|
1660 |
Linux platform */
|
|
1661 |
ret = get_errno(flock(arg1, arg2));
|
|
1603 | 1662 |
break; |
1604 | 1663 |
case TARGET_NR_readv: |
1605 | 1664 |
{ |
... | ... | |
1638 | 1697 |
goto unimplemented; |
1639 | 1698 |
case TARGET_NR__sysctl: |
1640 | 1699 |
goto unimplemented; |
1641 |
case TARGET_NR_mlock: |
|
1642 |
ret = get_errno(mlock((void *)arg1, arg2)); |
|
1643 |
break; |
|
1644 |
case TARGET_NR_munlock: |
|
1645 |
ret = get_errno(munlock((void *)arg1, arg2)); |
|
1646 |
break; |
|
1647 |
case TARGET_NR_mlockall: |
|
1648 |
ret = get_errno(mlockall(arg1)); |
|
1649 |
break; |
|
1650 |
case TARGET_NR_munlockall: |
|
1651 |
ret = get_errno(munlockall()); |
|
1652 |
break; |
|
1653 | 1700 |
case TARGET_NR_sched_setparam: |
1654 | 1701 |
goto unimplemented; |
1655 | 1702 |
case TARGET_NR_sched_getparam: |
... | ... | |
1681 | 1728 |
} |
1682 | 1729 |
break; |
1683 | 1730 |
|
1684 |
case TARGET_NR_mremap: |
|
1685 | 1731 |
case TARGET_NR_setresuid: |
1686 | 1732 |
case TARGET_NR_getresuid: |
1687 | 1733 |
case TARGET_NR_vm86: |
1688 | 1734 |
case TARGET_NR_query_module: |
1689 |
case TARGET_NR_poll: |
|
1690 | 1735 |
case TARGET_NR_nfsservctl: |
1691 | 1736 |
case TARGET_NR_setresgid: |
1692 | 1737 |
case TARGET_NR_getresgid: |
... | ... | |
1800 | 1845 |
goto unimplemented; |
1801 | 1846 |
default: |
1802 | 1847 |
unimplemented: |
1803 |
gemu_log("Unsupported syscall: %d\n", num); |
|
1848 |
gemu_log("gemu: Unsupported syscall: %d\n", num);
|
|
1804 | 1849 |
ret = -ENOSYS; |
1805 | 1850 |
break; |
1806 | 1851 |
} |
Also available in: Unified diff