diff -Naur util-linux-2.12q.orig/text-utils/more.c util-linux-2.12q/text-utils/more.c
--- util-linux-2.12q.orig/text-utils/more.c	2004-12-22 12:46:25.000000000 +0200
+++ util-linux-2.12q/text-utils/more.c	2005-06-11 16:00:56.000000000 +0300
@@ -76,6 +76,14 @@
 
 #define stty(fd,argp)  tcsetattr(fd,TCSANOW,argp)
 
+/* TAB3 and TABDLY are in XPG3 and up */
+#if !defined(TABDLY) && defined(TBDELAY)
+#define TABDLY		TBDELAY
+#endif
+#if !defined(TAB3) && defined(XTABS)
+#define TAB3		XTABS
+#endif
+
 /* some function declarations */
 void initterm(void);
 void kill_line(void);
@@ -1804,8 +1812,8 @@
     no_intty = tcgetattr(fileno(stdin), &otty);
     tcgetattr(fileno(stderr), &otty);
     savetty0 = otty;
-    slow_tty = (otty.c_cflag & CBAUD) < B1200;
-    hardtabs = (otty.c_oflag & TABDLY) != XTABS;
+    slow_tty = cfgetospeed(&otty) < B1200;
+    hardtabs = (otty.c_oflag & TABDLY) != TAB3;
     if (!no_tty) {
 	otty.c_lflag &= ~(ICANON|ECHO);
 	otty.c_cc[VMIN] = 1;
diff -Naur util-linux-2.12q.orig/login-utils/agetty.c util-linux-2.12q/login-utils/agetty.c
--- util-linux-2.12q.orig/login-utils/agetty.c	2002-07-29 10:36:42.000000000 +0300
+++ util-linux-2.12q/login-utils/agetty.c	2005-06-11 16:00:56.000000000 +0300
@@ -17,8 +17,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/ioctl.h>
-#include <termio.h>
+#include <termios.h>
 #include <signal.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -30,7 +29,7 @@
 #include "xstrncpy.h"
 #include "nls.h"
 
-#ifdef __linux__
+#if defined(unix)
 #include "pathnames.h"
 #include <sys/param.h>
 #define USE_SYSLOG
@@ -93,27 +93,6 @@
 #define DEF_SWITCH	0		/* default switch char */
 
  /*
-  * SunOS 4.1.1 termio is broken. We must use the termios stuff instead,
-  * because the termio -> termios translation does not clear the termios
-  * CIBAUD bits. Therefore, the tty driver would sometimes report that input
-  * baud rate != output baud rate. I did not notice that problem with SunOS
-  * 4.1. We will use termios where available, and termio otherwise.
-  */
-
-/* linux 0.12 termio is broken too, if we use it c_cc[VERASE] isn't set
-   properly, but all is well if we use termios?! */
-
-#ifdef	TCGETS
-#undef	TCGETA
-#undef	TCSETA
-#undef	TCSETAW
-#define	termio	termios
-#define	TCGETA	TCGETS
-#define	TCSETA	TCSETS
-#define	TCSETAW	TCSETSW
-#endif
-
- /*
   * This program tries to not use the standard-i/o library.  This keeps the
   * executable small on systems that do not have shared libraries (System V
   * Release <3).
@@ -221,13 +200,13 @@
 void parse_args P_((int argc, char **argv, struct options *op));
 void parse_speeds P_((struct options *op, char *arg));
 void update_utmp P_((char *line));
-void open_tty P_((char *tty, struct termio *tp, int local));
-void termio_init P_((struct termio *tp, int speed, struct options *op));
-void auto_baud P_((struct termio *tp));
-void do_prompt P_((struct options *op, struct termio *tp));
-void next_speed P_((struct termio *tp, struct options *op));
-char *get_logname P_((struct options *op, struct chardata *cp, struct termio *tp));
-void termio_final P_((struct options *op, struct termio *tp, struct chardata *cp));
+void open_tty P_((char *tty, struct termios *tp, int local));
+void termios_init P_((struct termios *tp, int speed, struct options *op));
+void auto_baud P_((struct termios *tp));
+void do_prompt P_((struct options *op, struct termios *tp));
+void next_speed P_((struct termios *tp, struct options *op));
+char *get_logname P_((struct options *op, struct chardata *cp, struct termios *tp));
+void termios_final P_((struct options *op, struct termios *tp, struct chardata *cp));
 int caps_lock P_((char *s));
 int bcode P_((char *s));
 void usage P_((void));
@@ -256,7 +235,7 @@
 {
     char   *logname = NULL;		/* login name, given to /bin/login */
     struct chardata chardata;		/* set by get_logname() */
-    struct termio termio;		/* terminal mode bits */
+    struct termios termios;		/* terminal mode bits */
     static struct options options = {
 	F_ISSUE,			/* show /etc/issue (SYSV_STYLE) */
 	0,				/* no timeout */
@@ -299,7 +278,7 @@
 
     parse_args(argc, argv, &options);
 
-#ifdef __linux__
+#if defined(unix)
 	setsid();
 #endif
 	
@@ -311,19 +290,19 @@
 
     debug(_("calling open_tty\n"));
     /* Open the tty as standard { input, output, error }. */
-    open_tty(options.tty, &termio, options.flags & F_LOCAL);
+    open_tty(options.tty, &termios, options.flags & F_LOCAL);
 
-#ifdef __linux__
+#if defined(unix)
 	{
 		int iv;
 		
 		iv = getpid();
-		(void) ioctl(0, TIOCSPGRP, &iv);
+		(void) tcsetpgrp(0, iv);
 	}
 #endif
-    /* Initialize the termio settings (raw mode, eight-bit, blocking i/o). */
-    debug(_("calling termio_init\n"));
-    termio_init(&termio, options.speeds[FIRST_SPEED], &options);
+    /* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */
+    debug(_("calling termios_init\n"));
+    termios_init(&termios, options.speeds[FIRST_SPEED], &options);
 
     /* write the modem init string and DON'T flush the buffers */
     if (options.flags & F_INITSTRING) {
@@ -339,7 +318,7 @@
     /* Optionally detect the baud rate from the modem status message. */
     debug(_("before autobaud\n"));
     if (options.flags & F_PARSE)
-	auto_baud(&termio);
+	auto_baud(&termios);
 
     /* Set the optional timer. */
     if (options.timeout)
@@ -363,8 +342,8 @@
     if (!(options.flags & F_NOPROMPT)) {
 	/* Read the login name. */
 	debug(_("reading login name\n"));
-	while ((logname = get_logname(&options, &chardata, &termio)) == 0)
-	  next_speed(&termio, &options);
+	while ((logname = get_logname(&options, &chardata, &termios)) == 0)
+	  next_speed(&termios, &options);
     }
 
     /* Disable timer. */
@@ -372,9 +351,9 @@
     if (options.timeout)
 	(void) alarm(0);
 
-    /* Finalize the termio settings. */
+    /* Finalize the termios settings. */
 
-    termio_final(&options, &termio, &chardata);
+    termios_final(&options, &termios, &chardata);
 
     /* Now the newline character should be properly written. */
 
@@ -629,7 +608,7 @@
 void
 open_tty(tty, tp, local)
      char   *tty;
-     struct termio *tp;
+     struct termios *tp;
      int    local;
 {
     /* Get rid of the present standard { output, error} if any. */
@@ -678,7 +657,7 @@
 	error(_("%s: dup problem: %m"), tty);	/* we have a problem */
 
     /*
-     * The following ioctl will fail if stdin is not a tty, but also when
+     * The following function will fail if stdin is not a tty, but also when
      * there is noise on the modem control lines. In the latter case, the
      * common course of action is (1) fix your cables (2) give the modem more
      * time to properly reset after hanging up. SunOS users can achieve (2)
@@ -686,8 +665,8 @@
      * 5 seconds seems to be a good value.
      */
 
-    if (ioctl(0, TCGETA, tp) < 0)
-	error("%s: ioctl: %m", tty);
+    if (tcgetattr(0, tp) < 0)
+	error("%s: tcgetattr: %m", tty);
 
     /*
      * It seems to be a terminal. Set proper protections and ownership. Mode
@@ -705,27 +684,27 @@
     errno = 0;					/* ignore above errors */
 }
 
-/* termio_init - initialize termio settings */
+/* termios_init - initialize termios settings */
 
 char gbuf[1024];
 char area[1024];
 
 void
-termio_init(tp, speed, op)
-     struct termio *tp;
+termios_init(tp, speed, op)
+     struct termios *tp;
      int     speed;
      struct options *op;
 {
 
     /*
-     * Initial termio settings: 8-bit characters, raw-mode, blocking i/o.
+     * Initial termios settings: 8-bit characters, raw-mode, blocking i/o.
      * Special characters are set after we have read the login name; all
      * reads will be done in raw mode anyway. Errors will be dealt with
      * lateron.
      */
-#ifdef __linux__
+#if defined(unix)
     /* flush input and output queues, important for modems! */
-    (void) ioctl(0, TCFLSH, TCIOFLUSH);
+    (void) tcflush(0, TCIOFLUSH);
 #endif
 
     tp->c_cflag = CS8 | HUPCL | CREAD | speed;
@@ -733,7 +712,10 @@
 	tp->c_cflag |= CLOCAL;
     }
 
-    tp->c_iflag = tp->c_lflag = tp->c_oflag = tp->c_line = 0;
+    tp->c_iflag = tp->c_lflag = tp->c_oflag = 0;
+#if defined(__linux__)
+    tp->c_line = 0;
+#endif
     tp->c_cc[VMIN] = 1;
     tp->c_cc[VTIME] = 0;
 
@@ -744,7 +726,7 @@
 	tp->c_cflag |= CRTSCTS;
 #endif
 
-    (void) ioctl(0, TCSETA, tp);
+    (void) tcsetattr(0, TCSANOW, tp);
 
     /* go to blocking input even in local mode */
     fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~O_NONBLOCK);
@@ -755,7 +737,7 @@
 /* auto_baud - extract baud rate from modem status message */
 void
 auto_baud(tp)
-     struct termio *tp;
+     struct termios *tp;
 {
     int     speed;
     int     vmin;
@@ -788,7 +770,7 @@
     tp->c_iflag |= ISTRIP;			/* enable 8th-bit stripping */
     vmin = tp->c_cc[VMIN];
     tp->c_cc[VMIN] = 0;				/* don't block if queue empty */
-    (void) ioctl(0, TCSETA, tp);
+    (void) tcsetattr(0, TCSANOW, tp);
 
     /*
      * Wait for a while, then read everything the modem has said so far and
@@ -801,8 +783,7 @@
 	for (bp = buf; bp < buf + nread; bp++) {
 	    if (isascii(*bp) && isdigit(*bp)) {
 		if ((speed = bcode(bp))) {
-		    tp->c_cflag &= ~CBAUD;
-		    tp->c_cflag |= speed;
+		    (void) cfsetospeed(tp, speed);
 		}
 		break;
 	    }
@@ -812,14 +793,14 @@
 
     tp->c_iflag = iflag;
     tp->c_cc[VMIN] = vmin;
-    (void) ioctl(0, TCSETA, tp);
+    (void) tcsetattr(0, TCSANOW, tp);
 }
 
 /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */
 void
 do_prompt(op, tp)
      struct options *op;
-     struct termio *tp;
+     struct termios *tp;
 {
 #ifdef	ISSUE
     FILE    *fd;
@@ -835,7 +816,7 @@
     if ((op->flags & F_ISSUE) && (fd = fopen(op->issue, "r"))) {
 	oflag = tp->c_oflag;			/* save current setting */
 	tp->c_oflag |= (ONLCR | OPOST);		/* map NL in output to CR-NL */
-	(void) ioctl(0, TCSETAW, tp);
+	(void) tcsetattr(0, TCSADRAIN, tp);
 
 
 	while ((c = getc(fd)) != EOF)
@@ -915,7 +896,7 @@
 			int i;
 
 			for (i = 0; speedtab[i].speed; i++) {
-			    if (speedtab[i].code == (tp->c_cflag & CBAUD)) {
+			    if (speedtab[i].code == cfgetospeed(tp)) {
 				printf("%ld", speedtab[i].speed);
 				break;
 			    }
@@ -947,7 +928,7 @@
 	fflush(stdout);
 
 	tp->c_oflag = oflag;			/* restore settings */
-	(void) ioctl(0, TCSETAW, tp);		/* wait till output is gone */
+	(void) tcsetattr(0, TCSADRAIN, tp);	/* wait till output is gone */
 	(void) fclose(fd);
     }
 #endif
@@ -965,15 +948,14 @@
 /* next_speed - select next baud rate */
 void
 next_speed(tp, op)
-     struct termio *tp;
+     struct termios *tp;
      struct options *op;
 {
     static int baud_index = FIRST_SPEED;/* current speed index */
 
     baud_index = (baud_index + 1) % op->numspeed;
-    tp->c_cflag &= ~CBAUD;
-    tp->c_cflag |= op->speeds[baud_index];
-    (void) ioctl(0, TCSETA, tp);
+    (void) cfsetospeed(0, op->speeds[baud_index]);
+    (void) tcsetattr(0, TCSANOW, tp);
 }
 
 /* get_logname - get user name, establish parity, speed, erase, kill, eol */
@@ -981,7 +963,7 @@
 char   *get_logname(op, cp, tp)
      struct options *op;
      struct chardata *cp;
-     struct termio *tp;
+     struct termios *tp;
 {
     static char logname[BUFSIZ];
     char   *bp;
@@ -1003,7 +985,7 @@
     /* Flush pending input (esp. after parsing or switching the baud rate). */
 
     (void) sleep(1);
-    (void) ioctl(0, TCFLSH, TCIFLUSH);
+    (void) tcflush(0, TCIFLUSH);
 
     /* Prompt for and read a login name. */
 
@@ -1087,11 +1069,11 @@
     return (logname);
 }
 
-/* termio_final - set the final tty mode bits */
+/* termios_final - set the final tty mode bits */
 void
-termio_final(op, tp, cp)
+termios_final(op, tp, cp)
      struct options *op;
-     struct termio *tp;
+     struct termios *tp;
      struct chardata *cp;
 {
     /* General terminal-independent stuff. */
@@ -1107,7 +1089,7 @@
     tp->c_cc[VEOL] = DEF_EOL;
 #ifdef __linux__
     tp->c_cc[VSWTC] = DEF_SWITCH;		/* default switch character */
-#else
+#elif defined(VSWTCH)
     tp->c_cc[VSWTCH] = DEF_SWITCH;		/* default switch character */
 #endif
 
@@ -1139,11 +1121,13 @@
     }
     /* Account for upper case without lower case. */
 
+#if defined(IUCLC) && defined(XCASE) && defined(OLCUC)
     if (cp->capslock) {
 	tp->c_iflag |= IUCLC;
 	tp->c_lflag |= XCASE;
 	tp->c_oflag |= OLCUC;
     }
+#endif
     /* Optionally enable hardware flow control */
 
 #ifdef	CRTSCTS
@@ -1153,8 +1137,8 @@
 
     /* Finally, make the new settings effective */
 
-    if (ioctl(0, TCSETA, tp) < 0)
-	error("%s: ioctl: TCSETA: %m", op->tty);
+    if (tcsetattr(0, TCSADRAIN, tp) < 0)
+	error("%s: tcsetattr: %m", op->tty);
 }
 
 /* caps_lock - string contains upper case without lower case */
diff -Naur util-linux-2.12q.orig/misc-utils/setterm.c util-linux-2.12q/misc-utils/setterm.c
--- util-linux-2.12q.orig/misc-utils/setterm.c	2003-10-17 19:17:51.000000000 +0300
+++ util-linux-2.12q/misc-utils/setterm.c	2005-06-11 16:00:56.000000000 +0300
@@ -107,11 +107,6 @@
 #include <sys/time.h>
 #include "nls.h"
 
-#ifndef TCGETS
-/* TCGETS is either defined in termios.h, or here: */
-#include <asm/ioctls.h>
-#endif
-
 #if __GNU_LIBRARY__ < 5
 #ifndef __alpha__
 # include <linux/unistd.h>
diff -Naur util-linux-2.12q.orig/login-utils/login.c util-linux-2.12q/login-utils/login.c
--- util-linux-2.12q.orig/login-utils/login.c	2004-12-05 04:37:12.000000000 +0200
+++ util-linux-2.12q/login-utils/login.c	2005-06-11 16:00:56.000000000 +0300
@@ -1274,12 +1276,12 @@
 
 static void
 timedout2(int sig) {
-	struct termio ti;
+	struct termios ti;
     
 	/* reset echo */
-	ioctl(0, TCGETA, &ti);
+	tcgetattr(0, &ti);
 	ti.c_lflag |= ECHO;
-	ioctl(0, TCSETA, &ti);
+	tcsetattr(0, TCSANOW, &ti);
 	exit(0);			/* %% */
 }
 
