Bug 124475 - [Patch] misc/splitvt: don't use sgtty
Summary: [Patch] misc/splitvt: don't use sgtty
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Rong-En Fan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-11 13:20 UTC by Ed Schouten
Modified: 2008-06-11 14:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Schouten freebsd_committer freebsd_triage 2008-06-11 13:20:01 UTC
The splitvt port still uses sgtty. This means it depends on the
COMPAT_43TTY kernel option. We can easily port it to termios, which
means we can eventually remove sgtty from the FreeBSD operating system.

Fix: 

The following patch changes splitvt to use termios instead of sgtty:

--- misc/splitvt/files/patch-misc.c
+++ misc/splitvt/files/patch-misc.c
@@ -1,11 +1,112 @@
 --- misc.c.orig	Wed Dec 15 10:28:45 2004
 +++ misc.c	Sat Oct  7 14:34:28 2006
-@@ -5,6 +5,8 @@
- #include	<fcntl.h>
- #include	<stdio.h>
+@@ -7,10 +7,13 @@
+ #include	<stdlib.h>
+ #include	<string.h>
  #include	<signal.h>
 +#include	<stdlib.h>
 +#include	<string.h>
  
++#define HAVE_TERMIO_H
  
  #ifdef HAVE_TERMIO_H
+-#include	<termio.h>
++#include	<termios.h>
+ #else
+ #include	<sys/ioctl.h>
+ #endif  /* HAVE_TERMIO_H */
+@@ -431,13 +434,13 @@
+ /* Get the modes of the controlling tty and save them.  Saves
+    ttymodes in tty_mode and returns -1 if ioctl fails. */
+ 
+-struct termio tty_mode;  /* Save tty mode here */
++struct termios tty_mode;  /* Save tty mode here */
+ static int tty_init=0;
+ 
+ int tty_getmode(fd)
+ int fd;
+ {
+-	d_zero((char *)&tty_mode, sizeof(struct termio));
++	d_zero((char *)&tty_mode, sizeof(struct termios));
+ 	tty_init=1;	/* Flag: we have initialized the tty_mode struct */
+ 
+ 	if ( ! isatty(fd) )
+@@ -447,7 +450,7 @@
+ 	fprintf(stderr, "Getting tty modes for tty_mode.\r\n");
+ #endif
+ 
+-	if (ioctl(fd, TCGETA, (char *) &tty_mode) < 0)
++	if (tcgetattr(fd, &tty_mode) < 0)
+ 	{
+ #ifdef DEBUG
+ 		perror("tty_getmode(): ioctl error");
+@@ -464,14 +467,14 @@
+ int tty_sane(fd)
+ int fd;
+ {
+-	struct termio temp_mode;
++	struct termios temp_mode;
+ 
+ 	if ( ! isatty(fd) )
+ 		return(0);
+ 
+ 	if ( ! tty_init )
+ 	{
+-		if (ioctl(fd, TCGETA, (char *) &tty_mode) < 0)
++		if (tcgetattr(fd, &tty_mode) < 0)
+ 			return(-1);  
+ 	}
+ 
+@@ -491,7 +494,7 @@
+ 	temp_mode.c_cc[VEOF]=('D'^64);
+ 	
+ 	/* TCSETAW is important for letting tty input drain. */
+-	if ( ioctl(fd, TCSETAW, (char *)&temp_mode) < 0 )
++	if ( tcsetattr(fd, TCSADRAIN, &temp_mode) < 0 )
+ 	{
+ #ifdef DEBUG
+ 		perror("Can't set tty modes");
+@@ -508,7 +511,7 @@
+ int tty_raw(fd)
+ int fd;     /* of tty device */
+ {
+-	struct termio temp_mode;
++	struct termios temp_mode;
+ 
+ 	if ( ! tty_init )
+ 		return(-1);
+@@ -516,7 +519,7 @@
+ 	if ( ! isatty(fd) )
+ 		return(0);
+ 
+-	if ( ioctl(fd, TCGETA, (char *)&temp_mode) < 0 )
++	if ( tcgetattr(fd, &temp_mode) < 0 )
+ 		return(-1);
+ 
+ #ifdef SEVEN_BIT
+@@ -524,14 +527,14 @@
+ #else
+ 	temp_mode.c_iflag=(IGNBRK);		/* turn off all input control */
+ #endif
+-	temp_mode.c_oflag &= ~(OLCUC | ONLCR | OCRNL | ONLRET);
++	temp_mode.c_oflag &= ~(ONLCR | OCRNL | ONLRET);
+ 					/* disable output post-processing */
+ 	temp_mode.c_lflag = 0;
+ 	temp_mode.c_cc[VMIN]=1;		/* 1 or more chars satisfy read */
+ 	temp_mode.c_cc[VTIME]=0;	/* 10'ths of seconds between chars */
+ 
+ 	/* TCSETAW is important for letting tty input drain. */
+-	if (ioctl(fd, TCSETAW, (char *) &temp_mode) < 0)
++	if (tcsetattr(fd, TCSADRAIN, &temp_mode) < 0)
+ 		return(-1);
+ 	return(0);
+ }
+@@ -550,7 +553,7 @@
+ 		return(0);
+ 
+ 	/* TCSETAW is important for letting tty input drain. */
+-	if (ioctl(fd, TCSETAW, (char *) &tty_mode) < 0)
++	if (tcsetattr(fd, TCSADRAIN, &tty_mode) < 0)
+ 		return(-1);
+ 	return(0);
+ }
--- misc/splitvt/files/patch-vttest.c
+++ misc/splitvt/files/patch-vttest.c
@@ -1,6 +1,54 @@
 --- vttest.c.orig	Sat Oct  7 15:38:17 2006
 +++ vttest.c	Sat Oct  7 15:40:43 2006
-@@ -87,9 +87,13 @@
+@@ -15,8 +15,9 @@
+ #include	<sys/types.h>
+ #include	<stdio.h>
+ #include	<fcntl.h>
++#define HAVE_TERMIO_H
+ #ifdef HAVE_TERMIO_H 
+-#include        <termio.h> 
++#include        <termios.h> 
+ #else 
+ #include	<setjmp.h> 
+ #include	<signal.h> 
+@@ -49,15 +50,15 @@
+ {
+ 	char   buff[512];
+ 	int x=0, w, rc=0, fd;
+-	struct termio ttold, ttraw;
++	struct termios ttold, ttraw;
+ 
+ 	/* Set the terminal in a raw mode */
+ 	if ( (fd=open("/dev/tty", O_RDWR, 0666)) < 0 )
+ 		return(0);
+ 
+-	if ( ioctl(fd, TCGETA, (char *)&ttold) < 0 )
++	if ( tcgetattr(fd, &ttold) < 0 )
+ 		return(0);
+-	(void) ioctl(fd, TCGETA, (char *)&ttraw);
++	(void) tcgetattr(fd, &ttraw);
+ 
+ #ifdef HAVE_TERMIO_H
+ #ifdef SEVEN_BIT
+@@ -65,7 +66,7 @@
+ #else
+ 	ttraw.c_iflag=(IGNBRK);   /* turn off all input control */
+ #endif /* SEVEN_BIT */
+-        ttraw.c_oflag &= ~(OLCUC | ONLCR | OCRNL | ONLRET);
++        ttraw.c_oflag &= ~(ONLCR | OCRNL | ONLRET);
+                                         /* disable output post-processing */
+         ttraw.c_lflag = 0;
+         ttraw.c_cc[VMIN]=0;          /* 1 or more chars satisfy read */
+@@ -75,7 +76,7 @@
+ 	ttraw.sg_flags &= ~ECHO;	/* turn ECHO off */
+ #endif /* HAVE_TERMIO_H */
+ 
+-        if (ioctl(fd, TCSETAW, (char *)&ttraw) < 0)
++        if (tcsetattr(fd, TCSADRAIN, &ttraw) < 0)
+                 return(0);
+ 
+   	write(fd,"\033[c", 3);	/* Vt100 test: ESC [ c */
+@@ -87,9 +88,13 @@
  	setjmp(alarm_buf);
  #endif
  	while ( !alarmed && (x < 20) ) { 
@@ -15,3 +63,12 @@
  	buff[x]='\0';		/* For printing, if we desire. */
    	if ( buff[0] == '\033' )	/* An escape sequence? :) */
  		rc=1;
+@@ -98,7 +103,7 @@
+ 	alarm(0);
+ 	signal(SIGALRM, SIG_DFL);
+ #endif
+-        (void) ioctl(fd, TCSETAW, (char *)&ttold);
++        (void) tcsetattr(fd, TCSADRAIN, &ttold);
+ 	(void) close(fd);
+ 
+ #ifdef not_defined		/* Print out the response for debugging */
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2008-06-11 13:20:10 UTC
Responsible Changed
From-To: freebsd-ports-bugs->ed

Submitter has GNATS access (via the GNATS Auto Assign Tool)
Comment 2 dfilter service freebsd_committer freebsd_triage 2008-06-11 14:23:08 UTC
rafan       2008-06-11 13:23:02 UTC

  FreeBSD ports repository

  Modified files:
    misc/splitvt         Makefile 
    misc/splitvt/files   patch-misc.c patch-vttest.c 
  Log:
  - Use termios instead of sgtty
  - Bump PORTREVISION
  
  PR:             ports/124475
  Submitted by:   ed
  
  Revision  Changes    Path
  1.20      +1 -0      ports/misc/splitvt/Makefile
  1.3       +104 -3    ports/misc/splitvt/files/patch-misc.c
  1.2       +58 -1     ports/misc/splitvt/files/patch-vttest.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 3 Rong-En Fan freebsd_committer freebsd_triage 2008-06-11 14:23:10 UTC
Responsible Changed
From-To: ed->rafan

I'll take it.
Comment 4 Rong-En Fan freebsd_committer freebsd_triage 2008-06-11 14:23:14 UTC
State Changed
From-To: open->closed

Committed. Thanks!