+ * Sets the tty state to not allow any more changes of foreground process
+ * group. This is required to be done so that a subsequent revoke on a vnode
+ * is able to always successfully complete.
+ *
+ * Locks : Assumes tty_lock held on entry
+ */
+void
+ttysetpgrphup(struct tty *tp)
+{
+ TTY_LOCK_OWNED(tp); /* debug assert */
+ SET(tp->t_state, TS_PGRPHUP);
+}
+
+/*
+ * Locks : Assumes tty lock held on entry
+ */
+void
+ttyclrpgrphup(struct tty *tp)
+{
+ TTY_LOCK_OWNED(tp); /* debug assert */
+ CLR(tp->t_state, TS_PGRPHUP);
+}
+
+/*
+ * ttioctl
+ *
+ * Identical to ttioctl_locked, only the lock is not held
+ *
+ * Parameters: <See ttioctl_locked()>
+ *
+ * Returns: <See ttioctl_locked()>
+ *
+ * Locks: This function assumes the tty_lock() is not held on entry;
+ * it takes the lock, and releases it before returning.
+ *
+ * Notes: This is supported to ensure the line discipline interfaces
+ * all have the same locking semantics.
+ *
+ * This function is called from
+ */
+int
+ttioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, proc_t p)
+{
+ int retval;
+
+ tty_lock(tp);
+ retval = ttioctl_locked(tp, cmd, data, flag, p);
+ tty_unlock(tp);
+
+ return (retval);
+}
+
+
+/*
+ * ttioctl_locked
+ *
+ * Ioctls for all tty devices.
+ *
+ * Parameters: tp Tty on which ioctl() is being called
+ * cmd ioctl() command parameter
+ * data ioctl() data argument (if any)
+ * flag fileglob open modes from fcntl.h;
+ * if called internally, this is usually
+ * set to 0, rather than something useful
+ * p Process context for the call; if the
+ * call is proxied to a worker thread,
+ * this will not be the current process!!!
+ *
+ * Returns: 0 Success
+ * EIO I/O error (no process group, job
+ * control, etc.)
+ * EINTR Interrupted by signal
+ * EBUSY Attempt to become the console while
+ * the console is busy
+ * ENOTTY TIOCGPGRP on a non-controlling tty
+ * EINVAL Invalid baud rate
+ * ENXIO TIOCSETD of invalid line discipline
+ * EPERM TIOCSTI, not root, not open for read
+ * EACCES TIOCSTI, not root, not your controlling
+ * tty
+ * EPERM TIOCSCTTY failed
+ * ENOTTY/EINVAL/EPERM TIOCSPGRP failed
+ * EPERM TIOCSDRAINWAIT as non-root user
+ * suser:EPERM Console control denied
+ * ttywait:EIO t_timeout too small/expired
+ * ttywait:ERESTART Upper layer must redrive the call;
+ * this is usually done by the Libc
+ * stub in user space
+ * ttywait:EINTR Interrupted (usually a signal)
+ * ttcompat:EINVAL
+ * ttcompat:ENOTTY
+ * ttcompat:EIOCTL
+ * ttcompat:ENOTTY TIOCGSID, if no session or session
+ * leader
+ * ttcompat:ENOTTY All unrecognized ioctls
+ * *tp->t_param:? TIOCSETA* underlying function
+ * *linesw[t].l_open:? TIOCSETD line discipline open failure
+ *
+ *
+ * Locks: This function assumes that the tty_lock() is held for the
+ * tp at the time of the call. The lock remains held on return.
+ *
+ * Notes: This function is called after line-discipline specific ioctl
+ * has been called to do discipline-specific functions and/or
+ * reject any of these ioctl() commands.
+ *
+ * This function calls ttcompat(), which can re-call ttioctl()
+ * to a depth of one (FORTRAN style mutual recursion); at some
+ * point, we should just in-line ttcompat() here.