1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-06 13:09:50 +00:00

Add a hack to emulator to emulat spx device for local X connections.

This is truly a hack.  The idea is taken from the Linux ibcs2 emulator.

To use this feature, you must use the option,
	options		SPX_HACK
in your config.

Also, in /compat/ibcs2/dev, you must do:

lrwxr-xr-x  1 root  wheel         9 Oct 15 22:20 X0R@ -> /dev/null
lrwxr-xr-x  1 root  wheel         7 Oct 15 22:20 nfsd@ -> socksys
lrwxr-xr-x  1 root  wheel         9 Oct 15 22:20 socksys@ -> /dev/null
crw-rw-rw-  1 root  wheel   41,   1 Oct 15 22:14 spx

Do NOT use old socksys driver as that has been removed.
This hack needs /compat/ibcs2/dev/spx to be any device that does NOT
exist/configured (so the now non-existant spx major/minor works fine).
When an open() is called, the error ENXIO is checked and then the
path is checked.  If spx open detected, then a unix socket is opened
to the hardcoded path "/tmp/.X11-unix/X0".

As the Linux hacker author mentioned, the real way would be to detect
the getmsg/putmsg through /dev/X0R and /dev/spx.  Until this true
solution is implemented (if ever), I think this hack is important
enough to be put into the tree, even though I don't like it dirtying
up my clean code (which is what #ifdef SPX_HACK is for).
This commit is contained in:
Steven Wallace 1995-10-16 05:52:55 +00:00
parent 0bc3a91127
commit 473fbdbe96
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=11527
2 changed files with 54 additions and 0 deletions

View File

@ -23,6 +23,8 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*/
#include <sys/param.h>
@ -185,6 +187,12 @@ ibcs2_open(p, uap, retval)
CHECKALTEXIST(p, &sg, SCARG(uap, path));
ret = open(p, (struct open_args *)uap, retval);
#ifdef SPX_HACK
if(ret == ENXIO)
if(!strcmp(SCARG(uap, path), "/compat/ibcs2/dev/spx"))
ret = spx_open(p, uap, retval);
else
#endif /* SPX_HACK */
if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
struct filedesc *fdp = p->p_fd;
struct file *fp = fdp->fd_ofiles[*retval];

View File

@ -74,3 +74,49 @@ ibcs2_lseek(struct proc *p, register struct ibcs2_lseek_args *uap, int *retval)
*(long *)retval = lret;
return (error);
}
#ifdef SPX_HACK
#include <sys/socket.h>
#include <sys/un.h>
int
spx_open(struct proc *p, void *uap, int *retval)
{
struct socket_args sock;
struct connect_args conn;
struct sockaddr_un *Xaddr;
caddr_t name;
int fd, error;
caddr_t sg = stackgap_init();
/* obtain a socket. */
DPRINTF(("SPX: open socket\n"));
sock.domain = AF_UNIX;
sock.type = SOCK_STREAM;
sock.protocol = 0;
error = socket(p, &sock, retval);
if (error)
return error;
/* 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);
conn.s = fd = *retval;
conn.name = (caddr_t)Xaddr;
conn.namelen = sizeof(struct sockaddr_un);
error = connect(p, &conn, retval);
if (error) {
struct close_args cl;
cl.fd = fd;
close(p, &cl, retval);
return error;
}
*retval = fd;
return 0;
}
#endif /* SPX_HACK */