1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-14 14:55:41 +00:00

Use kern_open() directly rather than a stackgap detour via open().

This commit is contained in:
John Baldwin 2005-02-07 18:22:20 +00:00
parent 01660e7bc2
commit 777a3021d3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=141466

View File

@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/protosw.h>
#include <sys/socketvar.h>
#include <sys/syscallsubr.h>
#include <sys/un.h>
#include <sys/domain.h>
#include <net/if.h>
@ -289,7 +290,6 @@ static int
svr4_ptm_alloc(td)
struct thread *td;
{
struct proc *p = td->td_proc;
/*
* XXX this is very, very ugly. But I can't find a better
* way that won't duplicate a big amount of code from
@ -306,25 +306,20 @@ svr4_ptm_alloc(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;
register_t fd = -1;
int error;
oa.path = path;
oa.flags = O_RDWR;
oa.mode = 0;
struct proc *p;
register_t fd;
int error, l, n;
fd = -1;
n = 0;
l = 0;
p = td->td_proc;
while (fd == -1) {
ptyname[8] = ttyletters[l];
ptyname[9] = ttynumbers[n];
if ((error = copyout(ptyname, path, sizeof(ptyname))) != 0)
return error;
switch (error = open(td, &oa)) {
error = kern_open(td, ptyname, UIO_SYSSPACE, O_RDWR, 0);
switch (error) {
case ENOENT:
case ENXIO:
return error;