From 43e757a78da49e3faff211f9330f1fe5f71d0f96 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Sat, 8 Jul 2006 20:05:04 +0000 Subject: [PATCH] Use kern_connect() in spx_open() to avoid the need for the stackgap. I also used kern_close() for simplicity though close(2) wasn't requiring the use of the stackgap. --- sys/i386/ibcs2/ibcs2_other.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/sys/i386/ibcs2/ibcs2_other.c b/sys/i386/ibcs2/ibcs2_other.c index 2a8c21d96a3..9013af423ca 100644 --- a/sys/i386/ibcs2/ibcs2_other.c +++ b/sys/i386/ibcs2/ibcs2_other.c @@ -35,7 +35,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include @@ -85,10 +87,8 @@ int spx_open(struct thread *td) { struct socket_args sock; - struct connect_args conn; - struct sockaddr_un *Xaddr; + struct sockaddr_un sun; int fd, error; - caddr_t sg = stackgap_init(); /* obtain a socket. */ DPRINTF(("SPX: open socket\n")); @@ -98,23 +98,18 @@ spx_open(struct thread *td) error = socket(td, &sock); if (error) return error; + fd = td->td_retval[0]; /* connect the socket to standard X socket */ DPRINTF(("SPX: connect to /tmp/X11-unix/X0\n")); - Xaddr = stackgap_alloc(&sg, sizeof(struct sockaddr_un)); - Xaddr->sun_family = AF_UNIX; - Xaddr->sun_len = sizeof(struct sockaddr_un) - sizeof(Xaddr->sun_path) + - strlen(Xaddr->sun_path) + 1; - copyout("/tmp/.X11-unix/X0", Xaddr->sun_path, 18); + sun.sun_family = AF_UNIX; + strcpy(sun.sun_path, "/tmp/.X11-unix/X0"); + sun.sun_len = sizeof(struct sockaddr_un) - sizeof(sun.sun_path) + + strlen(sun.sun_path) + 1; - conn.s = fd = td->td_retval[0]; - conn.name = (caddr_t)Xaddr; - conn.namelen = sizeof(struct sockaddr_un); - error = connect(td, &conn); + error = kern_connect(td, fd, (struct sockaddr *)&sun); if (error) { - struct close_args cl; - cl.fd = fd; - close(td, &cl); + kern_close(td, fd); return error; } td->td_retval[0] = fd;