summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
Commit message (Collapse)AuthorAgeFilesLines
* ttyfree() frees the cdev(). But if there are pending kevents,kib2007-07-201-7/+17
| | | | | | | | | | | | | | | | filt_ttyrdetach() etc would later attempt to dereference cdev->si_tty, causing a 0xdeadc0de dereference. Change kn_hook value from cdev to struct tty to avoid dereferencing freed cdev. In ttygone(), wake up select(), sigio and kevent() users in addition to the queue sleepers. Return EV_EOF from kevent filters if TS_GONE is set. Submitted by: peter Tested by: Peter Holm Approved by: re (kensmith) MFC after: 2 weeks
* - Use rufetchcalc() rather than calcru() in ttyinfo so that we getjeff2007-07-011-3/+2
| | | | | | | | correct system and user time stats. Approved by: re Reported by: kris Discussed with: Attilio
* Re-acquire the PROC_SLOCK before calling calcru(), and release it after,cognet2007-06-111-0/+2
| | | | | | since calcru() expects it to be locked. Reviewed by: attilio
* The new compiler can't quite follow the logic of has_stime andmjacob2007-06-101-1/+1
| | | | complains about using uninitialized tags in stime.
* Commit 9/14 of sched_lock decomposition.jeff2007-06-041-57/+117
| | | | | | | | | | - Attempt to return the ttyinfo() selection algorithm to something sane as it has been broken and disabled for some time. Adapt this algorithm in such a way that it does not conflict with per-cpu scheduler locking. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
* Back out rev. 1.266. The real cause for the recent panics has been fixedmbr2006-12-201-1/+1
| | | | in rev. 1.267 and there is no need to keep this test.
* Giant might have been temporarily dropped while waiting for proctree_lock, ↵mbr2006-12-191-1/+1
| | | | | | | | | allowing for an intervening tty_close() that cleared tp->t_session. Submitted by: tegge MFC: 1 day
* Add the tp->t_refcnt validity check back. There are still some racembr2006-12-191-1/+1
| | | | conditions where tp->t_refcnt can go to zero.
* Threading cleanup.. part 2 of several.julian2006-12-061-25/+2
| | | | | | | | | | | | | | | | | | | | | | Make part of John Birrell's KSE patch permanent.. Specifically, remove: Any reference of the ksegrp structure. This feature was never fully utilised and made things overly complicated. All code in the scheduler that tried to make threaded programs fair to unthreaded programs. Libpthread processes will already do this to some extent and libthr processes already disable it. Also: Since this makes such a big change to the scheduler(s), take the opportunity to rename some structures and elements that had to be moved anyhow. This makes the code a lot more readable. The ULE scheduler compiles again but I have no idea if it works. The 4bsd scheduler still reqires a little cleaning and some functions that now do ALMOST nothing will go away, but I thought I'd do that as a separate commit. Tested by David Xu, and Dan Eischen using libthr and libpthread.
* Don't drop reference to tty in tty_close() if TS_ISOPEN is already cleared.tegge2006-11-061-7/+6
| | | | Reviewed by: bde
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningrwatson2006-11-061-6/+8
| | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
* Make KSE a kernel option, turned on by default in all GENERICjb2006-10-261-0/+11
| | | | | | | kernel configs except sun4v (which doesn't process signals properly with KSE). Reviewed by: davidxu@
* Any call of tty_close() with a tty refcount of <= 1 is wrong and we willmbr2006-09-301-6/+9
| | | | | | | free the tty in this case. This is a workaround until the underlaying devfs/tty problems are fixed. MFC after: 1 day
* Check for tp->t_refcnt == 0 before doing anything in tty_open().mbr2006-09-231-0/+6
| | | | | PR: 103520 MFC after: 1 week
* Back out rev. 1.258. The real race cause has been fixedmbr2006-09-211-2/+2
| | | | | | in rev. 1.241 of kern_proc.c. Requested by: jhb
* Fix locking race in ttymodem(). The locking of the proctree happens too latembr2006-09-101-2/+2
| | | | | | | | | | | | and opens a small race window before tp->t_session->s_leader is accessed. In case tp->t_session has just been set to NULL elsewhere, we get a panic(). This fix is a bandaid until someone else fixes the whole locking in the tty subsystem. Definitly more work needs to be done. MFC after: 1 week Reviewed by: mlaier PR: kern/103101
* Move the old BSD4.3 tty compatibility from (!BURN_BRIDGES && COMPAT_43)phk2006-01-101-11/+3
| | | | | | | | | | | | to COMPAT_43TTY. Add COMPAT_43TTY to NOTES and */conf/GENERIC Compile tty_compat.c only under the new option. Spit out #warning "Old BSD tty API used, please upgrade." if ioctl_compat.h gets #included from userland.
* Deorbit ttymalloc() in preference for ttyalloc()phk2006-01-041-16/+2
|
* Use MTX_SYSINIT to set up the tty list mutex.phk2006-01-041-6/+1
|
* Revert most of revision 1.235 and fix the problem a different way. Wejhb2005-10-271-7/+12
| | | | | | | | | | | | | | | | | | can't acquire an sx lock in ttyinfo() because ttyinfo() can be called from interrupt handlers (such as atkbd_intr()). Instead, go back to locking the process group while we pick a thread to display information for and hold that lock until after we drop sched_lock to make sure the process doesn't exit out from under us. sched_lock ensures that the specific thread from that process doesn't go away. To protect against the process exiting after we drop the proc lock but before we dereference it to lookup the pid and p_comm in the call to ttyprintf(), we now copy the pid and p_comm to local variables while holding the proc lock. This problem was found by the recently added TD_NO_SLEEPING assertions for interrupt handlers. Tested by: emaste MFC after: 1 week
* Use new functions to call into drivers methods.phk2005-10-161-39/+27
|
* Make ttyconsolemode() call ttsetwater() so that drivers don't have to.phk2005-10-161-0/+1
|
* Eliminate two unused arguments to ttycreate().phk2005-10-161-2/+4
|
* Fix the recent panics/LORs/hangs created by my kqueue commit by:ssouhlal2005-07-011-2/+2
| | | | | | | | | | | | | | | | | - Introducing the possibility of using locks different than mutexes for the knlist locking. In order to do this, we add three arguments to knlist_init() to specify the functions to use to lock, unlock and check if the lock is owned. If these arguments are NULL, we assume mtx_lock, mtx_unlock and mtx_owned, respectively. - Using the vnode lock for the knlist locking, when doing kqueue operations on a vnode. This way, we don't have to lock the vnode while holding a mutex, in filt_vfsread. Reviewed by: jmg Approved by: re (scottl), scottl (mentor override) Pointyhat to: ssouhlal Will be happy: everyone
* According to the comment in struct tty, t_modem is optional; hence we shouldavatar2005-04-131-2/+4
| | | | | | | | guard against NULL t_modem entry. Otherwise, driver doesn't have t_modem callback implemented(such like sys/dev/usb/ucycom.c) would panic when someone opens the driver's associated tty device. Reviewed by: phk, sam (mentor)
* Make (some) serial ports implement the PPS-API again. This changephk2005-03-261-0/+6
| | | | appearantly fell out during the tty code cleanup.
* Replace my previous change for 32 bit systems with hz > 169 with Bruce'speter2005-03-121-10/+11
| | | | simpler one.
* Make the tty vmin/vtime timeouts work for hz > 169 on 32 bit machines.peter2005-03-121-7/+7
|
* Add placeholder mutex argument to new_unrhdr().phk2005-03-071-1/+1
|
* Call tty_close() at the very end of ttyclose() since otherwise NULLjhb2004-12-301-1/+1
| | | | | | | deferences can occur since tty_close() may end up freeing the tty structure if it drops the last reference to it. Glanced at by: phk
* fix a misleading sleep identifier.phk2004-12-201-1/+1
|
* Improvements and fixes in the 1.241 commit:dds2004-11-161-6/+9
| | | | | | | | | | | - Have TS_ZOMBIE ttys return POLLHUP instead of POLLERR - Remove unneeded POLLWRNORM (old bug) - TS_ZOMBIE ttys will set POLLIN and POLLRDNORM - Do not call selrecord in TS_ZOMBIE ttys PR: kern/73821 Reviewed by: bde MFC after: 4 weeks
* Return POLLERR rather than POLLIN/POLLOUT on TS_ZOMBIE ttys.dds2004-11-111-4/+5
| | | | | PR: kern/73821 MFC after: 4 weeks
* Restore TTYDEF_LFLAG to set echo bits.phk2004-11-031-1/+1
|
* Add new function ttyinitmode() which sets our systemwide defaultphk2004-10-181-12/+29
| | | | | | | | | | | | | | modes on a tty structure. Both the ".init" and the current settings are initialized allowing the function to be used both at attach and open time. The function takes an argument to decide if echoing should be enabled. Echoing should not be enabled for regular physical serial ports unless they are consoles, in which case they should be configured by ttyconsolemode() instead. Use the new function throughout.
* Make pty's always come up in echo mode.phk2004-10-151-1/+1
|
* Add missing chunk of code to enforce the lock-bits of termios.phk2004-10-141-1/+26
| | | | | | | This solves the problem where serial consoles suddenly required DCD to be asserted. Reported by: Randy Bush <randy@psg.com>
* Don't call driver close unless we have one.phk2004-10-121-2/+4
|
* Rework how we store process times in the kernel such that we always storejhb2004-10-051-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the raw values including for child process statistics and only compute the system and user timevals on demand. - Fix the various kern_wait() syscall wrappers to only pass in a rusage pointer if they are going to use the result. - Add a kern_getrusage() function for the ABI syscalls to use so that they don't have to play stackgap games to call getrusage(). - Fix the svr4_sys_times() syscall to just call calcru() to calculate the times it needs rather than calling getrusage() twice with associated stackgap, etc. - Add a new rusage_ext structure to store raw time stats such as tick counts for user, system, and interrupt time as well as a bintime of the total runtime. A new p_rux field in struct proc replaces the same inline fields from struct proc (i.e. p_[isu]ticks, p_[isu]u, and p_runtime). A new p_crux field in struct proc contains the "raw" child time usage statistics. ruadd() has been changed to handle adding the associated rusage_ext structures as well as the values in rusage. Effectively, the values in rusage_ext replace the ru_utime and ru_stime values in struct rusage. These two fields in struct rusage are no longer used in the kernel. - calcru() has been split into a static worker function calcru1() that calculates appropriate timevals for user and system time as well as updating the rux_[isu]u fields of a passed in rusage_ext structure. calcru() uses a copy of the process' p_rux structure to compute the timevals after updating the runtime appropriately if any of the threads in that process are currently executing. It also now only locks sched_lock internally while doing the rux_runtime fixup. calcru() now only requires the caller to hold the proc lock and calcru1() only requires the proc lock internally. calcru() also no longer allows callers to ask for an interrupt timeval since none of them actually did. - calcru() now correctly handles threads executing on other CPUs. - A new calccru() function computes the child system and user timevals by calling calcru1() on p_crux. Note that this means that any code that wants child times must now call this function rather than reading from p_cru directly. This function also requires the proc lock. - This finishes the locking for rusage and friends so some of the Giant locks in exit1() and kern_wait() are now gone. - The locking in ttyinfo() has been tweaked so that a shared lock of the proctree lock is used to protect the process group rather than the process group lock. By holding this lock until the end of the function we now ensure that the process/thread that we pick to dump info about will no longer vanish while we are trying to output its info to the console. Submitted by: bde (mostly) MFC after: 1 month
* Assign a global unit number for the tty slave devices (init/lock) usingphk2004-09-301-6/+23
| | | | | | | the new subr_unit.c code. For now assert Giant in ttycreate() and ttyfree(). It is not obvious that it will ever pay off to lock these with anything else.
* Add functions to create and free the "tty-ness" of a serial port in aphk2004-09-281-6/+233
| | | | | | | | | | | | | | | | | | | | | | | | | generic way. This code will allow a similar amount of code to be removed from most if not all serial port drivers. Add generic cdevsw for tty devices. Add generic slave cdevsw for init/lock devices. Add ttypurge function which wakes up all know generic sleep points in the tty code, and calls into the hw-driver if it provides a method. Add ttycreate function which creates tty device and optionally cua device. In both cases .init/.lock devices are created as well. Change ttygone() slightly to also call the hw driver provided purge routine. Add ttyfree() which will purge and destroy the cdevs. Add ttyconsole mode for setting console friendly termios on a port.
* Hold threadcount while throbbing cdevsw in our underlying driver.phk2004-09-241-20/+25
| | | | | This is a bit heavyhanded, and will be simplified once the tty code learns to properly deal with disappearing hw and drivers.
* Initialize new ttys a bit more.phk2004-09-181-8/+22
| | | | Check TS_GONE flag for gone-ness.
* Add ttyopen and ttyclose functions which will do the right stuff forphk2004-09-171-0/+97
| | | | | | | most if not all of our tty drivers in the future. Centralizing this stuff enables us to remove about 100 lines of almost but not quite perfectly copy&paste code from each tty driver.
* Add ttyalloc() which in due time will be the successor to ttymalloc(),phk2004-09-171-0/+7
| | | | but without the "struct tty *" argument.
* Add locking to the kqueue subsystem. This also makes the kqueue subsystemjmg2004-08-151-7/+13
| | | | | | | | | | | | | a more complete subsystem, and removes the knowlege of how things are implemented from the drivers. Include locking around filter ops, so a module like aio will know when not to be unloaded if there are outstanding knotes using it's filter ops. Currently, it uses the MTX_DUPOK even though it is not always safe to aquire duplicate locks. Witness currently doesn't support the ability to discover if a dup lock is ok (in some cases). Reviewed by: green, rwatson (both earlier versions)
* Preparation commit for the tty cleanups that will follow in the nearphk2004-07-151-4/+4
| | | | | | | | | future: rename ttyopen() -> tty_open() and ttyclose() -> tty_close(). We need the ttyopen() and ttyclose() for the new generic cdevsw functions for tty devices in order to have consistent naming.
* Introduce ttygone() which indicates that the hardware is detached.phk2004-07-111-0/+64
| | | | Move dtrwait logic to the generic TTY level.
* Pick the hotchar out of the tty structure instead of caching privatephk2004-06-261-2/+1
| | | | | | | | copies. No current line disciplines have a dynamically changing hotchar, and expecting to receive anything sensible during a change in ldisc is insane so no locking of the hotchar field is necessary.
* Fix line discipline switching issues: If opening a new ldisc fails,phk2004-06-261-12/+21
| | | | | | | | | | | | | we have to revert to TTYDISC which we know will successfully open rather than try the previous ldisc which might also fail to open. Do not let ldisc implementations muck about with ->t_line, and remove code which checks for reopens, it should never happen. Move ldisc->l_hotchar to tty->t_hotchar and have ldisc implementation initialize it in their open routines. Reset to zero when we enter TTYDISC. ("no" should really be -1 since zero could be a valid hotchar for certain old european mainframe protocols.)
OpenPOWER on IntegriCloud