PTY: Fix some tricky issues. Now seems to be working. A lot more testing is needed

This commit is contained in:
Gregory Nutt
2016-07-15 14:29:32 -06:00
parent 4b5149b244
commit 4b1553d3ad
3 changed files with 34 additions and 2 deletions
+28
View File
@@ -233,6 +233,34 @@ int open(const char *path, int oflags, ...)
goto errout_with_fd;
}
#ifdef CONFIG_PSEUDOTERM_SUSV1
/* If the return value from the open method is > 0, then we may assume that
* it is actually a file descriptor. This kind of logic is only needed for
* /dev/ptmx: When dev ptmx is opened, it does not return a file descriptor
* associated with the /dev/ptmx inode, but rather with the master device.
*
* REVISIT: This is a kludge. It is dangerous because (1) Zero is also a
* valid file descriptor, and (2) there could potentially be driver open
* methods that return values > 0 for normal success conditions.
*/
if (ret > 0)
{
/* Release file descriptor and inode that we allocated. We don't
* need those.
*/
files_release(fd);
inode_release(inode);
/* Instead, return the descriptor associated with the master side
* device.
*/
fd = ret;
}
#endif
return fd;
errout_with_fd: