Commit Graph

111 Commits

Author SHA1 Message Date
Eivind Eklund 5526d2d920 Split DIAGNOSTIC -> DIAGNOSTIC, INVARIANTS, and INVARIANT_SUPPORT as
discussed on -hackers.

Introduce 'KASSERT(assertion, ("panic message", args))' for simple
check + panic.

Reviewed by:	msmith
1999-01-08 17:31:30 +00:00
Bruce Evans e1501bb6eb Backed out the FIOASYNC fix in rev.1.108. fcntl(fd, F_SETFL, flags)
depends on the bug.  It does an FIOASYNC ioctl to sync the setting
of the O_ASYNC "file" flag with drivers even if the setting hasn't
changed.

PR:		9003
1998-12-08 10:22:07 +00:00
Andrey A. Chernov 8e3c23be56 Move stime declaration to main block, otherwise can left uninitialized
in rare cases.
Found by: Eivind Eklund <eivind@yes.no>
1998-12-07 07:59:20 +00:00
Bruce Evans 7dd89537f1 Fixed some missing cases in the check for ioctls that involve modification.
Many (mostly machine-dependent ones) are still missing.  NIST-PCTS found
this bug for all the ioctls used to implement the POSIX tc* functions
(TIOCCBRK, TIOCDRAIN, TIOCSPGRP, TIOCSBRK, TIOCSTART and TIOCSTOP), and
I found FIOASYNC, TIOCCONS, TIOCEXCL, TIOCHPCL, TIOCNXCL, TIOCSCTTY and
TIOCSDRAINWAIT by inspection.  TIOCSPGRP was ifdefed out for some reason.

Handle tcsetattr()'s historical speed conversions correctly and more
centrally:
- don't store speeds of 0 in the final termios struct.  Drivers can now
  depend on tp->t_ispeed and tp->t_ospeed giving the actual speed.
  Applications can now depend on tcgetattr() being POSIX.1 conformant.
- convert from a proposed input speed of 0 to the proposed output speed
  (except if that is 0, convert to the current output speed).  Drivers
  can now depend on the proposed input speed being nonzero.
- don't reject negative speeds.  Negative speeds can't happen now that
  speed_t is unsigned, and rejecting invalid speeds is a bug - tcsetattr()
  is supposed to succeed if it can "perform any of the requested actions",
  so it shouldn't fail in practice.
1998-11-22 09:04:09 +00:00
Don Lewis 831d27a9f5 Installed the second patch attached to kern/7899 with some changes suggested
by bde, a few other tweaks to get the patch to apply cleanly again and
some improvements to the comments.

This change closes some fairly minor security holes associated with
F_SETOWN, fixes a few bugs, and removes some limitations that F_SETOWN
had on tty devices.  For more details, see the description on the PR.

Because this patch increases the size of the proc and pgrp structures,
it is necessary to re-install the includes and recompile libkvm,
the vinum lkm, fstat, gcore, gdb, ipfilter, ps, top, and w.

PR:		kern/7899
Reviewed by:	bde, elvind
1998-11-11 10:04:13 +00:00
Bruce Evans 5cf40a698b A limit of 200000 for the output buffer high watermark was excessive,
since (hardware) ttys have too low a bandwidth to benefit significantly
from large buffers.  Use twice the old limit for the new-default case
and 8 times the old limit for the driver-specifies-watermark case.
Nothing uses these cases yet.

Removed related debugging code.
1998-08-19 04:01:00 +00:00
Bruce Evans 2f18a2801b Fixed printf format errors. 1998-07-11 10:45:45 +00:00
Doug Rabson ecbb00a262 This commit fixes various 64bit portability problems required for
FreeBSD/alpha.  The most significant item is to change the command
argument to ioctl functions from int to u_long.  This change brings us
inline with various other BSD versions.  Driver writers may like to
use (__FreeBSD_version == 300003) to detect this change.

The prototype FreeBSD/alpha machdep will follow in a couple of days
time.
1998-06-07 17:13:14 +00:00
Bruce Evans c8b4782815 Fixed stale references to hzto() in comments. 1998-05-17 20:08:05 +00:00
Poul-Henning Kamp 227ee8a188 Eradicate the variable "time" from the kernel, using various measures.
"time" wasn't a atomic variable, so splfoo() protection were needed
around any access to it, unless you just wanted the seconds part.

Most uses of time.tv_sec now uses the new variable time_second instead.

