summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-08-01 00:50:57 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-08-01 00:50:57 +0000
commita82c8140c72f0f55d9967dc458496992fce2292f (patch)
tree387a5aa34c61ef778d9a1b49b596ea6b459cb2b3
parent6edefdb68777d682eb395900b8905a95bd3cac7d (diff)
Merge of NetBSD 0722
-rw-r--r--sys/compat/svr4/svr4_ioctl.c12
-rw-r--r--sys/compat/svr4/svr4_ioctl.h4
-rw-r--r--sys/compat/svr4/svr4_misc.c11
-rw-r--r--sys/compat/svr4/svr4_net.c37
-rw-r--r--sys/compat/svr4/svr4_stream.c85
-rw-r--r--sys/compat/svr4/svr4_stropts.h4
-rw-r--r--sys/compat/svr4/svr4_termios.c150
-rw-r--r--sys/compat/svr4/svr4_termios.h37
-rw-r--r--sys/compat/svr4/svr4_ttold.c100
9 files changed, 303 insertions, 137 deletions
diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c
index 2a8eb1c0033..510c5179d24 100644
--- a/sys/compat/svr4/svr4_ioctl.c
+++ b/sys/compat/svr4/svr4_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_ioctl.c,v 1.5 1996/04/21 22:18:20 deraadt Exp $ */
+/* $OpenBSD: svr4_ioctl.c,v 1.6 1996/08/01 00:50:52 niklas Exp $ */
/* $NetBSD: svr4_ioctl.c,v 1.16 1996/04/11 12:54:41 christos Exp $ */
/*
@@ -103,8 +103,8 @@ svr4_sys_ioctl(p, v, retval)
svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz);
- printf("svr4_ioctl(%d, _IO%s(%c, %d, %d), %p);\n", SCARG(uap, fd),
- dir, c, num, argsiz, SCARG(uap, data));
+ uprintf("svr4_ioctl(%d, _IO%s(%c, %d, %d), %p);\n", SCARG(uap, fd),
+ dir, c, num, argsiz, SCARG(uap, data));
#endif
fdp = p->p_fd;
cmd = SCARG(uap, com);
@@ -117,7 +117,7 @@ svr4_sys_ioctl(p, v, retval)
return EBADF;
switch (cmd & 0xff00) {
- case SVR4_tIOC:
+ case SVR4_tIOC:
fun = svr4_ttold_ioctl;
break;
@@ -137,6 +137,10 @@ svr4_sys_ioctl(p, v, retval)
fun = svr4_sock_ioctl;
break;
+ case SVR4_XIOC:
+ /* We do not support those */
+ return EINVAL;
+
default:
DPRINTF(("Unimplemented ioctl %lx\n", cmd));
return 0; /* XXX: really ENOSYS */
diff --git a/sys/compat/svr4/svr4_ioctl.h b/sys/compat/svr4/svr4_ioctl.h
index 0d68512113e..54d84100102 100644
--- a/sys/compat/svr4/svr4_ioctl.h
+++ b/sys/compat/svr4/svr4_ioctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_ioctl.h,v 1.2 1996/04/21 22:18:22 deraadt Exp $ */
+/* $OpenBSD: svr4_ioctl.h,v 1.3 1996/08/01 00:50:52 niklas Exp $ */
/* $NetBSD: svr4_ioctl.h,v 1.5 1996/04/11 12:54:43 christos Exp $ */
/*
@@ -39,6 +39,8 @@
#define SVR4_IOC(inout,group,num,len) \
(inout | ((len & 0xff) << 16) | ((group) << 8) | (num))
+#define SVR4_XIOC ('X' << 8)
+
#define SVR4_IO(g,n) SVR4_IOC(SVR4_IOC_VOID, (g), (n), 0)
#define SVR4_IOR(g,n,t) SVR4_IOC(SVR4_IOC_OUT, (g), (n), sizeof(t))
#define SVR4_IOW(g,n,t) SVR4_IOC(SVR4_IOC_IN, (g), (n), sizeof(t))
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 39a7e5795fa..ed0324e7dce 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_misc.c,v 1.4 1996/04/17 05:24:18 mickey Exp $ */
+/* $OpenBSD: svr4_misc.c,v 1.5 1996/08/01 00:50:53 niklas Exp $ */
/* $NetBSD: svr4_misc.c,v 1.36 1996/03/30 22:38:02 christos Exp $ */
/*
@@ -911,8 +911,13 @@ svr4_setinfo(p, st, s)
if (p) {
i.si_pid = p->p_pid;
- i.si_stime = p->p_ru->ru_stime.tv_sec;
- i.si_utime = p->p_ru->ru_utime.tv_sec;
+ if (p->p_stat == SZOMB) {
+ i.si_stime = p->p_ru->ru_stime.tv_sec;
+ i.si_utime = p->p_ru->ru_utime.tv_sec;
+ } else {
+ i.si_stime = p->p_stats->p_ru.ru_stime.tv_sec;
+ i.si_utime = p->p_stats->p_ru.ru_utime.tv_sec;
+ }
}
if (WIFEXITED(st)) {
diff --git a/sys/compat/svr4/svr4_net.c b/sys/compat/svr4/svr4_net.c
index 0c0ec744bf7..2b88bd5a15d 100644
--- a/sys/compat/svr4/svr4_net.c
+++ b/sys/compat/svr4/svr4_net.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_net.c,v 1.6 1996/04/21 22:18:23 deraadt Exp $ */
+/* $OpenBSD: svr4_net.c,v 1.7 1996/08/01 00:50:53 niklas Exp $ */
/* $NetBSD: svr4_net.c,v 1.9 1996/04/11 12:52:41 christos Exp $ */
/*
@@ -44,6 +44,8 @@
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/protosw.h>
+#include <sys/domain.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/proc.h>
@@ -108,7 +110,6 @@ svr4_netopen(dev, flag, mode, p)
struct socket *so;
int error;
int family;
- struct svr4_strm *st;
DPRINTF(("netopen("));
@@ -179,12 +180,9 @@ svr4_netopen(dev, flag, mode, p)
fp->f_type = DTYPE_SOCKET;
fp->f_ops = &svr4_netops;
- st = malloc(sizeof(struct svr4_strm), M_NETADDR, M_WAITOK);
- /* XXX: This is unused; ask for a field and make this legal */
- st->s_family = family;
- so->so_internal = st;
- st->s_cmd = ~0;
fp->f_data = (caddr_t)so;
+ (void) svr4_stream_get(fp);
+
DPRINTF(("ok);\n"));
p->p_dupfd = fd;
@@ -201,3 +199,28 @@ svr4_soo_close(fp, p)
free(so->so_internal, M_NETADDR);
return soo_close(fp, p);
}
+
+struct svr4_strm *
+svr4_stream_get(fp)
+ struct file *fp;
+{
+ struct socket *so;
+ struct svr4_strm *st;
+
+ if (fp == NULL || fp->f_type != DTYPE_SOCKET)
+ return NULL;
+
+ so = (struct socket *) fp->f_data;
+
+ if (so->so_internal)
+ return so->so_internal;
+
+ /* Allocate a new one. */
+ fp->f_ops = &svr4_netops;
+ st = malloc(sizeof(struct svr4_strm), M_NETADDR, M_WAITOK);
+ st->s_family = so->so_proto->pr_domain->dom_family;
+ st->s_cmd = ~0;
+ so->so_internal = st;
+
+ return st;
+}
diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c
index f7ccee8a9e1..33a15453cdf 100644
--- a/sys/compat/svr4/svr4_stream.c
+++ b/sys/compat/svr4/svr4_stream.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_stream.c,v 1.5 1996/05/22 11:45:00 deraadt Exp $ */
+/* $OpenBSD: svr4_stream.c,v 1.6 1996/08/01 00:50:54 niklas Exp $ */
/* $NetBSD: svr4_stream.c,v 1.14 1996/05/13 16:57:50 christos Exp $ */
/*
* Copyright (c) 1994, 1996 Christos Zoulas. All rights reserved.
@@ -71,7 +71,7 @@
/* Utils */
static int clean_pipe __P((struct proc *, const char *));
-static void getparm __P((struct socket *, struct svr4_si_sockparms *));
+static void getparm __P((struct file *, struct svr4_si_sockparms *));
/* Address Conversions */
static void sockaddr_to_netaddr_in __P((struct svr4_strmcmd *,
@@ -125,8 +125,8 @@ show_ioc(str, ioc)
int error;
int i;
- printf("%s cmd = %ld, timeout = %d, len = %d, buf = %p { ",
- str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf);
+ uprintf("%s cmd = %ld, timeout = %d, len = %d, buf = %p { ",
+ str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf);
if ((error = copyin(ioc->buf, ptr, ioc->len)) != 0) {
free((char *) ptr, M_TEMP);
@@ -134,9 +134,9 @@ show_ioc(str, ioc)
}
for (i = 0; i < ioc->len; i++)
- printf("%x ", (unsigned char) ptr[i]);
+ uprintf("%x ", (unsigned char) ptr[i]);
- printf("}\n");
+ uprintf("}\n");
free((char *) ptr, M_TEMP);
return 0;
@@ -168,12 +168,12 @@ show_strbuf(str)
}
}
- printf(", { %d, %d, %p=[ ", str->maxlen, str->len, str->buf);
+ uprintf(", { %d, %d, %p=[ ", str->maxlen, str->len, str->buf);
for (i = 0; i < len; i++)
- printf("%x ", (unsigned char) ptr[i]);
+ uprintf("%x ", (unsigned char) ptr[i]);
- printf("]}");
+ uprintf("]}");
if (ptr)
free((char *) ptr, M_TEMP);
@@ -193,14 +193,14 @@ show_msg(str, fd, ctl, dat, flags)
struct svr4_strbuf buf;
int error;
- printf("%s(%d", str, fd);
+ uprintf("%s(%d", str, fd);
if (ctl != NULL) {
if ((error = copyin(ctl, &buf, sizeof(buf))) != 0)
return;
show_strbuf(&buf);
}
else
- printf(", NULL");
+ uprintf(", NULL");
if (dat != NULL) {
if ((error = copyin(dat, &buf, sizeof(buf))) != 0)
@@ -208,9 +208,9 @@ show_msg(str, fd, ctl, dat, flags)
show_strbuf(&buf);
}
else
- printf(", NULL");
+ uprintf(", NULL");
- printf(", %x);\n", flags);
+ uprintf(", %x);\n", flags);
}
@@ -221,13 +221,13 @@ show_strmcmd(str, cmd)
{
int i;
- printf("%s cmd = %ld, len = %ld, offs = %ld { ",
- str, cmd->cmd, cmd->len, cmd->offs);
+ uprintf("%s cmd = %ld, len = %ld, offs = %ld { ",
+ str, cmd->cmd, cmd->len, cmd->offs);
for (i = 0; i < sizeof(cmd->pad) / sizeof(cmd->pad[0]); i++)
- printf("%lx ", cmd->pad[i]);
+ uprintf("%lx ", cmd->pad[i]);
- printf("}\n");
+ uprintf("}\n");
}
#endif /* DEBUG_SVR4 */
@@ -364,11 +364,16 @@ netaddr_to_sockaddr_un(saun, sc)
static void
-getparm(so, pa)
- struct socket *so;
+getparm(fp, pa)
+ struct file *fp;
struct svr4_si_sockparms *pa;
{
- struct svr4_strm *st = (struct svr4_strm *) so->so_internal;
+ struct svr4_strm *st = svr4_stream_get(fp);
+ struct socket *so = (struct socket *) fp->f_data;
+
+ if (st == NULL)
+ return;
+
pa->family = st->s_family;
switch (so->so_type) {
@@ -405,7 +410,6 @@ si_ogetudata(fp, fd, ioc, p)
int error;
struct svr4_si_oudata ud;
struct svr4_si_sockparms pa;
- struct socket *so = (struct socket *) fp->f_data;
if (ioc->len != sizeof(ud) && ioc->len != sizeof(ud) - sizeof(int)) {
DPRINTF(("SI_OGETUDATA: Wrong size %d != %d\n",
@@ -416,7 +420,7 @@ si_ogetudata(fp, fd, ioc, p)
if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
return error;
- getparm(so, &pa);
+ getparm(fp, &pa);
switch (pa.family) {
case AF_INET:
@@ -460,10 +464,9 @@ si_sockparams(fp, fd, ioc, p)
struct svr4_strioctl *ioc;
struct proc *p;
{
- struct socket *so = (struct socket *) fp->f_data;
struct svr4_si_sockparms pa;
- getparm(so, &pa);
+ getparm(fp, &pa);
return copyout(&pa, ioc->buf, sizeof(pa));
}
@@ -476,8 +479,7 @@ si_listen(fp, fd, ioc, p)
struct proc *p;
{
int error;
- struct socket *so = (struct socket *) fp->f_data;
- struct svr4_strm *st = (struct svr4_strm *) so->so_internal;
+ struct svr4_strm *st = svr4_stream_get(fp);
register_t retval;
#if 0
struct sockaddr_in sain;
@@ -489,6 +491,9 @@ si_listen(fp, fd, ioc, p)
struct svr4_strmcmd lst;
struct sys_listen_args la;
+ if (st == NULL)
+ return EINVAL;
+
if ((error = copyin(ioc->buf, &lst, ioc->len)) != 0)
return error;
@@ -581,7 +586,6 @@ si_getudata(fp, fd, ioc, p)
{
int error;
struct svr4_si_udata ud;
- struct socket *so = (struct socket *) fp->f_data;
if (sizeof(ud) != ioc->len) {
DPRINTF(("SI_GETUDATA: Wrong size %d != %d\n",
@@ -592,7 +596,7 @@ si_getudata(fp, fd, ioc, p)
if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
return error;
- getparm(so, &ud.sockparms);
+ getparm(fp, &ud.sockparms);
switch (ud.sockparms.family) {
case AF_INET:
@@ -731,8 +735,7 @@ ti_bind(fp, fd, ioc, p)
struct proc *p;
{
int error;
- struct socket *so = (struct socket *) fp->f_data;
- struct svr4_strm *st = (struct svr4_strm *) so->so_internal;
+ struct svr4_strm *st = svr4_stream_get(fp);
struct sockaddr_in sain;
struct sockaddr_un saun;
register_t retval;
@@ -742,6 +745,9 @@ ti_bind(fp, fd, ioc, p)
struct svr4_strmcmd bnd;
struct sys_bind_args ba;
+ if (st == NULL)
+ return EINVAL;
+
if ((error = copyin(ioc->buf, &bnd, ioc->len)) != 0)
return error;
@@ -860,8 +866,7 @@ svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat)
caddr_t dat;
{
struct svr4_strbuf skb, *sub = (struct svr4_strbuf *) dat;
- struct socket *so = (struct socket *) fp->f_data;
- struct svr4_strm *st = (struct svr4_strm *) so->so_internal;
+ struct svr4_strm *st = svr4_stream_get(fp);
int error;
void *skp, *sup;
struct sockaddr_in sain;
@@ -871,6 +876,9 @@ svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat)
caddr_t sg;
int *lenp;
+ if (st == NULL)
+ return EINVAL;
+
sc.offs = 0x10;
if ((error = copyin(sub, &skb, sizeof(skb))) != 0) {
@@ -1245,7 +1253,6 @@ svr4_sys_putmsg(p, v, retval)
struct sockaddr_un saun;
void *skp, *sup;
int sasize;
- struct socket *so;
struct svr4_strm *st;
int error;
caddr_t sg;
@@ -1280,15 +1287,11 @@ svr4_sys_putmsg(p, v, retval)
/*
* Only for sockets for now.
*/
- if (fp == NULL || fp->f_type != DTYPE_SOCKET) {
+ if ((st = svr4_stream_get(fp)) == NULL) {
DPRINTF(("putmsg: bad file type\n"));
return EINVAL;
}
- so = (struct socket *) fp->f_data;
- st = (struct svr4_strm *) so->so_internal;
-
-
if (ctl.len > sizeof(sc)) {
DPRINTF(("putmsg: Bad control size %d != %d\n", ctl.len,
sizeof(struct svr4_strmcmd)));
@@ -1389,7 +1392,6 @@ svr4_sys_getmsg(p, v, retval)
struct sockaddr_un saun;
void *skp, *sup;
int sasize;
- struct socket *so;
struct svr4_strm *st;
int *flen;
int fl;
@@ -1431,14 +1433,11 @@ svr4_sys_getmsg(p, v, retval)
/*
* Only for sockets for now.
*/
- if (fp == NULL || fp->f_type != DTYPE_SOCKET) {
+ if ((st = svr4_stream_get(fp)) == NULL) {
DPRINTF(("getmsg: bad file type\n"));
return EINVAL;
}
- so = (struct socket *) fp->f_data;
- st = (struct svr4_strm *) so->so_internal;
-
if (ctl.maxlen == -1 || dat.maxlen == -1) {
DPRINTF(("getmsg: Cannot handle -1 maxlen (yet)\n"));
return ENOSYS;
diff --git a/sys/compat/svr4/svr4_stropts.h b/sys/compat/svr4/svr4_stropts.h
index bd35552ab8a..2c044205d1e 100644
--- a/sys/compat/svr4/svr4_stropts.h
+++ b/sys/compat/svr4/svr4_stropts.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_stropts.h,v 1.2 1996/04/21 22:18:31 deraadt Exp $ */
+/* $OpenBSD: svr4_stropts.h,v 1.3 1996/08/01 00:50:55 niklas Exp $ */
/* $NetBSD: svr4_stropts.h,v 1.6 1996/04/11 12:50:31 christos Exp $ */
/*
@@ -130,4 +130,6 @@ struct svr4_netaddr_un {
#define SVR4_ADDROF(sc) (void *) (((char *) (sc)) + (sc)->offs)
+struct svr4_strm *svr4_stream_get __P((struct file *fp));
+
#endif /* !_SVR4_STROPTS */
diff --git a/sys/compat/svr4/svr4_termios.c b/sys/compat/svr4/svr4_termios.c
index 08c406dfd92..6e285c446c2 100644
--- a/sys/compat/svr4/svr4_termios.c
+++ b/sys/compat/svr4/svr4_termios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_termios.c,v 1.7 1996/04/23 09:20:56 niklas Exp $ */
+/* $OpenBSD: svr4_termios.c,v 1.8 1996/08/01 00:50:55 niklas Exp $ */
/* $NetBSD: svr4_termios.c,v 1.9 1996/04/11 12:53:48 christos Exp $ */
/*
@@ -62,16 +62,20 @@
# endif
#endif
-static u_long bsd_to_svr4_speed __P((u_long sp, u_long mask));
-static u_long svr4_to_bsd_speed __P((u_long sp, u_long mask));
-static void svr4_to_bsd_termios __P((const struct svr4_termios *st,
- struct termios *bt));
-static void bsd_to_svr4_termios __P((const struct termios *bt,
- struct svr4_termios *st));
-static void svr4_termio_to_termios __P((const struct svr4_termio *t,
- struct svr4_termios *ts));
-static void svr4_termios_to_termio __P((const struct svr4_termios *ts,
- struct svr4_termio *t));
+static u_long bsd_to_svr4_speed __P((u_long, u_long));
+static u_long svr4_to_bsd_speed __P((u_long, u_long));
+static void svr4_to_bsd_termios __P((const struct svr4_termios *,
+ struct termios *, int));
+static void bsd_to_svr4_termios __P((const struct termios *,
+ struct svr4_termios *));
+static void svr4_termio_to_termios __P((const struct svr4_termio *,
+ struct svr4_termios *));
+static void svr4_termios_to_termio __P((const struct svr4_termios *,
+ struct svr4_termio *));
+#ifdef DEBUG_SVR4
+static void print_svr4_termios __P((const struct svr4_termios *));
+static void print_bsd_termios __P((const struct termios *));
+#endif /* DEBUG_SVR4 */
#define undefined_char(a,b) /**/
#define undefined_flag1(f,a,b) /**/
@@ -79,31 +83,40 @@ static void svr4_termios_to_termio __P((const struct svr4_termios *ts,
#define undefined_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) /**/
#define svr4_to_bsd_char(a,b) \
- if (st->c_cc[__CONCAT(a,b)] == SVR4_POSIX_VDISABLE) \
- bt->c_cc[__CONCAT(a,b)] = _POSIX_VDISABLE; \
- else \
- bt->c_cc[__CONCAT(a,b)] = st->c_cc[__CONCAT3(SVR4_,a,b)]
+ if (new || __CONCAT3(SVR4_,a,b) < SVR4_NCC) { \
+ if (st->c_cc[__CONCAT3(SVR4_,a,b)] == SVR4_POSIX_VDISABLE) \
+ bt->c_cc[__CONCAT(a,b)] = _POSIX_VDISABLE; \
+ else \
+ bt->c_cc[__CONCAT(a,b)] = \
+ st->c_cc[__CONCAT3(SVR4_,a,b)]; \
+ }
#define svr4_to_bsd_flag1(f,a,b) \
- if (st->f & __CONCAT3(SVR4_,a,b)) \
- bt->f |= __CONCAT(a,b); \
- else \
- bt->f &= ~__CONCAT(a,b)
+ if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
+ if (st->f & __CONCAT3(SVR4_,a,b)) \
+ bt->f |= __CONCAT(a,b); \
+ else \
+ bt->f &= ~__CONCAT(a,b); \
+ }
#define svr4_to_bsd_flag2(f,a,b,c1,t1,c2,t2) \
- bt->f &= ~__CONCAT(a,b); \
- switch (st->f & __CONCAT3(SVR4_,a,b)) { \
- case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
- case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
+ if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
+ bt->f &= ~__CONCAT(a,b); \
+ switch (st->f & __CONCAT3(SVR4_,a,b)) { \
+ case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
+ case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
+ } \
}
#define svr4_to_bsd_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \
- bt->f &= ~__CONCAT(a,b); \
- switch (st->f & __CONCAT3(SVR4_,a,b)) { \
- case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
- case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
- case __CONCAT3(SVR4_,c3,t3): bt->f |= __CONCAT(c3,t3); break; \
- case __CONCAT3(SVR4_,c4,t4): bt->f |= __CONCAT(c4,t4); break; \
+ if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
+ bt->f &= ~__CONCAT(a,b); \
+ switch (st->f & __CONCAT3(SVR4_,a,b)) { \
+ case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
+ case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
+ case __CONCAT3(SVR4_,c3,t3): bt->f |= __CONCAT(c3,t3); break; \
+ case __CONCAT3(SVR4_,c4,t4): bt->f |= __CONCAT(c4,t4); break; \
+ } \
}
@@ -135,6 +148,35 @@ static void svr4_termios_to_termio __P((const struct svr4_termios *ts,
case __CONCAT(c4,t4): st->f |= __CONCAT3(SVR4_,c4,t4); break; \
}
+#ifdef DEBUG_SVR4
+static void
+print_svr4_termios(st)
+ const struct svr4_termios *st;
+{
+ int i;
+ uprintf("SVR4\niflag=%lo oflag=%lo cflag=%lo lflag=%lo\n",
+ st->c_iflag, st->c_oflag, st->c_cflag, st->c_lflag);
+ uprintf("cc: ");
+ for (i = 0; i < SVR4_NCCS; i++)
+ uprintf("%o ", st->c_cc[i]);
+ uprintf("\n");
+}
+
+
+static void
+print_bsd_termios(bt)
+ const struct termios *bt;
+{
+ int i;
+ uprintf("BSD\niflag=%o oflag=%o cflag=%o lflag=%o\n",
+ bt->c_iflag, bt->c_oflag, bt->c_cflag, bt->c_lflag);
+ uprintf("cc: ");
+ for (i = 0; i < NCCS; i++)
+ uprintf("%o ", bt->c_cc[i]);
+ uprintf("\n");
+}
+#endif /* DEBUG_SVR4 */
+
static u_long
bsd_to_svr4_speed(sp, mask)
u_long sp;
@@ -159,6 +201,8 @@ bsd_to_svr4_speed(sp, mask)
getval(B,9600);
getval(B,19200);
getval(B,38400);
+ getval(B,57600);
+ getval(B,115200);
default: sp = SVR4_B9600; /* XXX */
}
@@ -200,15 +244,18 @@ svr4_to_bsd_speed(sp, mask)
getval(B,9600);
getval(B,19200);
getval(B,38400);
+ getval(B,57600);
+ getval(B,115200);
default: return B9600; /* XXX */
}
}
static void
-svr4_to_bsd_termios(st, bt)
+svr4_to_bsd_termios(st, bt, new)
const struct svr4_termios *st;
struct termios *bt;
+ int new;
{
/* control characters */
svr4_to_bsd_char(V,INTR);
@@ -478,7 +525,7 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data)
struct termios bt;
struct svr4_termios st;
struct svr4_termio t;
- int error;
+ int error, new;
int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
fp->f_ops->fo_ioctl;
@@ -490,33 +537,14 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data)
if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bt, p)) != 0)
return error;
-#ifdef DEBUG_SVR4
- {
- int i;
- printf("iflag=%o oflag=%o cflag=%o lflag=%o\n",
- bt.c_iflag, bt.c_oflag, bt.c_cflag, bt.c_lflag);
- printf("cc: ");
- for (i = 0; i < NCCS; i++)
- printf("%o ", bt.c_cc[i]);
- printf("\n");
- }
-#endif
-
+ bzero(&st,sizeof(st));
bsd_to_svr4_termios(&bt, &st);
- DPRINTF(("ioctl(TCGET[A|S]);\n"));
-
+ DPRINTF(("ioctl(TCGET%c);\n", cmd == SVR4_TCGETA ? 'A' : 'S'));
#ifdef DEBUG_SVR4
- {
- int i;
- printf("iflag=%o oflag=%o cflag=%o lflag=%o\n",
- bt.c_iflag, bt.c_oflag, bt.c_cflag, bt.c_lflag);
- printf("cc: ");
- for (i = 0; i < SVR4_NCCS; i++)
- printf("%o ", st.c_cc[i]);
- printf("\n");
- }
-#endif
+ print_bsd_termios(&bt);
+ print_svr4_termios(&st);
+#endif /* DEBUG_SVR4 */
if (cmd == SVR4_TCGETA) {
svr4_termios_to_termio(&st, &t);
@@ -542,6 +570,7 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data)
case SVR4_TCSETSF:
if ((error = copyin(data, &st, sizeof(st))) != 0)
return error;
+ new = 1;
break;
case SVR4_TCSETA:
@@ -552,10 +581,14 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data)
bsd_to_svr4_termios(&bt, &st);
svr4_termio_to_termios(&t, &st);
+ new = 0;
break;
+
+ default:
+ return EINVAL;
}
- svr4_to_bsd_termios(&st, &bt);
+ svr4_to_bsd_termios(&st, &bt, new);
switch (cmd) {
case SVR4_TCSETA:
@@ -575,6 +608,11 @@ svr4_term_ioctl(fp, p, retval, fd, cmd, data)
break;
}
+#ifdef DEBUG_SVR4
+ print_bsd_termios(&bt);
+ print_svr4_termios(&st);
+#endif /* DEBUG_SVR4 */
+
return (*ctl)(fp, cmd, (caddr_t) &bt, p);
case SVR4_TIOCGWINSZ:
diff --git a/sys/compat/svr4/svr4_termios.h b/sys/compat/svr4/svr4_termios.h
index 930c696b833..8ece5669264 100644
--- a/sys/compat/svr4/svr4_termios.h
+++ b/sys/compat/svr4/svr4_termios.h
@@ -197,21 +197,28 @@ struct svr4_winsize {
};
-#define SVR4_B0 0
-#define SVR4_B50 1
-#define SVR4_B75 2
-#define SVR4_B110 3
-#define SVR4_B134 4
-#define SVR4_B150 5
-#define SVR4_B200 6
-#define SVR4_B300 7
-#define SVR4_B600 8
-#define SVR4_B1200 9
+#define SVR4_B0 0
+#define SVR4_B50 1
+#define SVR4_B75 2
+#define SVR4_B110 3
+#define SVR4_B134 4
+#define SVR4_B150 5
+#define SVR4_B200 6
+#define SVR4_B300 7
+#define SVR4_B600 8
+#define SVR4_B1200 9
#define SVR4_B1800 10
-#define SVR4_B2400 11
-#define SVR4_B4800 12
-#define SVR4_B9600 13
-#define SVR4_B19200 14
-#define SVR4_B38400 15
+#define SVR4_B2400 11
+#define SVR4_B4800 12
+#define SVR4_B9600 13
+#define SVR4_B19200 14
+#define SVR4_B38400 15
+#define SVR4_B57600 16
+#define SVR4_B76800 17
+#define SVR4_B115200 18
+#define SVR4_B153600 19
+#define SVR4_B230400 20
+#define SVR4_B307200 21
+#define SVR4_B460800 22
#endif /* !_SVR4_TERMIOS_H_ */
diff --git a/sys/compat/svr4/svr4_ttold.c b/sys/compat/svr4/svr4_ttold.c
index e10c94909f6..78170a53239 100644
--- a/sys/compat/svr4/svr4_ttold.c
+++ b/sys/compat/svr4/svr4_ttold.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_ttold.c,v 1.4 1996/04/21 22:18:40 deraadt Exp $ */
+/* $OpenBSD: svr4_ttold.c,v 1.5 1996/08/01 00:50:56 niklas Exp $ */
/* $NetBSD: svr4_ttold.c,v 1.9 1996/04/11 12:54:45 christos Exp $ */
/*
@@ -65,6 +65,42 @@ static void svr4_ltchars_to_bsd_ltchars __P((const struct svr4_ltchars *sl,
static void bsd_ltchars_to_svr4_ltchars __P((const struct ltchars *bl,
struct svr4_ltchars *sl));
+#ifdef DEBUG_SVR4
+static void print_svr4_sgttyb __P((const char *, struct svr4_sgttyb *));
+static void print_svr4_tchars __P((const char *, struct svr4_tchars *));
+static void print_svr4_ltchars __P((const char *, struct svr4_ltchars *));
+
+static void
+print_svr4_sgttyb(str, ss)
+ const char *str;
+ struct svr4_sgttyb *ss;
+{
+ uprintf("%s\nispeed=%o ospeed=%o ", str, ss->sg_ispeed, ss->sg_ospeed);
+ uprintf("erase=%o kill=%o flags=%o\n", ss->sg_erase, ss->sg_kill,
+ ss->sg_flags);
+}
+
+static void
+print_svr4_tchars(str, st)
+ const char *str;
+ struct svr4_tchars *st;
+{
+ uprintf("%s\nintrc=%o quitc=%o ", str, st->t_intrc, st->t_quitc);
+ uprintf("startc=%o stopc=%o eofc=%o brkc=%o\n", st->t_startc,
+ st->t_stopc, st->t_eofc, st->t_brkc);
+}
+
+static void
+print_svr4_ltchars(str, sl)
+ const char *str;
+ struct svr4_ltchars *sl;
+{
+ uprintf("%s\nsuspc=%o dsuspc=%o ", str, sl->t_suspc, sl->t_dsuspc);
+ uprintf("rprntc=%o flushc=%o werasc=%o lnextc=%o\n", sl->t_rprntc,
+ sl->t_flushc, sl->t_werasc, sl->t_lnextc);
+}
+#endif /* DEBUG_SVR4 */
+
static void
svr4_tchars_to_bsd_tchars(st, bt)
const struct svr4_tchars *st;
@@ -171,7 +207,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
(caddr_t) &pid, p)) != 0)
return error;
- DPRINTF(("TIOCGPGRP %d", pid));
+ DPRINTF(("TIOCGPGRP %d\n", pid));
if ((error = copyout(&pid, data, sizeof(pid))) != 0)
return error;
@@ -185,7 +221,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
if ((error = copyin(data, &pid, sizeof(pid))) != 0)
return error;
- DPRINTF(("TIOCSPGRP %d", pid));
+ DPRINTF(("TIOCSPGRP %d\n", pid));
return (*ctl)(fp, TIOCSPGRP, (caddr_t) &pid, p);
}
@@ -198,7 +234,7 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
(caddr_t) &pid, p)) != 0)
return error;
- DPRINTF(("TIOCGSID %d", pid));
+ DPRINTF(("TIOCGSID %d\n", pid));
return copyout(&pid, data, sizeof(pid));
}
@@ -213,6 +249,9 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
return error;
bsd_sgttyb_to_svr4_sgttyb(&bs, &ss);
+#ifdef DEBUG_SVR4
+ print_svr4_sgttyb("SVR4_TIOCGETP", &ss);
+#endif /* DEBUG_SVR4 */
return copyout(&ss, data, sizeof(ss));
}
@@ -226,7 +265,9 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
return error;
svr4_sgttyb_to_bsd_sgttyb(&ss, &bs);
-
+#ifdef DEBUG_SVR4
+ print_svr4_sgttyb("SVR4_TIOCSET{P,N}", &ss);
+#endif /* DEBUG_SVR4 */
cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN;
return (*ctl)(fp, cmd, (caddr_t) &bs, p);
}
@@ -241,6 +282,9 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
return error;
bsd_tchars_to_svr4_tchars(&bt, &st);
+#ifdef DEBUG_SVR4
+ print_svr4_tchars("SVR4_TIOCGETC", &st);
+#endif /* DEBUG_SVR4 */
return copyout(&st, data, sizeof(st));
}
@@ -253,7 +297,9 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
return error;
svr4_tchars_to_bsd_tchars(&st, &bt);
-
+#ifdef DEBUG_SVR4
+ print_svr4_tchars("SVR4_TIOCSETC", &st);
+#endif /* DEBUG_SVR4 */
return (*ctl)(fp, TIOCSETC, (caddr_t) &bt, p);
}
@@ -267,6 +313,9 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
return error;
bsd_ltchars_to_svr4_ltchars(&bl, &sl);
+#ifdef DEBUG_SVR4
+ print_svr4_ltchars("SVR4_TIOCGLTC", &sl);
+#endif /* DEBUG_SVR4 */
return copyout(&sl, data, sizeof(sl));
}
@@ -279,10 +328,47 @@ svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
return error;
svr4_ltchars_to_bsd_ltchars(&sl, &bl);
-
+#ifdef DEBUG_SVR4
+ print_svr4_ltchars("SVR4_TIOCSLTC", &sl);
+#endif /* DEBUG_SVR4 */
return (*ctl)(fp, TIOCSLTC, (caddr_t) &bl, p);
}
+ case SVR4_TIOCLGET:
+ {
+ int flags;
+ if ((error = (*ctl)(fp, cmd, (caddr_t) &flags, p)) !=
+ 0)
+ return error;
+ DPRINTF(("SVR4_TIOCLGET %o\n", flags));
+ return copyout(&flags, data, sizeof(flags));
+ }
+
+ case SVR4_TIOCLSET:
+ case SVR4_TIOCLBIS:
+ case SVR4_TIOCLBIC:
+ {
+ int flags;
+
+ if ((error = copyin(data, &flags, sizeof(flags))) != 0)
+ return error;
+
+ switch (cmd) {
+ case SVR4_TIOCLSET:
+ cmd = TIOCLSET;
+ break;
+ case SVR4_TIOCLBIS:
+ cmd = TIOCLBIS;
+ break;
+ case SVR4_TIOCLBIC:
+ cmd = TIOCLBIC;
+ break;
+ }
+
+ DPRINTF(("SVR4_TIOCL{SET,BIS,BIC} %o\n", flags));
+ return (*ctl)(fp, cmd, (caddr_t) &flags, p);
+ }
+
default:
DPRINTF(("Unknown svr4 ttold %lx\n", cmd));
return 0; /* ENOSYS really */