Index: sys/compat/linux/linux_file.c =================================================================== --- sys/compat/linux/linux_file.c +++ sys/compat/linux/linux_file.c @@ -235,10 +235,42 @@ } #endif +static bool +linux_fd_is_tty(struct thread *td, int fd) +{ + struct file *fp; + struct vnode *vp; + int error; + bool is_tty; + + error = fget(td, fd, &cap_no_rights, &fp); + if (error != 0) + return (false); + + if (fp->f_type != DTYPE_VNODE || fp->f_vnode->v_type != VCHR) { + fdrop(fp, td); + return (false); + } + + vp = fp->f_vnode; + dev_lock(); + if (vp->v_rdev != NULL && (vp->v_rdev->si_devsw->d_flags & D_TTY) != 0) + is_tty = true; + else + is_tty = false; + dev_unlock(); + fdrop(fp, td); + + return (is_tty); +} + int linux_lseek(struct thread *td, struct linux_lseek_args *args) { + if (linux_fd_is_tty(td, args->fdes)) + return (ESPIPE); + return (kern_lseek(td, args->fdes, args->off, args->whence)); } @@ -248,6 +280,9 @@ { int error; off_t off; + + if (linux_fd_is_tty(td, args->fd)) + return (ESPIPE); off = (args->olow) | (((off_t) args->ohigh) << 32);