From 9078a75888e1dbf76ce2c06b714fa3d421f0eb42 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Wed, 22 Jun 2005 20:11:59 +0000 Subject: [PATCH] Instead of emulating a userland system call via stackgap, use kern_open directly. --- sys/dev/misc/streams/streams.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/sys/dev/misc/streams/streams.c b/sys/dev/misc/streams/streams.c index c5f363928d..d006b494c2 100644 --- a/sys/dev/misc/streams/streams.c +++ b/sys/dev/misc/streams/streams.c @@ -31,7 +31,7 @@ * in 3.0-980524-SNAP then hacked a bit (but probably not enough :-). * * $FreeBSD: src/sys/dev/streams/streams.c,v 1.16.2.1 2001/02/26 04:23:07 jlemon Exp $ - * $DragonFly: src/sys/dev/misc/streams/Attic/streams.c,v 1.17 2005/06/22 20:09:34 joerg Exp $ + * $DragonFly: src/sys/dev/misc/streams/Attic/streams.c,v 1.18 2005/06/22 20:11:59 joerg Exp $ */ #include @@ -41,6 +41,8 @@ #include /* malloc region definitions */ #include #include +#include +#include #include #include #include @@ -279,32 +281,27 @@ svr4_ptm_alloc(struct thread *td) static char ptyname[] = "/dev/ptyXX"; static char ttyletters[] = "pqrstuwxyzPQRST"; static char ttynumbers[] = "0123456789abcdef"; - caddr_t sg = stackgap_init(); - char *path = stackgap_alloc(&sg, sizeof(ptyname)); - struct open_args oa; - int l = 0, n = 0; - int error; struct proc *p = td->td_proc; + struct nlookupdata nd; + int error, fd, l = 0, n = 0; KKASSERT(p); - SCARG(&oa, path) = path; - SCARG(&oa, flags) = O_RDWR; - SCARG(&oa, mode) = 0; - for (;;) { ptyname[8] = ttyletters[l]; ptyname[9] = ttynumbers[n]; - if ((error = copyout(ptyname, path, sizeof(ptyname))) != 0) - return error; + error = nlookup_init(&nd, ptyname, UIO_SYSSPACE, NLC_FOLLOW); + if (error == 0) + error = kern_open(&nd, O_RDWR, 0, &fd); + nlookup_done(&nd); - switch (error = open(&oa)) { + switch (error) { case ENOENT: case ENXIO: return error; case 0: - p->p_dupfd = oa.sysmsg_result; + p->p_dupfd = fd; return ENXIO; default: if (ttynumbers[++n] == '\0') { -- 2.41.0