gettime() changed to getmicrotime(0.

Remove a couple of unneeded splfoo() protections, the new getmicrotime()
is atomic, (until Bruce sets a breakpoint in it).

A couple of places needed random data, so use read_random() instead
of mucking about with time which isn't random.

Add a new nfs_curusec() function.

Mark a couple of bogosities involving the now disappeard time variable.

Update ffs_update() to avoid the weird "== &time" checks, by fixing the
one remaining call that passwd &time as args.

Change profiling in ncr.c to use ticks instead of time.  Resolution is
the same.

Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call
hzto() which subtracts time" sequences.

Reviewed by:	bde
1998-03-30 09:56:58 +00:00
Bruce Evans 0b8a3ff790 Set the input and output buffer sizes and the input buffer watermarks
dynamically depending on the line speed(s).  This should give the old
sizes and watermarks until drivers are changed.

Display the input watermarks in pstat and sicontrol.
1998-03-07 15:36:29 +00:00
Eivind Eklund 5591b823d1 Make COMPAT_43 and COMPAT_SUNOS new-style options. 1997-12-16 17:40:42 +00:00
Bruce Evans 239b7b699e Use ENOIOCTL instead of -1 (= ERESTART) for tty ioctls that are
not handled at a particular level.  This fixes mainly restarting
of interrupted TIOCDRAINs and TIOCSETA{W,F}s.
1997-12-06 13:25:01 +00:00
Poul-Henning Kamp 4a11ca4e29 Remove a bunch of variables which were unused both in GENERIC and LINT.
Found by:	-Wunused
1997-11-07 08:53:44 +00:00
Poul-Henning Kamp a1c995b626 Last major round (Unless Bruce thinks of somthing :-) of malloc changes.
Distribute all but the most fundamental malloc types.  This time I also
remembered the trick to making things static:  Put "static" in front of
them.

A couple of finer points by:	bde
1997-10-12 20:26:33 +00:00
Peter Wemm 6183953301 Extend to use poll backend. If memory serves correctly, most of this was
adapted from NetBSD..  However, there are some differences in the tty
system that are big enough to cause their code to not fit comfortably.

Obtained from:  NetBSD (I think)
1997-09-14 02:40:46 +00:00
Bruce Evans e4ba6a82b0 Removed unused #includes. 1997-09-02 20:06:59 +00:00
Bruce Evans afd2f6c218 Don't include <sys/ioctl.h> in the kernel. Stage 5: include
<sys/ioctl_compat.h> and sometimes <sys/filio.h> instead of
<sys/ioctl.h> in tty-related files.  <sys/ttycom.h> is still
usually imported bogusly via <sys/termios.h>.
1997-03-24 12:03:06 +00:00
Bruce Evans 3ac4d1ef0c Don't #include <sys/fcntl.h> in <sys/file.h> if KERNEL is defined.
Fixed everything that depended on getting fcntl.h stuff from the wrong
place.  Most things don't depend on file.h stuff at all.
1997-03-23 03:37:54 +00:00
Bruce Evans 3c81694426 Fixed some invalid (non-atomic) accesses to `time', mostly ones of the
form `tv = time'.  Use a new function gettime().  The current version
just forces atomicicity without fixing precision or efficiency bugs.
Simplified some related valid accesses by using the central function.
1997-03-22 06:53:45 +00:00
Peter Wemm 6875d25465 Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.
1997-02-22 09:48:43 +00:00
John Dyson 996c772f58 This is the kernel Lite/2 commit. There are some requisite userland
changes, so don't expect to be able to run the kernel as-is (very well)
without the appropriate Lite/2 userland changes.

The system boots and can mount UFS filesystems.

Untested: ext2fs, msdosfs, NFS
Known problems: Incorrect Berkeley ID strings in some files.
		Mount_std mounts will not work until the getfsent
		library routine is changed.

Reviewed by:	various people
Submitted by:	Jeffery Hsu <hsu@freebsd.org>
1997-02-10 02:22:35 +00:00
Jordan K. Hubbard 1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Bruce Evans 63f3c673f6 Help broken d_stop() routines by flushing the output queue before
calling them (as well as after).

Found by:	NIST PCTS
1996-11-29 16:16:47 +00:00
Bruce Evans 8be1cbf1f4 Fixed bugs handling (background) orphaned process groups. tty
writes and tty ioctls by processes in such groups must return
-1/EIO, but they were allowed.  tty reads were handled correctly.

Found by:	NIST PCTS
1996-11-29 15:50:56 +00:00
Bruce Evans 7542ee31b8 Fixed some bugs in BREAK handling. If BRKINT is set, then always flush
the queues and generate a SIGINT.  Previously, this wasn't done if ISIG
was clear or the VINTR character was disabled, and it was done by
converting the BREAK to a VINTR character and sometimes bogusly echoing
this character.

Found by:	NIST-PCTS
1996-11-29 15:23:42 +00:00
Bruce Evans c02039bc20 Fixed handling of non-POSIX control characters. They must not do
anything special unless IEXTEN is set.

Found by:	NIST-PCTS
1996-11-29 15:06:17 +00:00
Bruce Evans e0c95ed947 Fixed the easy cases of const poisoning in the kernel. Cosmetic. 1996-08-31 16:52:44 +00:00
Bruce Evans 14c0cc3d51 Fixed a wrong comment. Did tsleep() ever return the networking errno
ETIMEDOUT?
1996-08-28 18:45:09 +00:00
Gary Palmer c23670e294 Clean up -Wunused warnings.
Reviewed by:		bde
1996-06-12 05:11:41 +00:00
Poul-Henning Kamp e911eafcba removed:
CLBYTES PD_SHIFT PGSHIFT NBPG PGOFSET CLSIZELOG2 CLSIZE pdei()
        ptei() kvtopte() ptetov() ispt() ptetoav() &c &c
new:
        NPDEPG

Major macro cleanup.
1996-05-02 14:21:14 +00:00
Jeffrey Hsu b75356e1ac From Lite2: proc LIST changes.
Reviewed by:	david & bde
1996-03-11 06:05:03 +00:00
Peter Wemm 4bd4912865 Add more options into the conf/options and i386/conf/options.i386 files
and the #include hooks so that 'make depend' is more useful.  This
covers most of the options I regularly use (but not all) and some other
easy ones.
1996-03-02 18:24:13 +00:00
Bruce Evans 6a1441a3e6 Oops, the last commit missed one change from 200 to OBUFSIZ + 100. 1995-12-16 21:45:02 +00:00
Bruce Evans 247b53374b Changed the maximum output queue count from (TTMAXHIWAT + 200) to
(TTMAXHIWAT + OBUFSIZ + 100) in case someone changes OBUFSIZ.  200
was to allow 100 above high water for ordinary writes and another
100 for kernel printfs.

Increased the reserved output queue count from 512 to the maximum
output queue count.  This prevents exhaustion of clists and increases
the output throughput for 8 cy lines by almost a factor of 2 (on
a system where there aren't many other open ttys so clists become
exhausted after about 4 active lines (or earlier if TTMAXHIWAT is
increased :-]).

ttwrite() behaves very badly when clists are exhausted:
(1) it sleeps on lbolt instead of on TSA_OLOWAT(tp).
    This could be fixed adequately by sleeping on TSA_OLOWAT(tp).
    The nonzero reserved count guaratees that space will become
    available independent of other ttys, and a reserved count
    of 512 is barely enough for efficiency.
(2) it drops output if space runs out in the middle of special
    output processing.  This is too hard to fix without hardening
    the reserved count.  The watermark processing guarantees that
    space doesn't run out only if the advertised space is guaranteed.

Increasing the reserved output queue count defeats the point of
dynamic allocation of clists.  Previously, about 2K of memory per
tty was reserved (the raw queue was already reserved).  Now, about
3.5K is reserved.  Reserving everything would take a whole 0.5K
more.
1995-12-15 02:18:06 +00:00
Bruce Evans a59db23b94 Disabled the sleep in ttyflush(). It can't work in general because
ttyflush() might be called from an interrupt handler.  This fixes
panics in IXOFF mode at the cost of more failures to send the START
character to exit from IXOFF mode.
1995-12-15 01:01:00 +00:00
Bruce Evans 947803d7d8 Restored unused function ttrstrt(). It would be used if the low level
drivers supported inter-character delays.
1995-12-14 22:32:52 +00:00
Poul-Henning Kamp 87b6de2b76 A Major staticize sweep. Generates a couple of warnings that I'll deal
with later.
A number of unused vars removed.
A number of unused procs removed or #ifdefed.
1995-12-14 08:32:45 +00:00
Julian Elischer 6ba9ebce28 devsw tables are now arrays of POINTERS to struct [cb]devsw
seems to work hre just fine though  I can't check every file
that changed due to limmited h/w, however I've checked enught to be petty
happy withe hte code..

WARNING... struct lkm[mumble] has changed
so it might be an idea to recompile any lkm related programs
1995-12-13 15:13:57 +00:00
David Greenman efeaf95a41 Untangled the vm.h include file spaghetti. 1995-12-07 12:48:31 +00:00
Bruce Evans bb1140a9a5 Fixed initialization of TS_CONNECTED bit in t_state. It wasn't
set in open() when CLOCAL is set unless carrier is present.

Fixed initialization of line discipline.  It lived across opens.
Lines that started with the wrong discipline probably didn't work
at all, because TS_ISOPEN is only set by TTYDISC.
1995-10-31 19:27:50 +00:00
Bruce Evans e7c89b42c5 Fix wakeups for TIOCDRAINWAIT. The conditional wakeups introduced in rev
1.59 defeated the point of doing the wakeups (having reduced timeouts
take effect immediately).
1995-09-10 11:48:13 +00:00
Andrey A. Chernov af2a00bbbc Check for valid speed values in pty drive
Check for negative speed values in tty drive
Back out valid speed values checking from tty drive
Suggested by: bde
1995-08-02 06:55:36 +00:00
Andrey A. Chernov 271381b3b8 Optimize a bit valid speed search using fact that speed table sorted
Submitted by:
Obtained from:
1995-08-01 23:38:00 +00:00
Andrey A. Chernov 7a82fc7855 Check for valid speeds in TIOCSET* and return EINVAL for incorrect
values instead of setting garbadge.
1995-08-01 23:27:36 +00:00
Bruce Evans 19829865ca Obtained from: partly from ancient patches of mine via 1.1.5
Change all short variables in `struct tty' to int.  Shorts were only
right on ancient systems with ints optimized for vaxness over
efficiency.
1995-07-31 22:50:08 +00:00
Bruce Evans 35b46c174c Obtained from: partly from ancient patches of mine via 1.1.5
Handle MDMBUF a little better.  Prepare to handle 4 different kinds of
output flow control.
1995-07-31 22:48:46 +00:00
Bruce Evans f91307e23d Obtained from: an ancient patch of mine via 1.1.5
Clear PENDIN when input is flushed so that the handling of future input
doesn't get pessimized.
1995-07-31 21:43:37 +00:00
Bruce Evans 9fa18570a2 Obtained from: partly from ancient patches of mine via 1.1.5
Introduce TS_CONNECTED and TS_ZOMBIE states.  TS_CONNECTED is set
while a connection is established.  It is set while (TS_CARR_ON or
CLOCAL is set) and TS_ZOMBIE is clear.  TS_ZOMBIE is set for on to
off transitions of TS_CARR_ON that occur when CLOCAL is clear and
is cleared for off to on transitions of CLOCAL.  I/o can only occur
while TS_CONNECTED is set.  TS_ZOMBIE prevents further i/o.

Split the input-event sleep address TSA_CARR_ON(tp) into TSA_CARR_ON(tp)
and TSA_HUP_OR_INPUT(tp).  The former address is now used only for
off to on carrier transitions and equivalent CLOCAL transitions.
The latter is used for all input events, all carrier transitions
and certain CLOCAL transitions.  There are some harmless extra
wakeups for rare connection- related events.  Previously there were
too many extra wakeups for non-rare input events.

Drivers now call l_modem() instead of setting TS_CARR_ON directly
to handle even the initial off to on transition of carrier.  They
should always have done this.  l_modem() now handles TS_CONNECTED
and TS_ZOMBIE as well as TS_CARR_ON.

gnu/isdn/iitty.c:
Set TS_CONNECTED for first open ourself to go with bogusly setting
CLOCAL.

i386/isa/syscons.c, i386/isa/pcvt/pcvt_drv.c:
We fake carrier, so don't also fake CLOCAL.

kern/tty.c:
Testing TS_CONNECTED instead of TS_CARR_ON fixes TIOCCONS forgetting to
test CLOCAL.  TS_ISOPEN was tested instead, but that broke when we disabled
the clearing of TS_ISOPEN for certain transitions of CLOCAL.

Testing TS_CONNECTED fixes ttyselect() returning false success for output
to devices in state !TS_CARR_ON && !CLOCAL.

Optimize the other selwakeup() call (this is not related to the other
changes).

kern/tty_pty.c:
ptcopen() can be declared in traditional C now that dev_t isn't short.
1995-07-31 21:02:00 +00:00
Bruce Evans 177af312cd Assorted cosmetic changes:
Make more functions static.

tty.c:
Use tcflag_t (u_long) and cc_t instead of u_char and int/long.

Don't record values that are only evaluated once.

Compare ints using imin(), not min().  min() is for comparing u_ints.
Old versions of tty.c used the type-safe but multiple-evaluation-unsafe
macro MIN().  The args are apparently never negative; otherwise this
change would be non-cosmetic.

Don't repeat the loop test in ttywait().

tty.h:
Improve English in and formatting of comments.
1995-07-31 19:17:19 +00:00