diff options
Diffstat (limited to 'lib/libc/gen/ttyname.c')
-rw-r--r-- | lib/libc/gen/ttyname.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c index 6543604..a21b77f 100644 --- a/lib/libc/gen/ttyname.c +++ b/lib/libc/gen/ttyname.c @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <sys/types.h> -#include <sys/stat.h> #include <sys/ioctl.h> #include <sys/filio.h> #include <fcntl.h> @@ -60,8 +59,6 @@ static int ttyname_keycreated = 0; int ttyname_r(int fd, char *buf, size_t len) { - struct stat sb; - struct fiodgname_arg fgn; size_t used; *buf = '\0'; @@ -69,21 +66,14 @@ ttyname_r(int fd, char *buf, size_t len) /* Must be a terminal. */ if (!isatty(fd)) return (ENOTTY); - /* Must be a character device. */ - if (_fstat(fd, &sb) || !S_ISCHR(sb.st_mode)) - return (ENOTTY); /* Must have enough room */ if (len <= sizeof(_PATH_DEV)) return (ERANGE); strcpy(buf, _PATH_DEV); used = strlen(buf); - fgn.len = len - used; - fgn.buf = buf + used; - if (!_ioctl(fd, FIODGNAME, &fgn)) - return (0); - used = strlen(buf); - devname_r(sb.st_rdev, S_IFCHR, buf + used, len - used); + if (fdevname_r(fd, buf + used, len - used) == NULL) + return (ENOTTY); return (0); } |