fix inadvertent introduction of extern object stx
[musl] / src / misc / pty.c
1 #include <stdlib.h>
2 #include <sys/ioctl.h>
3 #include <stdio.h>
4 #include <fcntl.h>
5 #include <errno.h>
6 #include "syscall.h"
7
8 int posix_openpt(int flags)
9 {
10         return open("/dev/ptmx", flags);
11 }
12
13 int grantpt(int fd)
14 {
15         return 0;
16 }
17
18 int unlockpt(int fd)
19 {
20         int unlock = 0;
21         return ioctl(fd, TIOCSPTLCK, &unlock);
22 }
23
24 int __ptsname_r(int fd, char *buf, size_t len)
25 {
26         int pty, err;
27         if (!buf) len = 0;
28         if ((err = __syscall(SYS_ioctl, fd, TIOCGPTN, &pty))) return -err;
29         if (snprintf(buf, len, "/dev/pts/%d", pty) >= len) return ERANGE;
30         return 0;
31 }
32
33 weak_alias(__ptsname_r, ptsname_r);