diff options
| author | Dmitry Chagin <dchagin@FreeBSD.org> | 2009-05-16 18:48:41 +0000 |
|---|---|---|
| committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2009-05-16 18:48:41 +0000 |
| commit | 3933bde22e2b21e4be54f033529b164b72aca3ea (patch) | |
| tree | 4a61d560f65b84512f56bd4994c667b74585cb37 /sys/compat/linux/linux_socket.c | |
| parent | eeb63e515f60b0e1bdff8fc25130b8f3e9489582 (diff) | |
Notes
Diffstat (limited to 'sys/compat/linux/linux_socket.c')
| -rw-r--r-- | sys/compat/linux/linux_socket.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index e99ef84f414e..86cbcd64a65a 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -593,10 +593,13 @@ linux_socket(struct thread *td, struct linux_socket_args *args) int type; int protocol; } */ bsd_args; - int retval_socket; + int retval_socket, socket_flags; bsd_args.protocol = args->protocol; - bsd_args.type = args->type; + socket_flags = args->type & ~LINUX_SOCK_TYPE_MASK; + if (socket_flags & ~(LINUX_SOCK_CLOEXEC | LINUX_SOCK_NONBLOCK)) + return (EINVAL); + bsd_args.type = args->type & LINUX_SOCK_TYPE_MASK; if (bsd_args.type < 0 || bsd_args.type > LINUX_SOCK_MAX) return (EINVAL); bsd_args.domain = linux_to_bsd_domain(args->domain); @@ -607,6 +610,23 @@ linux_socket(struct thread *td, struct linux_socket_args *args) if (retval_socket) return (retval_socket); + if (socket_flags & LINUX_SOCK_NONBLOCK) { + retval_socket = kern_fcntl(td, td->td_retval[0], + F_SETFL, O_NONBLOCK); + if (retval_socket) { + (void)kern_close(td, td->td_retval[0]); + goto out; + } + } + if (socket_flags & LINUX_SOCK_CLOEXEC) { + retval_socket = kern_fcntl(td, td->td_retval[0], + F_SETFD, FD_CLOEXEC); + if (retval_socket) { + (void)kern_close(td, td->td_retval[0]); + goto out; + } + } + if (bsd_args.type == SOCK_RAW && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0) && bsd_args.domain == PF_INET) { @@ -642,6 +662,7 @@ linux_socket(struct thread *td, struct linux_socket_args *args) } #endif +out: return (retval_socket); } |
