diff options
Diffstat (limited to 'sys/compat/linux/linux_socket.c')
-rw-r--r-- | sys/compat/linux/linux_socket.c | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index ac73dde..de74054 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -187,7 +187,7 @@ linux_to_bsd_msg_flags(int flags) /* Return 0 if IP_HDRINCL is set for the given socket. */ static int -linux_check_hdrincl(struct proc *p, int s) +linux_check_hdrincl(struct thread *td, int s) { struct getsockopt_args /* { int s; @@ -213,7 +213,7 @@ linux_check_hdrincl(struct proc *p, int s) bsd_args.name = IP_HDRINCL; bsd_args.val = val; bsd_args.avalsize = (int *)valsize; - if ((error = getsockopt(p, &bsd_args))) + if ((error = getsockopt(td, &bsd_args))) return (error); if ((error = copyin(val, &optval, sizeof(optval)))) @@ -227,7 +227,7 @@ linux_check_hdrincl(struct proc *p, int s) * tweak endian-dependent fields in the IP packet. */ static int -linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args) +linux_sendto_hdrincl(struct thread *td, struct sendto_args *bsd_args) { /* * linux_ip_copysize defines how many bytes we should copy @@ -288,7 +288,7 @@ linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args) sendmsg_args.s = bsd_args->s; sendmsg_args.msg = (caddr_t)msg; sendmsg_args.flags = bsd_args->flags; - return (sendmsg(p, &sendmsg_args)); + return (sendmsg(td, &sendmsg_args)); } struct linux_socket_args { @@ -298,7 +298,7 @@ struct linux_socket_args { }; static int -linux_socket(struct proc *p, struct linux_socket_args *args) +linux_socket(struct thread *td, struct linux_socket_args *args) { struct linux_socket_args linux_args; struct socket_args /* { @@ -318,7 +318,7 @@ linux_socket(struct proc *p, struct linux_socket_args *args) if (bsd_args.domain == -1) return (EINVAL); - retval_socket = socket(p, &bsd_args); + retval_socket = socket(td, &bsd_args); if (bsd_args.type == SOCK_RAW && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0) && bsd_args.domain == AF_INET @@ -337,15 +337,15 @@ linux_socket(struct proc *p, struct linux_socket_args *args) sg = stackgap_init(); hdrincl = (int *)stackgap_alloc(&sg, sizeof(*hdrincl)); *hdrincl = 1; - bsd_setsockopt_args.s = p->p_retval[0]; + bsd_setsockopt_args.s = td->td_retval[0]; bsd_setsockopt_args.level = IPPROTO_IP; bsd_setsockopt_args.name = IP_HDRINCL; bsd_setsockopt_args.val = (caddr_t)hdrincl; bsd_setsockopt_args.valsize = sizeof(*hdrincl); /* We ignore any error returned by setsockopt() */ - setsockopt(p, &bsd_setsockopt_args); + setsockopt(td, &bsd_setsockopt_args); /* Copy back the return value from socket() */ - p->p_retval[0] = bsd_setsockopt_args.s; + td->td_retval[0] = bsd_setsockopt_args.s; } return (retval_socket); @@ -358,7 +358,7 @@ struct linux_bind_args { }; static int -linux_bind(struct proc *p, struct linux_bind_args *args) +linux_bind(struct thread *td, struct linux_bind_args *args) { struct linux_bind_args linux_args; struct bind_args /* { @@ -374,7 +374,7 @@ linux_bind(struct proc *p, struct linux_bind_args *args) bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.name; bsd_args.namelen = linux_args.namelen; - return (bind(p, &bsd_args)); + return (bind(td, &bsd_args)); } struct linux_connect_args { @@ -382,11 +382,11 @@ struct linux_connect_args { struct sockaddr * name; int namelen; }; -int linux_connect(struct proc *, struct linux_connect_args *); +int linux_connect(struct thread *, struct linux_connect_args *); #endif /* !__alpha__*/ int -linux_connect(struct proc *p, struct linux_connect_args *args) +linux_connect(struct thread *td, struct linux_connect_args *args) { struct linux_connect_args linux_args; struct connect_args /* { @@ -408,7 +408,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args) bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.name; bsd_args.namelen = linux_args.namelen; - error = connect(p, &bsd_args); + error = connect(td, &bsd_args); if (error != EISCONN) return (error); @@ -417,7 +417,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args) * when on a non-blocking socket. Instead it returns the * error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD. */ - error = holdsock(p->p_fd, linux_args.s, &fp); + error = holdsock(td->td_proc->p_fd, linux_args.s, &fp); if (error) return (error); error = EISCONN; @@ -427,7 +427,7 @@ linux_connect(struct proc *p, struct linux_connect_args *args) error = so->so_error; so->so_emuldata = (void *)1; } - fdrop(fp, p); + fdrop(fp, td); return (error); } @@ -439,7 +439,7 @@ struct linux_listen_args { }; static int -linux_listen(struct proc *p, struct linux_listen_args *args) +linux_listen(struct thread *td, struct linux_listen_args *args) { struct linux_listen_args linux_args; struct listen_args /* { @@ -453,7 +453,7 @@ linux_listen(struct proc *p, struct linux_listen_args *args) bsd_args.s = linux_args.s; bsd_args.backlog = linux_args.backlog; - return (listen(p, &bsd_args)); + return (listen(td, &bsd_args)); } struct linux_accept_args { @@ -463,7 +463,7 @@ struct linux_accept_args { }; static int -linux_accept(struct proc *p, struct linux_accept_args *args) +linux_accept(struct thread *td, struct linux_accept_args *args) { struct linux_accept_args linux_args; struct accept_args /* { @@ -484,7 +484,7 @@ linux_accept(struct proc *p, struct linux_accept_args *args) bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.addr; bsd_args.anamelen = linux_args.namelen; - error = oaccept(p, &bsd_args); + error = oaccept(td, &bsd_args); if (error) return (error); @@ -493,11 +493,11 @@ linux_accept(struct proc *p, struct linux_accept_args *args) * accepted one, so we must clear the flags in the new descriptor. * Ignore any errors, because we already have an open fd. */ - f_args.fd = p->p_retval[0]; + f_args.fd = td->td_retval[0]; f_args.cmd = F_SETFL; f_args.arg = 0; - (void)fcntl(p, &f_args); - p->p_retval[0] = f_args.fd; + (void)fcntl(td, &f_args); + td->td_retval[0] = f_args.fd; return (0); } @@ -508,7 +508,7 @@ struct linux_getsockname_args { }; static int -linux_getsockname(struct proc *p, struct linux_getsockname_args *args) +linux_getsockname(struct thread *td, struct linux_getsockname_args *args) { struct linux_getsockname_args linux_args; struct getsockname_args /* { @@ -524,7 +524,7 @@ linux_getsockname(struct proc *p, struct linux_getsockname_args *args) bsd_args.fdes = linux_args.s; bsd_args.asa = (caddr_t) linux_args.addr; bsd_args.alen = linux_args.namelen; - return (ogetsockname(p, &bsd_args)); + return (ogetsockname(td, &bsd_args)); } struct linux_getpeername_args { @@ -534,7 +534,7 @@ struct linux_getpeername_args { }; static int -linux_getpeername(struct proc *p, struct linux_getpeername_args *args) +linux_getpeername(struct thread *td, struct linux_getpeername_args *args) { struct linux_getpeername_args linux_args; struct ogetpeername_args /* { @@ -550,7 +550,7 @@ linux_getpeername(struct proc *p, struct linux_getpeername_args *args) bsd_args.fdes = linux_args.s; bsd_args.asa = (caddr_t) linux_args.addr; bsd_args.alen = linux_args.namelen; - return (ogetpeername(p, &bsd_args)); + return (ogetpeername(td, &bsd_args)); } struct linux_socketpair_args { @@ -561,7 +561,7 @@ struct linux_socketpair_args { }; static int -linux_socketpair(struct proc *p, struct linux_socketpair_args *args) +linux_socketpair(struct thread *td, struct linux_socketpair_args *args) { struct linux_socketpair_args linux_args; struct socketpair_args /* { @@ -582,7 +582,7 @@ linux_socketpair(struct proc *p, struct linux_socketpair_args *args) bsd_args.type = linux_args.type; bsd_args.protocol = linux_args.protocol; bsd_args.rsv = linux_args.rsv; - return (socketpair(p, &bsd_args)); + return (socketpair(td, &bsd_args)); } struct linux_send_args { @@ -593,7 +593,7 @@ struct linux_send_args { }; static int -linux_send(struct proc *p, struct linux_send_args *args) +linux_send(struct thread *td, struct linux_send_args *args) { struct linux_send_args linux_args; struct osend_args /* { @@ -611,7 +611,7 @@ linux_send(struct proc *p, struct linux_send_args *args) bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; - return (osend(p, &bsd_args)); + return (osend(td, &bsd_args)); } struct linux_recv_args { @@ -622,7 +622,7 @@ struct linux_recv_args { }; static int -linux_recv(struct proc *p, struct linux_recv_args *args) +linux_recv(struct thread *td, struct linux_recv_args *args) { struct linux_recv_args linux_args; struct orecv_args /* { @@ -640,7 +640,7 @@ linux_recv(struct proc *p, struct linux_recv_args *args) bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; - return (orecv(p, &bsd_args)); + return (orecv(td, &bsd_args)); } struct linux_sendto_args { @@ -653,7 +653,7 @@ struct linux_sendto_args { }; static int -linux_sendto(struct proc *p, struct linux_sendto_args *args) +linux_sendto(struct thread *td, struct linux_sendto_args *args) { struct linux_sendto_args linux_args; struct sendto_args /* { @@ -676,11 +676,11 @@ linux_sendto(struct proc *p, struct linux_sendto_args *args) bsd_args.to = linux_args.to; bsd_args.tolen = linux_args.tolen; - if (linux_check_hdrincl(p, linux_args.s) == 0) + if (linux_check_hdrincl(td, linux_args.s) == 0) /* IP_HDRINCL set, tweak the packet before sending */ - return (linux_sendto_hdrincl(p, &bsd_args)); + return (linux_sendto_hdrincl(td, &bsd_args)); - return (sendto(p, &bsd_args)); + return (sendto(td, &bsd_args)); } struct linux_recvfrom_args { @@ -693,7 +693,7 @@ struct linux_recvfrom_args { }; static int -linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args) +linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args) { struct linux_recvfrom_args linux_args; struct recvfrom_args /* { @@ -715,7 +715,7 @@ linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args) bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); bsd_args.from = linux_args.from; bsd_args.fromlenaddr = linux_args.fromlen; - return (orecvfrom(p, &bsd_args)); + return (orecvfrom(td, &bsd_args)); } struct linux_recvmsg_args { @@ -725,7 +725,7 @@ struct linux_recvmsg_args { }; static int -linux_recvmsg(struct proc *p, struct linux_recvmsg_args *args) +linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args) { struct linux_recvmsg_args linux_args; struct recvmsg_args /* { @@ -741,7 +741,7 @@ linux_recvmsg(struct proc *p, struct linux_recvmsg_args *args) bsd_args.s = linux_args.s; bsd_args.msg = linux_args.msg; bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); - return (recvmsg(p, &bsd_args)); + return (recvmsg(td, &bsd_args)); } struct linux_shutdown_args { @@ -750,7 +750,7 @@ struct linux_shutdown_args { }; static int -linux_shutdown(struct proc *p, struct linux_shutdown_args *args) +linux_shutdown(struct thread *td, struct linux_shutdown_args *args) { struct linux_shutdown_args linux_args; struct shutdown_args /* { @@ -764,7 +764,7 @@ linux_shutdown(struct proc *p, struct linux_shutdown_args *args) bsd_args.s = linux_args.s; bsd_args.how = linux_args.how; - return (shutdown(p, &bsd_args)); + return (shutdown(td, &bsd_args)); } struct linux_setsockopt_args { @@ -776,7 +776,7 @@ struct linux_setsockopt_args { }; static int -linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args) +linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args) { struct linux_setsockopt_args linux_args; struct setsockopt_args /* { @@ -814,7 +814,7 @@ linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args) bsd_args.name = name; bsd_args.val = linux_args.optval; bsd_args.valsize = linux_args.optlen; - return (setsockopt(p, &bsd_args)); + return (setsockopt(td, &bsd_args)); } struct linux_getsockopt_args { @@ -826,7 +826,7 @@ struct linux_getsockopt_args { }; static int -linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args) +linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args) { struct linux_getsockopt_args linux_args; struct getsockopt_args /* { @@ -864,45 +864,45 @@ linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args) bsd_args.name = name; bsd_args.val = linux_args.optval; bsd_args.avalsize = linux_args.optlen; - return (getsockopt(p, &bsd_args)); + return (getsockopt(td, &bsd_args)); } int -linux_socketcall(struct proc *p, struct linux_socketcall_args *args) +linux_socketcall(struct thread *td, struct linux_socketcall_args *args) { void *arg = (void *)args->args; switch (args->what) { case LINUX_SOCKET: - return (linux_socket(p, arg)); + return (linux_socket(td, arg)); case LINUX_BIND: - return (linux_bind(p, arg)); + return (linux_bind(td, arg)); case LINUX_CONNECT: - return (linux_connect(p, arg)); + return (linux_connect(td, arg)); case LINUX_LISTEN: - return (linux_listen(p, arg)); + return (linux_listen(td, arg)); case LINUX_ACCEPT: - return (linux_accept(p, arg)); + return (linux_accept(td, arg)); case LINUX_GETSOCKNAME: - return (linux_getsockname(p, arg)); + return (linux_getsockname(td, arg)); case LINUX_GETPEERNAME: - return (linux_getpeername(p, arg)); + return (linux_getpeername(td, arg)); case LINUX_SOCKETPAIR: - return (linux_socketpair(p, arg)); + return (linux_socketpair(td, arg)); case LINUX_SEND: - return (linux_send(p, arg)); + return (linux_send(td, arg)); case LINUX_RECV: - return (linux_recv(p, arg)); + return (linux_recv(td, arg)); case LINUX_SENDTO: - return (linux_sendto(p, arg)); + return (linux_sendto(td, arg)); case LINUX_RECVFROM: - return (linux_recvfrom(p, arg)); + return (linux_recvfrom(td, arg)); case LINUX_SHUTDOWN: - return (linux_shutdown(p, arg)); + return (linux_shutdown(td, arg)); case LINUX_SETSOCKOPT: - return (linux_setsockopt(p, arg)); + return (linux_setsockopt(td, arg)); case LINUX_GETSOCKOPT: - return (linux_getsockopt(p, arg)); + return (linux_getsockopt(td, arg)); case LINUX_SENDMSG: do { int error; @@ -940,10 +940,10 @@ linux_socketcall(struct proc *p, struct linux_socketcall_args *args) return (error); } done: - return (sendmsg(p, arg)); + return (sendmsg(td, arg)); } while (0); case LINUX_RECVMSG: - return (linux_recvmsg(p, arg)); + return (linux_recvmsg(td, arg)); } uprintf("LINUX: 'socket' typ=%d not implemented\n", args->what); |