mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
ttyname_r(): Return actual error, not always [ENOTTY].
Adjust the test that used to fail because of this bug. PR: 191936 MFC after: 1 week
This commit is contained in:
parent
920c6cbadc
commit
424c16b2ce
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=278038
|
@ -107,9 +107,6 @@ ATF_TC_BODY(ttyname_r_err, tc)
|
|||
ATF_REQUIRE(rv == ERANGE);
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
atf_tc_expect_fail("FreeBSD returns ENOTTY instead of EBADF; see bin/191936");
|
||||
#endif
|
||||
rv = ttyname_r(-1, buf, ttymax);
|
||||
ATF_REQUIRE(rv == EBADF);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ ttyname_r(int fd, char *buf, size_t len)
|
|||
|
||||
/* Must be a terminal. */
|
||||
if (!isatty(fd))
|
||||
return (ENOTTY);
|
||||
return (errno);
|
||||
/* Must have enough room */
|
||||
if (len <= sizeof(_PATH_DEV))
|
||||
return (ERANGE);
|
||||
|
@ -73,7 +73,7 @@ ttyname_r(int fd, char *buf, size_t len)
|
|||
strcpy(buf, _PATH_DEV);
|
||||
used = strlen(buf);
|
||||
if (fdevname_r(fd, buf + used, len - used) == NULL)
|
||||
return (ENOTTY);
|
||||
return (errno == EINVAL ? ERANGE : errno);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue