Home | History | Annotate | Download | only in kern
History log of /src/sys/kern/tty_pty.c
RevisionDateAuthorComments
 1.149  11-Oct-2021  thorpej Setting EV_EOF requires modifying kn->kn_flags. However, that relies on
holding the kq_lock of that note's kq. Rather than exposing this directly,
add new knote_set_eof() and knote_clear_eof() functions that handle the
necessary locking and don't leak as many implementation details to modules.

NetBSD 9.99.91
 1.148  29-Sep-2021  thorpej ttyread_filtops, ttywrite_filtops, ptcread_filtops, and ptcwrite_filtops
are MPSAFE.
 1.147  26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.146  11-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.145  15-Feb-2019  mgorny branches: 1.145.12;
Fix reporting EOF via kevent and add a test case

Fix the kernel pty driver to report closed slave via master's kevent
EVFILT_READ. This behavior matches the behavior for pipes, is
consistent with how FreeBSD implements it and is relied upon by LLDB's
main loop implementation.

Includes feedback by kre and kamil (from tech-kern), commit approved
by kamil.
 1.144  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.143  25-Oct-2017  maya branches: 1.143.2; 1.143.4;
Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.142  20-Aug-2015  christos branches: 1.142.2; 1.142.8; 1.142.10;
include ioconf.h instead of locally declaring the prototype of the attach
function
 1.141  18-Oct-2014  snj branches: 1.141.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.140  25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.139  22-May-2014  dholland Define TTY_ALLOW_PRIVATE in tty.c, tty_pty.c, and tty_conf.c.

These modules are the core of the tty code that in the long term needs
access to struct tty. (It may be that in the future this can be cut
back to just tty.c; we'll see. For now I'll settle for keeping drivers
out of struct tty.)
 1.138  04-Apr-2014  christos branches: 1.138.2;
Kernel portion of the multiple ptyfs mount support. Protocol changed
between kernel and module, so bump. (Ilya Zykov)
 1.137  28-Mar-2014  ozaki-r Fix unused variable 'mp'
 1.136  27-Mar-2014  christos From Ilya Zykov:
- ifdef out some code that is only used for NO_DEV_PTM
- pass the mountpoint instead of the ptm structure to the implementation
dependent (ptyfs or bsdpty) functions.
- add a function to return the correct ptyfs mountpoint for the current lwp
 1.135  16-Mar-2014  dholland Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.134  29-Jan-2014  yamt tty_pty: add CTASSERTs to document assumptions
 1.133  15-Sep-2013  martin Remove unused variables
 1.132  20-Oct-2012  apb branches: 1.132.2;
Set tp->t_dev to the correct dev_t value in both ptmopen and ptsopen.
Depending on how the pty had been opened, t_dev could previously have
been set to NODEV. This was probably harmless before, but it caused the
compatibility handler for the COMPAT_60_TIOCPTSNAME ioctl to fail for
ptys that were allocated by screen(1), but only if this was the first
time that the pty had ever been used.
 1.131  24-Sep-2011  christos branches: 1.131.2; 1.131.12;
put back the cc == 0 check, because we can re-enter the loop with cc != 0
if we block.
 1.130  23-Sep-2011  christos Fix various bogus things:
- Don't use TTYHOG - 1, you can use the last byte in the ring buffer.
- Don't put unnecessary if statements around the code. The loop invariant
is that if you reach the top of the loop, cc == 0.
- Remove cast to (void *).
- Check result of b_to_q and adjust cc.
- Explain what the TTYHOG - 2 code tried to do, and do it right.
 1.129  26-Jul-2011  yamt stop using lbolt in tty
 1.128  24-Apr-2011  rmind Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.127  09-Apr-2011  martin Add a few KASSERT to verify we do not accidently use minor(NODEV) as an
index into the pt_softc array.
 1.126  09-Apr-2011  martin KNF, add a comment and an assertion.
 1.125  09-Apr-2011  martin In ttymalloc() explicitly initialize t_dev to NODEV.
