Skip site navigation (1)Skip section navigation (2)
Date:      Sat,  2 Feb 2008 12:15:18 +0100 (CET)
From:      Ed Schouten <ed@fxq.nl>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/120215: [Patch] Remove exposure of the sgtty interface
Message-ID:  <20080202111518.757E81CC4E@palm.hoeg.nl>
Resent-Message-ID: <200802021120.m12BK1Lx087831@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         120215
>Category:       kern
>Synopsis:       [Patch] Remove exposure of the sgtty interface
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 02 11:20:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Ed Schouten
>Release:        FreeBSD 8.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD xbox.fxq.nl 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Wed Jan 2 00:57:21 CET 2008 ed@xbox.fxq.nl:/usr/obj/usr/src/sys/FXQXBOX i386
>Description:
As of this month I am going to work on improving FreeBSD's TTY layer in
areas like performance, stability and usability, especially for this
modern era where we use more pseudo terminals than physical ones.

The FreeBSD kernel still exposes the outdated interface called sgtty,
which allows you to obtain certain parameters which describe the
behaviour of the terminal. This interface has been replaced by termios a
very long time ago and a lot of applications use this interface. When
the FreeBSD project started, the sgtty interface was already marked as
outdated.

The last year I've been working on removing the usage of sgtty from all
the ports that are in the FreeBSD Ports tree. I have succeeded in this,
which means the sgtty interface can now be removed as a programming
interface, with very minor breakage. This means that existing binaries
will still work if you enable the COMPAT_43TTY kernel option, but cannot
be compiled against this interface anymore.

I would really appreciate it if this patch would hit the tree soon,
because by the time my work on the TTY layer is finished, we could
decide whether the improved TTY implementation should support this
interface at all.
>How-To-Repeat:
>Fix:
Apply the attached patch. Be sure to remove the following files
afterwards:

 - src/lib/libcompat/4.1/gtty.c
 - src/lib/libcompat/4.1/stty.3
 - src/lib/libcompat/4.1/stty.c
 - src/sys/sys/ttychars.h
 - src/sys/sys/ttydev.h


--- src/include/sgtty.h	2008-01-28 21:55:38.000000000 +0100
+++ src/include/sgtty.h	2008-01-28 21:57:43.000000000 +0100
@@ -1,39 +1,3 @@
-/*
- * Copyright (c) 1985, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)sgtty.h	8.1 (Berkeley) 6/2/93
- */
-
-#ifndef USE_OLD_TTY
-#define	USE_OLD_TTY
-#endif
-#include <sys/ioctl.h>
+/* $FreeBSD$ */
+#error "The sgtty interface has been replaced by termios(4)"
+#error "Try to use <sys/ioctl.h> or migrate to <termios.h>"
--- src/lib/libcompat/Makefile	2008-01-28 21:55:44.000000000 +0100
+++ src/lib/libcompat/Makefile	2008-01-28 21:58:21.000000000 +0100
@@ -12,12 +12,11 @@
 
 # compat 4.1 sources
 # XXX MISSING:	tell.c
-SRCS+=	ascftime.c cftime.c ftime.c getpw.c gtty.c stty.c
+SRCS+=	ascftime.c cftime.c ftime.c getpw.c
 
-MAN+=	4.1/ftime.3 4.1/getpw.3 4.1/stty.3
+MAN+=	4.1/ftime.3 4.1/getpw.3
 MAN+=	4.1/cftime.3
 
-MLINKS+=stty.3 gtty.3
 MLINKS+=cftime.3 ascftime.3
 
 # compat 4.3 sources
--- src/sys/sys/ioctl.h	2008-01-28 21:54:25.000000000 +0100
+++ src/sys/sys/ioctl.h	2008-01-28 21:58:54.000000000 +0100
@@ -69,14 +69,3 @@
 #include <sys/sockio.h>
 
 #endif /* !_SYS_IOCTL_H_ */
-
-/*
- * Keep outside _SYS_IOCTL_H_
- * Compatibility with old terminal driver
- *
- * Source level -> #define USE_OLD_TTY
- * Kernel level -> options COMPAT_43TTY
- */
-#if defined(USE_OLD_TTY) || defined(COMPAT_43TTY)
-#include <sys/ioctl_compat.h>
-#endif
--- src/sys/sys/ioctl_compat.h	2008-01-28 21:54:25.000000000 +0100
+++ src/sys/sys/ioctl_compat.h	2008-01-28 22:41:38.000000000 +0100
@@ -38,11 +38,9 @@
 #ifndef _SYS_IOCTL_COMPAT_H_
 #define	_SYS_IOCTL_COMPAT_H_
 
-#include <sys/ttychars.h>
-#include <sys/ttydev.h>
-
-#ifdef USE_OLD_TTY
-#warning "Old BSD tty API used and depends on COMPAT_43TTY. Use termios.h instead"
+#ifdef _KERNEL
+#ifndef COMPAT_43TTY
+#error "only to be used within the TTY compatibility layer"
 #endif
 
 struct tchars {
@@ -77,15 +75,8 @@
 };
 #endif
 
-#ifdef USE_OLD_TTY
-# undef  TIOCGETD
-# define TIOCGETD	_IOR('t', 0, int)	/* get line discipline */
-# undef  TIOCSETD
-# define TIOCSETD	_IOW('t', 1, int)	/* set line discipline */
-#else
-# define OTIOCGETD	_IOR('t', 0, int)	/* get line discipline */
-# define OTIOCSETD	_IOW('t', 1, int)	/* set line discipline */
-#endif
+#define	OTIOCGETD	_IOR('t', 0, int)	/* get line discipline */
+#define	OTIOCSETD	_IOW('t', 1, int)	/* set line discipline */
 #define	TIOCHPCL	_IO('t', 2)		/* hang up on last close */
 #define	TIOCGETP	_IOR('t', 8,struct sgttyb)/* get parameters -- gtty */
 #define	TIOCSETP	_IOW('t', 9,struct sgttyb)/* set parameters -- stty */
@@ -161,6 +152,9 @@
 #define	TIOCSLTC	_IOW('t',117,struct ltchars)/* set local special chars*/
 #define	TIOCGLTC	_IOR('t',116,struct ltchars)/* get local special chars*/
 #define OTIOCCONS	_IO('t', 98)	/* for hp300 -- sans int arg */
+#endif /* _KERNEL */
+
+/* XXX publish these so stty(1) can still report them */
 #define	OTTYDISC	0
 #define	NETLDISC	1
 #define	NTTYDISC	2
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080202111518.757E81CC4E>