MFC various commits back to stable/8:

SVN r197174:
  Make sure we never place the cursor outside the screen.

  For some vague reason, it may be possible that scp->cursor_pos exceeds
  scp->ysize * scp->xsize. This means that teken_set_cursor() may get
  called with an invalid position. Just ignore the old cursor position in
  this case.

  Reported by:  Paul B. Mahol <onemda gmail com>

SVN r198213:
  Make lock devices work properly.

  It turned out I did add the code to use the init state devices to set
  the termios structure when opening the device, but it seems I totally
  forgot to add the bits required to force the actual locking of flags
  through the lock state devices.

  Reported by:	ru

SVN r198215, r198217:
  Fix a typo in the jail(8) manpage.

  Submitted by: Jille Timmermans <jille quis cx>

SVN r198216:
  Fix qouting in a comment, to make it look more consistent

  Submitted by: Jille Timmermans <jille quis cx>

SVN r198223:
  Properly set the low watermarks when reducing the baud rate.

  Now that buffers are deallocated lazily, we should not use
  tty*q_getsize() to obtain the buffer size to calculate the low
  watermarks. Doing this may cause the watermark to be placed outside the
  typical buffer size.

  This caused some regressions after my previous commit to the TTY code,
  which allows pseudo-devices to resize the buffers as well.

  Reported by:  yongari, dougb
This commit is contained in:
Ed Schouten 2009-11-01 10:30:30 +00:00
parent 5d933cfd98
commit f36e7051c7
5 changed files with 53 additions and 8 deletions

View File

@ -565,7 +565,7 @@ run_rc_command()
rc_fast=yes
rc_quiet=yes
;;
force*) # "force prefix; always run
force*) # "force" prefix; always run
rc_force=yes
_rc_prefix=force
rc_arg=${rc_arg#${_rc_prefix}}

View File

@ -130,9 +130,12 @@ scteken_init(scr_stat *scp, void **softc, int code)
tp.tp_col = scp->xsize;
teken_set_winsize(&ts->ts_teken, &tp);
tp.tp_row = scp->cursor_pos / scp->xsize;
tp.tp_col = scp->cursor_pos % scp->xsize;
teken_set_cursor(&ts->ts_teken, &tp);
if (scp->cursor_pos < scp->ysize * scp->xsize) {
/* Valid old cursor position. */
tp.tp_row = scp->cursor_pos / scp->xsize;
tp.tp_col = scp->cursor_pos % scp->xsize;
teken_set_cursor(&ts->ts_teken, &tp);
}
break;
}

View File

@ -109,14 +109,14 @@ tty_watermarks(struct tty *tp)
ttyinq_setsize(&tp->t_inq, tp, bs);
/* Set low watermark at 10% (when 90% is available). */
tp->t_inlow = (ttyinq_getsize(&tp->t_inq) * 9) / 10;
tp->t_inlow = (ttyinq_getallocatedsize(&tp->t_inq) * 9) / 10;
/* Provide an ouput buffer for 0.2 seconds of data. */
bs = MIN(tp->t_termios.c_ospeed / 5, TTYBUF_MAX);
ttyoutq_setsize(&tp->t_outq, tp, bs);
/* Set low watermark at 10% (when 90% is available). */
tp->t_outlow = (ttyoutq_getsize(&tp->t_outq) * 9) / 10;
tp->t_outlow = (ttyoutq_getallocatedsize(&tp->t_outq) * 9) / 10;
}
static int
@ -523,6 +523,34 @@ ttydev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
goto done;
}
if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
struct termios *old = &tp->t_termios;
struct termios *new = (struct termios *)data;
struct termios *lock = TTY_CALLOUT(tp, dev) ?
&tp->t_termios_lock_out : &tp->t_termios_lock_in;
int cc;
/*
* Lock state devices. Just overwrite the values of the
* commands that are currently in use.
*/
new->c_iflag = (old->c_iflag & lock->c_iflag) |
(new->c_iflag & ~lock->c_iflag);
new->c_oflag = (old->c_oflag & lock->c_oflag) |
(new->c_oflag & ~lock->c_oflag);
new->c_cflag = (old->c_cflag & lock->c_cflag) |
(new->c_cflag & ~lock->c_cflag);
new->c_lflag = (old->c_lflag & lock->c_lflag) |
(new->c_lflag & ~lock->c_lflag);
for (cc = 0; cc < NCCS; ++cc)
if (lock->c_cc[cc])
new->c_cc[cc] = old->c_cc[cc];
if (lock->c_ispeed)
new->c_ispeed = old->c_ispeed;
if (lock->c_ospeed)
new->c_ospeed = old->c_ospeed;
}
error = tty_ioctl(tp, cmd, data, td);
done: tty_unlock(tp);

View File

@ -92,6 +92,13 @@ ttyinq_getsize(struct ttyinq *ti)
return (ti->ti_nblocks * TTYINQ_DATASIZE);
}
static __inline size_t
ttyinq_getallocatedsize(struct ttyinq *ti)
{
return (ti->ti_quota * TTYINQ_DATASIZE);
}
static __inline size_t
ttyinq_bytesleft(struct ttyinq *ti)
{
@ -142,6 +149,13 @@ ttyoutq_getsize(struct ttyoutq *to)
return (to->to_nblocks * TTYOUTQ_DATASIZE);
}
static __inline size_t
ttyoutq_getallocatedsize(struct ttyoutq *to)
{
return (to->to_quota * TTYOUTQ_DATASIZE);
}
static __inline size_t
ttyoutq_bytesleft(struct ttyoutq *to)
{

View File

@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 25, 2009
.Dd October 18, 2009
.Dt JAIL 8
.Os
.Sh NAME
@ -377,7 +377,7 @@ Since raw sockets can be used to configure and interact with various
network subsystems, extra caution should be used where privileged access
to jails is given out to untrusted parties.
.It Va allow.chflags
Normally, priveleged users inside a jail are treated as unprivileged by
Normally, privileged users inside a jail are treated as unprivileged by
.Xr chflags 2 .
When this parameter is set, such users are treated as privileged, and
may manipulate system file flags subject to the usual constraints on