In ptcwakeup() do not bother to wake up a client side if it has not been
opened yet.
The old code would spuriously wakeup the client minor(0) [i.e. ttyp0
typically] or crash the kernel if that wasn't open, see PR kern/40688.
(Old names used to match the PR and test case, adjust names for
/dev/ptm[x] resp. /dev/pts/* accordingly)
 1.124  16-Nov-2010  dyoung branches: 1.124.2;
Fix a bug in ptcread() that stopped a pty(4) in TIOCPKT_IOCTL mode from
sending a termios(4) structure like it was supposed to: ptcread() used
to copy pti->pt_send and zero it before testing it for TIOCPKT_IOCTL.
Test for TIOCPKT_IOCTL in the pti->pt_send copy in local variable c
instead of in pti->pt_send itself.
 1.123  05-Sep-2010  dyoung Cosmetic: remove unnecessary parenthesization in return statements.
Don't "test truth" of ints, but compare with 0, instead.

The generated assembly is the same before & after this change.
 1.122  13-Jun-2010  yamt use NULL instead of 0 for pointers.
 1.121  24-Jan-2010  dholland branches: 1.121.2; 1.121.4;
Amplify comment about ultrix bits.
 1.120  20-Dec-2009  pooka Add a pointing to an explanation of why we have #ifdef pmax stuff in here.
 1.119  14-Oct-2009  dsl Error out of ptcread() if the uio length supplied is zero before the code
has a chance to panic in ureadc().
 1.118  11-Oct-2009  dsl Fix locking when collecting pt_read and pt_ucntl.
 1.117  12-Jun-2009  plunky Writes on the controlling tty were not being awoken from blocks,
use the correct condvar to make this happen.

this fixes PR/41566
 1.116  09-Mar-2009  uebayasi KNF. ANSI'fy.
 1.115  22-Jan-2009  yamt branches: 1.115.2;
malloc -> kmem_alloc
 1.114  15-Nov-2008  mrg explicitly include <sys/ioctl_compat.h> since we explicitly use
symbols defined in it. fixes various build issues.
 1.113  14-Nov-2008  ad Remove unneeded compat ifdef.
 1.112  03-Sep-2008  drochner branches: 1.112.2; 1.112.4; 1.112.6;
Make ioctl(FIONREAD) on the master side of a pty return the amount of
data which can be read, as expected. Before, the call fell through a
"case" statement and was forwarded to the slave side, returning the
data which can be read by the slave.
The new behaviour also matches Linux and OSF/1.
 1.111  16-Jun-2008  ad branches: 1.111.2;
PPWAIT need only be locked by proc_lock, so move it to proc::p_lflag.
 1.110  25-May-2008  ad branches: 1.110.2;
Properly fix the "hanging in tty" bug that was worked around with cv_wakeup()
some time again.
 1.109  20-Apr-2008  ad branches: 1.109.2; 1.109.4;
Improve ^T / SIGINFO handling:

- Restore code removed during LWPification.
- Don't touch proc state from a hardware interrupt handler.
- Fix the locking.
 1.108  01-Mar-2008  rmind branches: 1.108.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.107  30-Dec-2007  ad branches: 1.107.2; 1.107.6;
Pull up 1.104.2.3:
Avoid mutex recursion with kqueue. Reported by martin@.
 1.106  22-Dec-2007  ad Restore seperate condvars for clist i/o and clist control activity.
Fixes lockups with concurrent output to ttys. kern/37455
 1.105  05-Dec-2007  pooka branches: 1.105.4;
Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
 1.104  19-Nov-2007  ad branches: 1.104.2;
Tidy up the locking a bit.
 1.103  19-Nov-2007  ad - Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.102  07-Nov-2007  ad Merge tty changes from the vmlocking branch.
 1.101  17-Apr-2007  pooka branches: 1.101.6; 1.101.8; 1.101.12; 1.101.14;
wrap calls to pgsignal() in proclist_mutex
 1.100  12-Mar-2007  ad Use mutexes/condvars.
 1.99  04-Mar-2007  christos branches: 1.99.2; 1.99.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.98  09-Feb-2007  ad branches: 1.98.2;
Merge newlock2 to head.
 1.97  22-Dec-2006  elad Use KAUTH_DEVICE_TTY_OPEN instead of comparing euid to zero.
 1.96  01-Nov-2006  yamt remove some __unused from function parameters.
 1.95  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.94  23-Sep-2006  xtraeme Remove duplicated includes, from Jeff Ito -> PR kern/26113. Thanks.
 1.93  03-Aug-2006  christos branches: 1.93.4; 1.93.6;
adjust resid in one more place.
 1.92  03-Aug-2006  christos don't drop characters that we've copied in when we block.
 1.91  23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.90  03-Jun-2006  christos Introduce SA_NOKERNINFO, a flag for SIGINFO not to print kernel messages.
 1.89  14-May-2006  elad branches: 1.89.2;
integrate kauth.
 1.88  13-Apr-2006  christos Strip the chrooted portion of the path from the reported pty path. Reported
and tested by Lasse Kliemann. Thanks!
 1.87  05-Mar-2006  christos branches: 1.87.2; 1.87.4;
Move ISSET/SET/CLR macros to sys/types.h
 1.86  11-Dec-2005  christos branches: 1.86.4; 1.86.6; 1.86.8;
merge ktrace-lwp.
 1.85  21-Jun-2005  ws branches: 1.85.2;
PR-30566: Poll must not return <sys/errno.h> values.
Start with those places I can easily test.
 1.84  29-May-2005  christos - add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.
 1.83  26-Feb-2005  perry nuke trailing whitespace
 1.82  13-Nov-2004  christos branches: 1.82.4; 1.82.6;
PR/25749: Peter Postma: Missing splx() in kernel.
 1.81  10-Nov-2004  christos Split the ptm driver out of tty_pty.c into its own file. From that split
the code that `knows' about /dev/[pt]tyXX names (the BSD ptys) into a separate
file. Make an interface to be used by the tty creating provider. The code
to enable old PTY searching via ptm is enabled via COMPAT_BSDPTY, and it
is turned on by default on all kernels that have compatibility options enabled.
 1.80  18-Jun-2004  christos ptm is now mandatory, depends on pty, and can be disabled with -DNO_DEV_PTM
 1.79  05-Jun-2004  lha Return directly when pty_alloc_master failes in ptmioctl,
bug-report on current users from Denis Lagno dlagno at smtp dot ru.
Make debug message in pty_alloc_master to match the code.
 1.78  27-May-2004  christos turn off debugging.
 1.77  27-May-2004  christos Unix 98 pty multiplexor device; original code from OpenBSD.
 1.76  23-Mar-2004  junyoung Nuke __P().
 1.75  09-Mar-2004  dbj add more spltty() calls around TTY_LOCK/UNLOCK where needed
 1.74  05-Mar-2004  dbj add some spltty() calls around TTY_LOCK() calls that didn't have them
 1.73  22-Feb-2004  jdolecek use the new NOTE_SUBMIT to flag if the locking is necessary
for EVFILT_READ/EVFILT_WRITE knotes

fixes PR kern/23915 by Martin Husemann (pipes), and similar locking problem
in tty code
 1.72  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.71  23-Jul-2003  dsl Fix (and simplify) interaction between check_pty() and pty_maxptys().
Lock setting/clearing of tp->t_oproc to guarantee concurrent opens can't
both suceed and that code in tty.c can't get a NULL t_oproc if the value
is re-read after being checked.
There are still MP issues with pt_flags, pt_send and pt_unctl.
Maybe problems that require TTY_LOCK() to be taken before calling std tty
functions.
 1.70  29-Jun-2003  fvdl branches: 1.70.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.69  28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.68  05-Feb-2003  pk Make the tty subsystem MP-safe..

..as far as mere mortals are able to, since this code illustrates the finest
points that Italian haute cuisine has to offer.
 1.67  19-Jan-2003  simonb b_to_q() and q_to_b() take a "u_char *" argument, so use a u_char array
in one place, and don't cast a "u_char *" to a "char *" in the q_to_b()
call(!) in another.
 1.66  26-Nov-2002  christos si_ -> sel_ to avoid conflicts with siginfo.
 1.65  23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.64  22-Sep-2002  jdolecek check_pty(): make sure to zero the newly allocated pt_softc structure
 1.63  06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.62  25-Mar-2002  itohy branches: 1.62.2;
Print ttyinfo *before* (not after) sending SIGINFO to processes.
This generates more useful information of a process who catches SIGINFO,
rather than always printing "runnable" (the process is marked runnable
because of the signal).
Inspired by the behavior of BSD/OS.
 1.61  17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.60  02-Mar-2002  mrg move the COMPAT_SUNOS TIOCGPGRP handling in the compat sunos code proper.
this is the final fix needed for it to run properly as an LKM. no more
COMPAT_SUNOS hacks around the tree!
 1.59  17-Feb-2002  christos ICANON is in lflags, by Neelkanth Natu
 1.58  02-Feb-2002  tls Kick DEFAULT_MAXPTYS from 256 to 992
 1.57  12-Nov-2001  lukem add RCSIDs
 1.56  02-May-2001  scw branches: 1.56.2; 1.56.4; 1.56.6;
Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.55  24-Nov-2000  chs branches: 1.55.2;
adjust the spinlock macros in the non-MULTIPROCESSOR, non-LOCKDEBUG case
so that gcc will think that static spinlock are used.
this allows us to remove the ugly conditionalization of
static spinlock declarations.
 1.54  21-Nov-2000  enami Unlock mutex before jumping off from the critical region instead of
testing if locked.
 1.53  20-Nov-2000  veego simple_lock_held is only defined when you use LOCKDEBUG.
Put it for now in an ifdef LOCKDEBUG.
 1.52  19-Nov-2000  jdolecek check_pty(): simple_unlock() might have been called even if the lock was
not locked previously in some cases; unlock only if the lock is held
 1.51  05-Nov-2000  jdolecek add new function sigismasked(), which checks whether passed signal
is ignored or masked by the process, and use it appropriately
instead of directly checking p->p_sigmask and p->p_sigignore
 1.50  01-Nov-2000  eeh Make line disciplines modular so they can be added or removed dynamically.
 1.49  11-Sep-2000  pk make compile #if LOCKDEBUG is on.
 1.48  10-Sep-2000  jdolecek change DEFAULT_MAXPTYS to 256
make all local variables static
use simplelocks - we really need only mutexes, full locks are not necessary
update couple of comments to be more accurate

add function pty_maxptys(), which provides a safe way to get&set maxptys - this
also supports setting maxptys to lower than current value, if the
value is lower or equal current number of ptys
 1.47  09-Sep-2000  jdolecek allocate pty kernel structures on demand at run-time - this allows
to support arbitrary number of ptys without need of kernel recompile
(the extra device special files in /dev/ still need to be created, of course)

upper limit of supported ptys is controlled via new sysctl variable
kern.maxptys (KERN_MAXPTYS), which is raise-only and defaults to 512.
 1.46  28-Jul-2000  mrg fix rev 1.44; make this cast look like:
sig = (int)(long)*(caddr_t *)data;
to *properly* dereference the passed data. this makes signals on
ptys actually *work* on the sparc64 port. from mycroft.


XXX: the release branch version needs this ASAP as it is probably
unstable on ILP32BE.
 1.45  27-Jul-2000  mason Moving to a default of 64 PTYs.
 1.44  14-Jul-2000  fvdl Don't use *(unsigned int *)data to get the signal number out; this will
fail on LP64-BE systems. Also, fix up the invalid signal number check.
 1.43  30-Mar-2000  augustss branches: 1.43.4;
Get rid of register declarations.
 1.42  11-Sep-1998  mycroft branches: 1.42.12;
Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
sys_sigpending() and sys_sigsuspend() into separate functions, and call them
from all the emulations rather than hard-coding everything. (Avoids uses
the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified. Other ports and
emulations need to be updated.
 1.41  25-Jun-1998  thorpej defopt COMPAT_SUNOS
 1.40  21-Mar-1998  mycroft Replace TS_WOPEN with t_wopen, per mail on tech-kern.
 1.39  01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38  07-Sep-1996  mycroft branches: 1.38.12;
Implement poll(2).
 1.37  05-Sep-1996  mycroft Use SET(), CLR(), ISSET().
 1.36  02-Sep-1996  mycroft tty stop functions really should return void, not int, and certainly not both.
 1.35  02-Jul-1996  pk sunos_compat: return EIO when TIOCGPGRPing a half-open pty. This is
expected by SunOS pty-allocating programs (telnetd,rlogind,..).
 1.34  29-May-1996  mrg impliment ttylist stats based on disk stats.
 1.33  30-Mar-1996  christos branches: 1.33.4;
Eliminate kern_conf.h
 1.32  09-Feb-1996  christos More proto fixes
 1.31  04-Feb-1996  christos First pass at prototyping
 1.30  10-Oct-1995  mycroft Add hooks for COMPAT_FREEBSD, from Noriyuki Soda.
 1.29  19-Apr-1995  mycroft Rename pttty() to ptytty() to mimic ptyioctl().
 1.28  19-Apr-1995  mycroft Fix typo.
 1.27  19-Apr-1995  mycroft Implement pttty(), and rename pt_ioctl to pt_softc.
 1.26  14-Dec-1994  mycroft Remove extra arg to ptcopen().
 1.25  13-Dec-1994  mycroft Fix compiler warning.
 1.24  30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.23  29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.22  12-May-1994  cgd upgrade to 4.4-Lite's tty code. our bug fixes included, some might need GC.
 1.21  05-May-1994  cgd lots of changes: prototype migration, move lots of variables, definitions,
and structure elements around. kill some unnecessary type and macro
definitions. standardize clock handling. More changes than you'd want.
 1.20  04-May-1994  cgd Rename a lot of process flags.
 1.19  25-Apr-1994  cgd kill some code that became obsolete when berknet died...
 1.18  09-Feb-1994  mycroft All ioctl routines take a struct proc * now.
 1.17  27-Jan-1994  cgd kill two patchkit bogons
 1.16  18-Dec-1993  mycroft Canonicalize all #includes.
 1.15  15-Nov-1993  deraadt add a ptyattach() function, as in magnum.
 1.14  12-Nov-1993  cgd from Mike Karels, via bsdi-users: nuking session pointer prevents cleanup.
 1.13  29-Sep-1993  cgd ifdef out the ttyfree()'s, so that fill_eproc doesn't panic when
a process's session still holds a ref to a tty which has been deallocated
and reused.
 1.12  29-Aug-1993  deraadt branches: 1.12.2;
tty XXstart() routines return void
 1.11  19-Jul-1993  mycroft branches: 1.11.2;
Move flushq() macro into tty.h.
 1.10  19-Jul-1993  mycroft Make sure there are character in the ring before flushing.
 1.9  19-Jul-1993  mycroft Use ndflush(), not while(getc()).
 1.8  12-Jul-1993  mycroft Change tty code to use clist interface, but with ring buffer implementation.
Also, fix a couple of bugs in tty.c and pccons.c, and some gross kluginess
in the hp300 stuff.
 1.7  27-Jun-1993  andrew * ansifications
* fixed the arguments given to the line discipline l_open function in
ptsopen()
* should ptsstart() return 1 if (tp->t_state & TS_TTSTOP)?
 1.6  06-Jun-1993  cgd make getc() and ungetc() be rb{un,}getc(), so getc() and ungetc()
don't conflict w/ansi prototypes...
 1.5  26-May-1993  deraadt tty dynamic allocation
 1.4  18-May-1993  cgd make kernel select interface be one-stop shopping & clean it all up.
 1.3  10-May-1993  deraadt ring buffer now uses rbchar's (shorts) instead of chars.
 1.2  21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  01-Mar-1998  fvdl Import 4.4BSD-Lite2
 1.1.1.2  01-Mar-1998  fvdl Import 4.4BSD-Lite for reference
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.2.2  19-Jul-1993  mycroft Move flushq() macro into tty.h.
 1.11.2.1  19-Jul-1993  mycroft file tty_pty.c was added on branch netbsd-0-9 on 1993-07-19 05:52:33 +0000
 1.12.2.7  14-Nov-1993  mycroft Need pty.h.
 1.12.2.6  14-Nov-1993  mycroft Canonicalize all #includes.
 1.12.2.5  12-Nov-1993  cgd merge changes from trunk
 1.12.2.4  06-Oct-1993  mycroft Merge changes from trunk.
 1.12.2.3  29-Sep-1993  mycroft init_main.c: Remove calls to startrtclock(), startkgclock(), and enablertclock().
sys_process.c: Remove profil() (now in subr_prof.c).
vfs_bio.c: Merge changes from trunk.
kern_clock.c, tty_pty.c: Trivial changes to match KNF.
 1.12.2.2  27-Sep-1993  deraadt initial empty ptyattach()
 1.12.2.1  24-Sep-1993  mycroft Make all files using spl*() #include cpu.h. Changes from trunk.
init_main.c: New method of pseudo-device of initialization.
kern_clock.c: hardclock() and softclock() now take a pointer to a clockframe.
softclock() only does callouts.
kern_synch.c: Remove spurious declaration of endtsleep(). Adjust uses of
averunnable for new struct loadav.
subr_prf.c: Allow printf() formats in panic().
tty.c: averunnable changes.
vfs_subr.c: va_size and va_bytes are now quads.
 1.33.4.2  26-Jan-1997  rat Pullup 1.34 -> 1.35. Return EIO when TIOCGPGRPing a half-open pty. This is
expected by SunOS pty-allocating programs (telnetd,rlogind,..).
 1.33.4.1  02-Jun-1996  mrg pull up tty stats "bug fix".
 1.38.12.1  08-Sep-1997  thorpej Significantly restructure the way signal state for a process is stored.
Rather than using bitmasks to redundantly store the information kept
in the process's sigacts (because the sigacts was kept in the u-area),
hang sigacts directly off the process, and access it directly.

Simplify signal setup code tremendously by storing information in
the sigacts as an array of struct sigactions, rather than in a different
format, since userspace uses sigactions.

Make sigacts sharable by adding reference counting.
 1.42.12.3  08-Dec-2000  bouyer Sync with HEAD.
 1.42.12.2  22-Nov-2000  bouyer Sync with HEAD.
 1.42.12.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.43.4.3  04-Aug-2000  mason Sync with tty_pty.c,v 1.45, requested by mason, approved by jhawk.
 1.43.4.2  29-Jul-2000  mrg pullup 1.46 (approved by thorpej):
>fix rev 1.44; make this cast look like:
> sig = (int)(long)*(caddr_t *)data;
>to *properly* dereference the passed data. this makes signals on
>ptys actually *work* on the sparc64 port. from mycroft.
 1.43.4.1  20-Jul-2000  fvdl Pull up version 1.44 from trunk: fix an LP64-BE problem with TIOCSIG,
and a faulty bounds check for the argument.
 1.55.2.11  11-Dec-2002  thorpej Sync with HEAD.
 1.55.2.10  11-Nov-2002  nathanw Catch up to -current
 1.55.2.9  18-Oct-2002  nathanw Catch up to -current.
 1.55.2.8  17-Sep-2002  nathanw Catch up to -current.
 1.55.2.7  12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.55.2.6  24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.55.2.5  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.55.2.4  28-Feb-2002  nathanw Catch up to -current.
 1.55.2.3  14-Nov-2001  nathanw Catch up to -current.
 1.55.2.2  21-Jun-2001  nathanw Catch up to -current.
 1.55.2.1  05-Mar-2001  nathanw Initial commit of scheduler activations and lightweight process support.
 1.56.6.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.56.4.3  13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.56.4.2  26-Sep-2001  fvdl * add a VCLONED vnode flag that indicates a vnode representing a cloned
device.
* rename REVOKEALL to REVOKEALIAS, and add a REVOKECLONE flag, to pass
to VOP_REVOKE
* the revoke system call will revoke all aliases, as before, but not the
clones
* vdevgone is called when detaching a device, so make it use REVOKECLONE
to get rid of all clones as well
* clean up all uses of VOP_OPEN wrt. locking.
* add a few VOPS to spec_vnops that need to do something when it's a
clone vnode (access and getattr)
* add a copy of the vnode vattr structure of the original 'master' vnode
to the specinfo of a cloned vnode. could possibly redirect getattr to
the 'master' vnode, but this has issues with revoke
* add a vdev_reassignvp function that disassociates a vnode from its
original device, and reassociates it with the specified dev_t. to be
used by cloning devices only, in case a new minor is allocated.
* change all direct references in drivers to v_devcookie and v_rdev
to vdev_privdata(vp) and vdev_rdev(vp). for diagnostic purposes
when debugging race conditions that still exist wrt. locking and
revoking vnodes.
* make the locking state of a vnode consistent when passed to
d_open and d_close (unlocked). locked would be better, but has
some deadlock issues
 1.56.4.1  07-Sep-2001  thorpej Commit my "devvp" changes to the thorpej-devvp branch. This
replaces the use of dev_t in most places with a struct vnode *.

This will form the basic infrastructure for real cloning device
support (besides being architecurally cleaner -- it'll be good
to get away from using numbers to represent objects).
 1.56.2.9  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.56.2.8  29-Sep-2002  jdolecek drop (caddr_t) and (void *) casts for kn_hook
 1.56.2.7  24-Sep-2002  jdolecek so the one-off difference was caused by having flags ONLCR and IGNCR
set for the master side of pty, so 'normal behaviour'

this also means the 'data' value returned for EVFILT_READ kevent(2)
is only approximation, but still useful as hint
 1.56.2.6  24-Sep-2002  jdolecek implement ptckqfilter() and remove the #define from <sys/conf.h>
convert selwakeup() calls in tty_pty.c to selnotify()
hint: if there is unique poll routine, unique kqfilter is needed too

this makes EVFILT_READ and EVFILT_WRITE events working on the master
side of pty

XXX EVFILT_READ would report 'data' exactly one more than the actual
XXX amount of data available; need to find out why
 1.56.2.5  24-Sep-2002  jdolecek pullup rev. 1.64:
check_pty(): make sure to zero the newly allocated pt_softc structure

uninitialized struct selinfo caused panics in selnotify() here
 1.56.2.4  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.56.2.3  16-Mar-2002  jdolecek Catch up with -current.
 1.56.2.2  11-Feb-2002  jdolecek Sync w/ -current.
 1.56.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.62.2.1  16-May-2002  gehenna Add the character device switch.
 1.70.2.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.70.2.7  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.70.2.6  29-Nov-2004  skrll Sync with HEAD.
 1.70.2.5  14-Nov-2004  skrll Sync with HEAD.
 1.70.2.4  21-Sep-2004  skrll Fix the sync with head I botched.
 1.70.2.3  18-Sep-2004  skrll Sync with HEAD.
 1.70.2.2  03-Aug-2004  skrll Sync with HEAD
 1.70.2.1  02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.82.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.82.4.1  29-Apr-2005  kent sync with -current
 1.85.2.8  17-Mar-2008  yamt sync with head.
 1.85.2.7  21-Jan-2008  yamt sync with head
 1.85.2.6  07-Dec-2007  yamt sync with head
 1.85.2.5  15-Nov-2007  yamt sync with head.
 1.85.2.4  03-Sep-2007  yamt sync with head.
 1.85.2.3  26-Feb-2007  yamt sync with head.
 1.85.2.2  30-Dec-2006  yamt sync with head.
 1.85.2.1  21-Jun-2006  yamt sync with head.
 1.86.8.4  11-Aug-2006  yamt sync with head
 1.86.8.3  26-Jun-2006  yamt sync with head.
 1.86.8.2  24-May-2006  yamt sync with head.
 1.86.8.1  13-Mar-2006  yamt sync with head.
 1.86.6.3  03-Jun-2006  kardel Sync with head.
 1.86.6.2  01-Jun-2006  kardel Sync with head.
 1.86.6.1  22-Apr-2006  simonb Sync with head.
 1.86.4.1  09-Sep-2006  rpaulo sync with head
 1.87.4.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.87.2.3  06-May-2006  christos - Move kauth_cred_t declaration to <sys/types.h>
- Cleanup struct ucred; forward declarations that are unused.
- Don't include <sys/kauth.h> in any header, but include it in the c files
that need it.

Approved by core.
 1.87.2.2  19-Apr-2006  elad sync with head.
 1.87.2.1  08-Mar-2006  elad Adapt to kernel authorization KPI.
 1.89.2.1  19-Jun-2006  chap Sync with head.
 1.93.6.2  10-Dec-2006  yamt sync with head.
 1.93.6.1  22-Oct-2006  yamt sync with head
 1.93.4.5  12-Jan-2007  ad Sync with head.
 1.93.4.4  29-Dec-2006  ad Checkpoint work in progress.
 1.93.4.3  18-Nov-2006  ad Sync with head.
 1.93.4.2  17-Nov-2006  ad Checkpoint work in progress.
 1.93.4.1  21-Oct-2006  ad Checkpoint work in progress on locking and per-LWP signals. Very much a
a work in progress and there is still a lot to do.
 1.98.2.3  07-May-2007  yamt sync with head.
 1.98.2.2  24-Mar-2007  yamt sync with head.
 1.98.2.1  12-Mar-2007  rmind Sync with HEAD.
 1.99.4.1  11-Jul-2007  mjf Sync with head.
 1.99.2.4  19-Oct-2007  ad In the tty code, defer posting singals to a soft interrupt. Avoids
touching process state from a hardware interrupt, and avoids locking
problems (tty_lock is always held when the signals are sent).
 1.99.2.3  19-Oct-2007  ad Replace the tty locks with a global tty_lock.
 1.99.2.2  21-Mar-2007  ad - Replace more simple_locks, and fix up in a few places.
- Use condition variables.
- LOCK_ASSERT -> KASSERT.
 1.99.2.1  13-Mar-2007  ad Sync with head.
 1.101.14.4  18-Feb-2008  mjf Sync with HEAD.
 1.101.14.3  27-Dec-2007  mjf Sync with HEAD.
 1.101.14.2  08-Dec-2007  mjf Sync with HEAD.
 1.101.14.1  19-Nov-2007  mjf Sync with HEAD.
 1.101.12.2  21-Nov-2007  bouyer Sync with HEAD
 1.101.12.1  13-Nov-2007  bouyer Sync with HEAD
 1.101.8.3  23-Mar-2008  matt sync with HEAD
 1.101.8.2  09-Jan-2008  matt sync with HEAD
 1.101.8.1  08-Nov-2007  matt sync with -HEAD
 1.101.6.3  09-Dec-2007  jmcneill Sync with HEAD.
 1.101.6.2  21-Nov-2007  joerg Sync with HEAD.
 1.101.6.1  11-Nov-2007  joerg Sync with HEAD.
 1.104.2.3  30-Dec-2007  ad Avoid mutex recursion with kqueue. Reported by martin@.
 1.104.2.2  26-Dec-2007  ad Sync with head.
 1.104.2.1  08-Dec-2007  ad Sync with head.
 1.105.4.1  02-Jan-2008  bouyer Sync with HEAD
 1.107.6.5  17-Jan-2009  mjf Sync with HEAD.
 1.107.6.4  28-Sep-2008  mjf Sync with HEAD.
 1.107.6.3  29-Jun-2008  mjf Sync with HEAD.
 1.107.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.107.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.107.2.1  24-Mar-2008  keiichi sync with head.
 1.108.2.3  17-Jun-2008  yamt sync with head.
 1.108.2.2  04-Jun-2008  yamt sync with head
 1.108.2.1  18-May-2008  yamt sync with head.
 1.109.4.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.109.4.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.109.2.5  09-Oct-2010  yamt sync with head
 1.109.2.4  11-Aug-2010  yamt sync with head.
 1.109.2.3  11-Mar-2010  yamt sync with head
 1.109.2.2  20-Jun-2009  yamt sync with head
 1.109.2.1  04-May-2009  yamt sync with head.
 1.110.2.1  18-Jun-2008  simonb Sync with head.
 1.111.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.111.2.1  19-Oct-2008  haad Sync with HEAD.
 1.112.6.1  17-Jun-2009  bouyer branches: 1.112.6.1.2;
Pull up following revision(s) (requested by plunky in ticket #807):
sys/kern/tty_pty.c: revision 1.117
Writes on the controlling tty were not being awoken from blocks,
use the correct condvar to make this happen.
this fixes PR/41566
 1.112.6.1.2.1  21-Apr-2010  matt sync to netbsd-5
 1.112.4.1  17-Jun-2009  bouyer Pull up following revision(s) (requested by plunky in ticket #807):
sys/kern/tty_pty.c: revision 1.117
Writes on the controlling tty were not being awoken from blocks,
use the correct condvar to make this happen.
this fixes PR/41566
 1.112.2.3  28-Apr-2009  skrll Sync with HEAD.
 1.112.2.2  03-Mar-2009  skrll Sync with HEAD.
 1.112.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.115.2.2  23-Jul-2009  jym Sync with HEAD.
 1.115.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.121.4.4  31-May-2011  rmind sync with head
 1.121.4.3  21-Apr-2011  rmind sync with head
 1.121.4.2  05-Mar-2011  rmind sync with head
 1.121.4.1  03-Jul-2010  rmind sync with head
 1.121.2.2  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.121.2.1  17-Aug-2010  uebayasi Sync with HEAD.
 1.124.2.1  06-Jun-2011  jruoho Sync with HEAD.
 1.131.12.3  03-Dec-2017  jdolecek update from HEAD
 1.131.12.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.131.12.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.131.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.131.2.1  30-Oct-2012  yamt sync with head
 1.132.2.1  18-May-2014  rmind sync with head
 1.138.2.1  10-Aug-2014  tls Rebase.
 1.141.2.1  22-Sep-2015  skrll Sync with HEAD
 1.142.10.1  01-Mar-2019  martin Pull up following revision(s) (requested by kamil in ticket #1201):

tests/kernel/kqueue/read/t_ttypty.c: revision 1.3
sys/kern/tty_pty.c: revision 1.145

Fix reporting EOF via kevent and add a test case

Fix the kernel pty driver to report closed slave via master's kevent
EVFILT_READ. This behavior matches the behavior for pipes, is
consistent with how FreeBSD implements it and is relied upon by LLDB's
main loop implementation.

Includes feedback by kre and kamil (from tech-kern), commit approved
by kamil.
 1.142.8.2  29-Apr-2017  pgoyette Remove more unnecessary #include for sys/localcount.h
 1.142.8.1  27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.142.2.7  29-Jul-2016  pgoyette Add module initializers in the pmax-specific copies of the [bc]devsw's
 1.142.2.6  29-Jul-2016  pgoyette Add a note to revisit the locking for this device.
 1.142.2.5  29-Jul-2016  pgoyette Redo previous, restoring "return xxx;" in each case of the select. This
gets the exit conditions back the way they were, and allows the atf test
kernel/t_pty to pass.
 1.142.2.4  26-Jul-2016  pgoyette Rename LOCALCOUNT_INITIALIZER to DEVSW_MODULE_INIT. This better describes
what we're doing, and why.
 1.142.2.3  20-Jul-2016  pgoyette Adapt machine-independant code to the new {b,c}devsw reference-counting
(using localcount(9)). All callers of {b,c}devsw_lookup() now call
{b,c}devsw_lookup_acquire() which retains a reference on the 'struct
{b,c}devsw'. This reference must be released by the caller once it is
finished with the structure's content (or other data that would disappear
if the 'struct {b,c}devsw' were to disappear).
 1.142.2.2  19-Jul-2016  pgoyette Instead of repeatedly typing the conditional initialization of the
.d_localcount members in the various {b,c}devsw, define an initializer
macro and use it. This also removes the need for defining new symbols
for each 'struct localcount'.

As suggested by riastradh@
 1.142.2.1  18-Jul-2016  pgoyette Rump drivers are always installed via devsw_attach() so we need to
always allocate a 'struct localcount' for these drivers whenever they
are built as modules.
 1.143.4.1  10-Jun-2019  christos Sync with HEAD
 1.143.2.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.145.12.1  14-Dec-2020  thorpej Sync w/ HEAD.

RSS XML Feed