aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2002-08-15 07:02:01 +0000
committerH. Peter Anvin <hpa@zytor.com>2002-08-15 07:02:01 +0000
commit005d4313bacd704099976d451a880551dcd77d3d (patch)
tree9bd9992774e17318a0d2889fa705c09ca8006ac1
parent65b8258ec2450938e930ad2fb5993f034dd64c79 (diff)
downloadklibc-005d4313bacd704099976d451a880551dcd77d3d.tar.gz
Fix bugs in <termios.h>; add basic pty functionalityklibc-0.42
-rw-r--r--include/stdlib.h10
-rw-r--r--include/termios.h10
-rw-r--r--klibc/Makefile2
-rw-r--r--klibc/include/stdlib.h10
-rw-r--r--klibc/include/termios.h10
-rw-r--r--klibc/pty.c31
-rw-r--r--pty.c31
7 files changed, 93 insertions, 11 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index 4d885a9190440..bcff2a02645fa 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -80,4 +80,14 @@ static __inline__ void srandom(unsigned int __s)
srand48(__s);
}
+/* Basic PTY functions. These only work if devpts is mounted! */
+
+static __inline__ int grantpt(int __fd)
+{
+ (void)__fd;
+ return 0; /* devpts does this all for us! */
+}
+__extern int unlockpt(int);
+__extern char *ptsname(int);
+
#endif /* _STDLIB_H */
diff --git a/include/termios.h b/include/termios.h
index d1f58ba2f7892..08a5e56855e17 100644
--- a/include/termios.h
+++ b/include/termios.h
@@ -5,7 +5,7 @@
#ifndef _TERMIOS_H
#define _TERMIOS_H
-#include <extern.h>
+#include <klibc/extern.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -63,23 +63,23 @@ static __inline__ int tcsetpgrp(int __fd, pid_t __p)
static __inline__ speed_t cfgetospeed(const struct termios *__s)
{
- return (speed_t)(__s->c_cflags & CBAUD);
+ return (speed_t)(__s->c_cflag & CBAUD);
}
static __inline__ speed_t cfgetispeed(const struct termios *__s)
{
- return (speed_t)(__s->c_cflags & CBAUD);
+ return (speed_t)(__s->c_cflag & CBAUD);
}
static __inline__ int cfsetospeed(struct termios *__s, speed_t __v)
{
- __s->c_cflags = (__s->c_cflags & ~CBAUD) | (__v & CBAUD);
+ __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
return 0;
}
static __inline__ int cfsetispeed(struct termios *__s, speed_t __v)
{
- __s->c_cflags = (__s->c_cflags & ~CBAUD) | (__v & CBAUD);
+ __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
return 0;
}
diff --git a/klibc/Makefile b/klibc/Makefile
index c50711809c459..33c5c2040c426 100644
--- a/klibc/Makefile
+++ b/klibc/Makefile
@@ -28,7 +28,7 @@ LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
strsep.o strtok.o \
gethostname.o getdomainname.o getcwd.o seteuid.o setegid.o \
getenv.o setenv.o unsetenv.o getopt.o readdir.o \
- syslog.o closelog.o \
+ syslog.o closelog.o pty.o \
time.o fdatasync.o llseek.o select.o nice.o getpriority.o \
qsort.o lrand48.o srand48.o seed48.o \
inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
diff --git a/klibc/include/stdlib.h b/klibc/include/stdlib.h
index 4d885a9190440..bcff2a02645fa 100644
--- a/klibc/include/stdlib.h
+++ b/klibc/include/stdlib.h
@@ -80,4 +80,14 @@ static __inline__ void srandom(unsigned int __s)
srand48(__s);
}
+/* Basic PTY functions. These only work if devpts is mounted! */
+
+static __inline__ int grantpt(int __fd)
+{
+ (void)__fd;
+ return 0; /* devpts does this all for us! */
+}
+__extern int unlockpt(int);
+__extern char *ptsname(int);
+
#endif /* _STDLIB_H */
diff --git a/klibc/include/termios.h b/klibc/include/termios.h
index d1f58ba2f7892..08a5e56855e17 100644
--- a/klibc/include/termios.h
+++ b/klibc/include/termios.h
@@ -5,7 +5,7 @@
#ifndef _TERMIOS_H
#define _TERMIOS_H
-#include <extern.h>
+#include <klibc/extern.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -63,23 +63,23 @@ static __inline__ int tcsetpgrp(int __fd, pid_t __p)
static __inline__ speed_t cfgetospeed(const struct termios *__s)
{
- return (speed_t)(__s->c_cflags & CBAUD);
+ return (speed_t)(__s->c_cflag & CBAUD);
}
static __inline__ speed_t cfgetispeed(const struct termios *__s)
{
- return (speed_t)(__s->c_cflags & CBAUD);
+ return (speed_t)(__s->c_cflag & CBAUD);
}
static __inline__ int cfsetospeed(struct termios *__s, speed_t __v)
{
- __s->c_cflags = (__s->c_cflags & ~CBAUD) | (__v & CBAUD);
+ __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
return 0;
}
static __inline__ int cfsetispeed(struct termios *__s, speed_t __v)
{
- __s->c_cflags = (__s->c_cflags & ~CBAUD) | (__v & CBAUD);
+ __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
return 0;
}
diff --git a/klibc/pty.c b/klibc/pty.c
new file mode 100644
index 0000000000000..5907ca2ff5040
--- /dev/null
+++ b/klibc/pty.c
@@ -0,0 +1,31 @@
+/*
+ * pty.c
+ *
+ * Basic Unix98 PTY functionality; assumes devpts
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+char *ptsname(int fd)
+{
+ static char buffer[32]; /* Big enough to hold even a 64-bit pts no */
+ unsigned int ptyno;
+
+ if ( ioctl(fd, TIOCGPTN, &ptyno) )
+ return NULL;
+
+ snprintf(buffer, sizeof buffer, "/dev/pts/%u", ptyno);
+
+ return buffer;
+}
+
+int unlockpt(int fd)
+{
+ int unlock = 0;
+
+ return ioctl(fd, TIOCSPTLCK, &unlock);
+}
diff --git a/pty.c b/pty.c
new file mode 100644
index 0000000000000..5907ca2ff5040
--- /dev/null
+++ b/pty.c
@@ -0,0 +1,31 @@
+/*
+ * pty.c
+ *
+ * Basic Unix98 PTY functionality; assumes devpts
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+char *ptsname(int fd)
+{
+ static char buffer[32]; /* Big enough to hold even a 64-bit pts no */
+ unsigned int ptyno;
+
+ if ( ioctl(fd, TIOCGPTN, &ptyno) )
+ return NULL;
+
+ snprintf(buffer, sizeof buffer, "/dev/pts/%u", ptyno);
+
+ return buffer;
+}
+
+int unlockpt(int fd)
+{
+ int unlock = 0;
+
+ return ioctl(fd, TIOCSPTLCK, &unlock);
+}