Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / emulation / ibcs2 / i386 / ibcs2_other.c
1 /*
2  * Copyright (c) 1995 Steven Wallace
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. The name of the author may not be used to endorse or promote products
11  *    derived from this software without specific prior written permission
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  * $FreeBSD: src/sys/i386/ibcs2/ibcs2_other.c,v 1.10 1999/08/28 00:43:59 peter Exp $
25  * $DragonFly: src/sys/emulation/ibcs2/i386/Attic/ibcs2_other.c,v 1.2 2003/06/17 04:28:35 dillon Exp $
26  */
27
28 /*
29  * IBCS2 compatibility module.
30  */
31
32 #include "opt_spx_hack.h"
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/sysproto.h>
37
38 #include <i386/ibcs2/ibcs2_types.h>
39 #include <i386/ibcs2/ibcs2_signal.h>
40 #include <i386/ibcs2/ibcs2_util.h>
41 #include <i386/ibcs2/ibcs2_proto.h>
42
43 #define IBCS2_SECURE_GETLUID 1
44 #define IBCS2_SECURE_SETLUID 2
45
46 int
47 ibcs2_secure(struct proc *p, struct ibcs2_secure_args *uap)
48 {
49         switch (uap->cmd) {
50
51         case IBCS2_SECURE_GETLUID:              /* get login uid */
52                 p->p_retval[0] = p->p_ucred->cr_uid;
53                 return 0;
54
55         case IBCS2_SECURE_SETLUID:              /* set login uid */
56                 return EPERM;
57
58         default:
59                 printf("IBCS2: 'secure' cmd=%d not implemented\n", uap->cmd);
60         }
61
62         return EINVAL;
63 }
64
65 int
66 ibcs2_lseek(struct proc *p, register struct ibcs2_lseek_args *uap)
67 {
68         struct lseek_args largs;
69         int error;
70
71         largs.fd = uap->fd;
72         largs.offset = uap->offset;
73         largs.whence = uap->whence;
74         error = lseek(p, &largs);
75         return (error);
76 }
77
78 #ifdef SPX_HACK
79 #include <sys/socket.h>
80 #include <sys/un.h>     
81
82 int
83 spx_open(struct proc *p, void *uap)
84 {
85         struct socket_args sock;
86         struct connect_args conn;
87         struct sockaddr_un *Xaddr;
88         int fd, error;
89         caddr_t sg = stackgap_init();
90
91         /* obtain a socket. */
92         DPRINTF(("SPX: open socket\n"));
93         sock.domain = AF_UNIX;
94         sock.type = SOCK_STREAM;
95         sock.protocol = 0;
96         error = socket(p, &sock);
97         if (error)
98                 return error;
99
100         /* connect the socket to standard X socket */
101         DPRINTF(("SPX: connect to /tmp/X11-unix/X0\n"));
102         Xaddr = stackgap_alloc(&sg, sizeof(struct sockaddr_un));
103         Xaddr->sun_family = AF_UNIX;
104         Xaddr->sun_len = sizeof(struct sockaddr_un) - sizeof(Xaddr->sun_path) +
105           strlen(Xaddr->sun_path) + 1;
106         copyout("/tmp/.X11-unix/X0", Xaddr->sun_path, 18);
107
108         conn.s = fd = p->p_retval[0];
109         conn.name = (caddr_t)Xaddr;
110         conn.namelen = sizeof(struct sockaddr_un);
111         error = connect(p, &conn);
112         if (error) {
113                 struct close_args cl;
114                 cl.fd = fd;
115                 close(p, &cl);
116                 return error;
117         }
118         p->p_retval[0] = fd;
119         return 0;
120 }
121 #endif /* SPX_HACK */