syscall.c (76ca310a19463e9883e2e55a88ac8be1fc171eea) | syscall.c (f19e00d776b781bfb0067b9b20a592440fd2990e) |
---|---|
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 --- 1890 unchanged lines hidden (view full) --- 1899 1900 ret = target_to_host_sockaddr(addr, target_addr, addrlen); 1901 if (ret) 1902 return ret; 1903 1904 return get_errno(connect(sockfd, addr, addrlen)); 1905} 1906 | 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 --- 1890 unchanged lines hidden (view full) --- 1899 1900 ret = target_to_host_sockaddr(addr, target_addr, addrlen); 1901 if (ret) 1902 return ret; 1903 1904 return get_errno(connect(sockfd, addr, addrlen)); 1905} 1906 |
1907/* do_sendrecvmsg() Must return target values and target errnos. */ 1908static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, 1909 int flags, int send) | 1907/* do_sendrecvmsg_locked() Must return target values and target errnos. */ 1908static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, 1909 int flags, int send) |
1910{ 1911 abi_long ret, len; | 1910{ 1911 abi_long ret, len; |
1912 struct target_msghdr *msgp; | |
1913 struct msghdr msg; 1914 int count; 1915 struct iovec *vec; 1916 abi_ulong target_vec; 1917 | 1912 struct msghdr msg; 1913 int count; 1914 struct iovec *vec; 1915 abi_ulong target_vec; 1916 |
1918 /* FIXME */ 1919 if (!lock_user_struct(send ? VERIFY_READ : VERIFY_WRITE, 1920 msgp, 1921 target_msg, 1922 send ? 1 : 0)) 1923 return -TARGET_EFAULT; | |
1924 if (msgp->msg_name) { 1925 msg.msg_namelen = tswap32(msgp->msg_namelen); 1926 msg.msg_name = alloca(msg.msg_namelen); 1927 ret = target_to_host_sockaddr(msg.msg_name, tswapal(msgp->msg_name), 1928 msg.msg_namelen); 1929 if (ret) { 1930 goto out2; 1931 } --- 38 unchanged lines hidden (view full) --- 1970 ret = len; 1971 } 1972 } 1973 } 1974 1975out: 1976 unlock_iovec(vec, target_vec, count, !send); 1977out2: | 1917 if (msgp->msg_name) { 1918 msg.msg_namelen = tswap32(msgp->msg_namelen); 1919 msg.msg_name = alloca(msg.msg_namelen); 1920 ret = target_to_host_sockaddr(msg.msg_name, tswapal(msgp->msg_name), 1921 msg.msg_namelen); 1922 if (ret) { 1923 goto out2; 1924 } --- 38 unchanged lines hidden (view full) --- 1963 ret = len; 1964 } 1965 } 1966 } 1967 1968out: 1969 unlock_iovec(vec, target_vec, count, !send); 1970out2: |
1971 return ret; 1972} 1973 1974static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, 1975 int flags, int send) 1976{ 1977 abi_long ret; 1978 struct target_msghdr *msgp; 1979 1980 if (!lock_user_struct(send ? VERIFY_READ : VERIFY_WRITE, 1981 msgp, 1982 target_msg, 1983 send ? 1 : 0)) { 1984 return -TARGET_EFAULT; 1985 } 1986 ret = do_sendrecvmsg_locked(fd, msgp, flags, send); |
|
1978 unlock_user_struct(msgp, target_msg, send ? 0 : 1); 1979 return ret; 1980} 1981 | 1987 unlock_user_struct(msgp, target_msg, send ? 0 : 1); 1988 return ret; 1989} 1990 |
1991#ifdef TARGET_NR_sendmmsg 1992/* We don't rely on the C library to have sendmmsg/recvmmsg support, 1993 * so it might not have this *mmsg-specific flag either. 1994 */ 1995#ifndef MSG_WAITFORONE 1996#define MSG_WAITFORONE 0x10000 1997#endif 1998 1999static abi_long do_sendrecvmmsg(int fd, abi_ulong target_msgvec, 2000 unsigned int vlen, unsigned int flags, 2001 int send) 2002{ 2003 struct target_mmsghdr *mmsgp; 2004 abi_long ret = 0; 2005 int i; 2006 2007 if (vlen > UIO_MAXIOV) { 2008 vlen = UIO_MAXIOV; 2009 } 2010 2011 mmsgp = lock_user(VERIFY_WRITE, target_msgvec, sizeof(*mmsgp) * vlen, 1); 2012 if (!mmsgp) { 2013 return -TARGET_EFAULT; 2014 } 2015 2016 for (i = 0; i < vlen; i++) { 2017 ret = do_sendrecvmsg_locked(fd, &mmsgp[i].msg_hdr, flags, send); 2018 if (is_error(ret)) { 2019 break; 2020 } 2021 mmsgp[i].msg_len = tswap32(ret); 2022 /* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */ 2023 if (flags & MSG_WAITFORONE) { 2024 flags |= MSG_DONTWAIT; 2025 } 2026 } 2027 2028 unlock_user(mmsgp, target_msgvec, sizeof(*mmsgp) * i); 2029 2030 /* Return number of datagrams sent if we sent any at all; 2031 * otherwise return the error. 2032 */ 2033 if (i) { 2034 return i; 2035 } 2036 return ret; 2037} 2038#endif 2039 |
|
1982/* If we don't have a system accept4() then just call accept. 1983 * The callsites to do_accept4() will ensure that they don't 1984 * pass a non-zero flags argument in this config. 1985 */ 1986#ifndef CONFIG_ACCEPT4 1987static inline int accept4(int sockfd, struct sockaddr *addr, 1988 socklen_t *addrlen, int flags) 1989{ --- 4721 unchanged lines hidden (view full) --- 6711 ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0); 6712 break; 6713#endif 6714#ifdef TARGET_NR_sendmsg 6715 case TARGET_NR_sendmsg: 6716 ret = do_sendrecvmsg(arg1, arg2, arg3, 1); 6717 break; 6718#endif | 2040/* If we don't have a system accept4() then just call accept. 2041 * The callsites to do_accept4() will ensure that they don't 2042 * pass a non-zero flags argument in this config. 2043 */ 2044#ifndef CONFIG_ACCEPT4 2045static inline int accept4(int sockfd, struct sockaddr *addr, 2046 socklen_t *addrlen, int flags) 2047{ --- 4721 unchanged lines hidden (view full) --- 6769 ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0); 6770 break; 6771#endif 6772#ifdef TARGET_NR_sendmsg 6773 case TARGET_NR_sendmsg: 6774 ret = do_sendrecvmsg(arg1, arg2, arg3, 1); 6775 break; 6776#endif |
6777#ifdef TARGET_NR_sendmmsg 6778 case TARGET_NR_sendmmsg: 6779 ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); 6780 break; 6781 case TARGET_NR_recvmmsg: 6782 ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0); 6783 break; 6784#endif |
|
6719#ifdef TARGET_NR_sendto 6720 case TARGET_NR_sendto: 6721 ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); 6722 break; 6723#endif 6724#ifdef TARGET_NR_shutdown 6725 case TARGET_NR_shutdown: 6726 ret = get_errno(shutdown(arg1, arg2)); --- 2487 unchanged lines hidden --- | 6785#ifdef TARGET_NR_sendto 6786 case TARGET_NR_sendto: 6787 ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); 6788 break; 6789#endif 6790#ifdef TARGET_NR_shutdown 6791 case TARGET_NR_shutdown: 6792 ret = get_errno(shutdown(arg1, arg2)); --- 2487 unchanged lines hidden --- |