History log of /haiku/src/add-ons/kernel/generic/tty/tty_private.h
Revision Date Author Comments
# b197dcba 09-May-2023 Trung Nguyen <trungnt282910@gmail.com>

tty: Implement exclusive mode

Implemented exclusive mode on Haiku and added the related `ioctl`
operations (`TIOCEXCL` and `TIOCNXCL`).

Change-Id: Iaa201ea20eec0e45d02dd5db9ba6aa35fd27dfb2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6387
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>


# bb57ea89 09-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

generic/tty: Combine settings structures.

It doesn't make much sense to have separate window sizes, termios, etc.
settings for the two halves of a TTY. Moreover, having separate settings
which can get out of sync breaks applications, e.g. double-printing
in shells.

The original TTY driver has unified settings. It seems likely that the
settings were separated as part of the locking simplification, however
the lock separation was reverted a while back, anyway.


# 0f6f5adb 18-Oct-2021 Adrien Destugues <pulkomandy@pulkomandy.tk>

generic/tty: restore lock sharing between master and slave TTYs

The code in this module was derived from the one in driver/tty. However,
the driver uses a shared lock between the master and slave side of a
TTY, and this was changed to use two separate locks. The approach with
two locks does not work. It seems the change was unfinished and the
second TTY was never locked. But attempting to lock it will result in
lock inversion problems, unless we do complicated things (try to find
which of the two TTY is the master side, and lock that first, for
example). It is simpler to restore the shared lock as used in the
driver.

To set up the shared lock, I modified the tty_create function to take a
pointer to the master TTY when creating the slave. Maybe it makes more
sense to create both sides in the same call, create_tty_pair?

However, this does not work as easily as I wanted, because there is some
recursion going on: at least in one case, the tty_control function is
calling the driver's tty_service function, which in turns attempts to
call back into tty_control for the "other side" TTY. To handle this
case, replace the mutex with a recursive_lock.

Fixes #17091, where the root problem was access to
other_tty->select_pool without locking. This was also made unconvenient
to debug because select_pool objects are self-deleting, when the last
item in the pool is removed. As a result, the code accessing it without
log would suddenly find out that the data it was accessing had been
freed and erased.

This also makes the TTY code in driver/tty and generic/tty a bit more
similar than it was before, and brings us one step closer to merging the
two together. There are still two main differences and I don't know
enough about TTY to decide if they are important, and which version
should be kept:
- The driver has extra code for "background" read and write. I don't
know what this is used for.
- The driver has a single "settings" instance shared by a master and
slave TTY, while the module has two separate instances, but seems to
copy one to the other. I'm not sure which approach is correct.

Change-Id: Ie2daddd027859ce32ba395af76b4f109f8b984b0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4604
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# e7a62c42 17-Oct-2021 Adrien Destugues <pulkomandy@pulkomandy.tk>

tty: synchronize the driver and module sourcecode a bit

The tty module started its life as a copy of the driver, and they
diverged over time as fixes and refactorings were not always brought to
both sides.

This commit does not improve the situation, but it tries to make the
two versions of the tty_private.h and tty.cpp files as similar as
possible to ease comparison.

Change-Id: I62255262b167ab81c9a0619c8f19b36b1a165fad
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4601
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 7f8f4c9c 28-Apr-2019 Jérôme Duval <jerome.duval@gmail.com>

tty: some improvements to pass posix_openpt_test.

WriterLocker::AcquireWriter(): don't fail when the other end isn't yet opened.
WriterLocker::_CheckBackgroundWrite(): don't fail when the pgrp_id differs.
ReaderLocker::AcquireReader(): fail when the other end isn't opened anymore.
ReaderLocker::AcquireReader(): check available bytes even in case of failure.
ReaderLocker::_CheckBackgroundRead(): don't fail when the pgrp_id differs.

Change-Id: Ice2bd119cbec2afc9ebd40714e4307856f540ea2
Reviewed-on: https://review.haiku-os.org/c/1418
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 6e72f897 10-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Remove the global lock and the documentation for it. It was specific to the tty
driver and doesn't apply to the generic module.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42086 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91bcf08e 07-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Adding a generic tty module based largely on the tty driver. This has a new API
and doesn't come with BeOS backwards compatibility. It also has the BeOS
compatibility ioctl ops removed and such. I've actually made this back in april,
so I don't really remember any more details.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39760 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e72f897f4d3adb220c53482aa6133f13e0df4b1 10-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Remove the global lock and the documentation for it. It was specific to the tty
driver and doesn't apply to the generic module.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42086 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91bcf08ee50af0da44d5d8631477e7c08c5e0255 07-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Adding a generic tty module based largely on the tty driver. This has a new API
and doesn't come with BeOS backwards compatibility. It also has the BeOS
compatibility ioctl ops removed and such. I've actually made this back in april,
so I don't really remember any more details.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39760 a95241bf-73f2-0310-859d-f6bbb57e9c96