From 2b83e2ee5e053fd5152e085f12cf2b72b36ae62b Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Tue, 10 Sep 2019 21:30:00 +0200 Subject: [PATCH] Retire the utmp specific ttyslot() function, like FreeBSD did. --- Makefile_upgrade.inc | 1 + include/unistd.h | 1 - lib/libc/gen/Makefile.inc | 3 +-- lib/libc/gen/Symbol.map | 1 - lib/libc/gen/getttyent.3 | 3 +-- lib/libc/gen/ttyname.3 | 26 ++++---------------------- lib/libc/gen/ttyslot.c | 32 +++----------------------------- libexec/getty/ttys.5 | 3 +-- 8 files changed, 11 insertions(+), 59 deletions(-) diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index 3142c62019..0be7fcb258 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -3765,6 +3765,7 @@ TO_REMOVE+=/usr/share/man/man3/logwtmp.3.gz TO_REMOVE+=/usr/share/man/man5/lastlog.5.gz TO_REMOVE+=/usr/share/man/man5/utmp.5.gz TO_REMOVE+=/usr/share/man/man5/wtmp.5.gz +TO_REMOVE+=/usr/share/man/man3/ttyslot.3.gz .if !defined(WANT_INSTALLER) TO_REMOVE+=/usr/sbin/dfuibe_installer diff --git a/include/unistd.h b/include/unistd.h index 6c6482bf6a..b6e6e81e39 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -596,7 +596,6 @@ int swapoff(const char *); int swapon(const char *); int syscall(int, ...); off_t __syscall(quad_t, ...); -int ttyslot(void); int umtx_sleep(volatile const int *, int , int); int umtx_wakeup(volatile const int *, int); int undelete(const char *); diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index a4d86f915f..32176113ba 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -283,8 +283,7 @@ MLINKS+=tcsetattr.3 cfgetispeed.3 \ tcsetattr.3 cfsetspeed.3 \ tcsetattr.3 tcgetattr.3 MLINKS+=ttyname.3 isatty.3 \ - ttyname.3 ttyname_r.3 \ - ttyname.3 ttyslot.3 + ttyname.3 ttyname_r.3 MLINKS+=tzset.3 tzsetwall.3 MLINKS+=unvis.3 strnunvis.3 \ unvis.3 strnunvisx.3 \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 91742de8c4..564888885f 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -424,7 +424,6 @@ DF404.0 { times; ttyname; ttyname_r; - ttyslot; ualarm; ulimit; uname; diff --git a/lib/libc/gen/getttyent.3 b/lib/libc/gen/getttyent.3 index 74d65280fd..3ccb54ff1a 100644 --- a/lib/libc/gen/getttyent.3 +++ b/lib/libc/gen/getttyent.3 @@ -28,7 +28,7 @@ .\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD: src/lib/libc/gen/getttyent.3,v 1.15 2007/01/09 00:27:54 imp Exp $ .\" -.Dd November 17, 1996 +.Dd September 10, 2019 .Dt GETTTYENT 3 .Os .Sh NAME @@ -188,7 +188,6 @@ zero otherwise. .El .Sh SEE ALSO .Xr login 1 , -.Xr ttyslot 3 , .Xr gettytab 5 , .Xr termcap 5 , .Xr ttys 5 , diff --git a/lib/libc/gen/ttyname.3 b/lib/libc/gen/ttyname.3 index e0113bce59..5fe7d614c7 100644 --- a/lib/libc/gen/ttyname.3 +++ b/lib/libc/gen/ttyname.3 @@ -27,16 +27,14 @@ .\" .\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD: src/lib/libc/gen/ttyname.3,v 1.14 2007/01/09 00:27:55 imp Exp $ -.\" $DragonFly: src/lib/libc/gen/ttyname.3,v 1.3 2005/11/19 22:32:53 swildner Exp $ .\" -.Dd March 22, 2009 +.Dd September 10, 2019 .Dt TTYNAME 3 .Os .Sh NAME .Nm ttyname , .Nm ttyname_r , -.Nm isatty , -.Nm ttyslot +.Nm isatty .Nd get name of associated terminal (tty) from file descriptor .Sh LIBRARY .Lb libc @@ -48,8 +46,6 @@ .Fn ttyname_r "int fd" "char *buf" "size_t len" .Ft int .Fn isatty "int fd" -.Ft int -.Fn ttyslot void .Sh DESCRIPTION These functions operate on the system file descriptors for terminal type devices. @@ -91,13 +87,6 @@ The .Fn ttyname_r function takes a buffer and length as arguments to avoid this problem. -.Pp -The -.Fn ttyslot -function -fetches the current process' control terminal number from the -.Xr ttys 5 -file entry. .Sh RETURN VALUES The .Fn isatty @@ -118,12 +107,6 @@ The .Fn ttyname_r function returns 0 if successful. Otherwise an error number is returned. -.Pp -The -.Fn ttyslot -function -returns the unit number of the device file if found; otherwise -the value zero is returned. .Sh FILES .Bl -tag -width ".Pa /etc/ttys" -compact .It Pa /dev/\(** @@ -157,10 +140,9 @@ is smaller than the length of the string to be returned. .Xr ttys 5 .Sh HISTORY The -.Fn isatty , -.Fn ttyname , +.Fn isatty and -.Fn ttyslot +.Fn ttyname functions appeared in .At v7 . diff --git a/lib/libc/gen/ttyslot.c b/lib/libc/gen/ttyslot.c index 2aa46b3cf6..c0ee1af23a 100644 --- a/lib/libc/gen/ttyslot.c +++ b/lib/libc/gen/ttyslot.c @@ -27,39 +27,13 @@ * SUCH DAMAGE. * * @(#)ttyslot.c 8.1 (Berkeley) 6/4/93 - * $DragonFly: src/lib/libc/gen/ttyslot.c,v 1.4 2005/11/13 00:07:42 swildner Exp $ */ -#include -#include -#include -#include -#include +#include +__sym_compat(ttyslot, past_ttyslot, DF404.0); int -ttyslot(void) +past_ttyslot(void) { - struct ttyent *ttyp; - int slot; - int cnt; - char *name; - size_t len = sizeof(_PATH_DEV) - 1; - - setttyent(); - for (cnt = 0; cnt < 3; ++cnt) - if ( (name = ttyname(cnt)) ) { - if (strncmp(name, _PATH_DEV, len) != 0) - break; - - name += len; - - for (slot = 1; (ttyp = getttyent()); ++slot) - if (!strcmp(ttyp->ty_name, name)) { - endttyent(); - return(slot); - } - break; - } - endttyent(); return(0); } diff --git a/libexec/getty/ttys.5 b/libexec/getty/ttys.5 index b7927f070a..19d796f3e7 100644 --- a/libexec/getty/ttys.5 +++ b/libexec/getty/ttys.5 @@ -28,7 +28,7 @@ .\" from: @(#)ttys.5 8.1 (Berkeley) 6/4/93 .\" $FreeBSD: head/libexec/getty/ttys.5 330277 2018-03-02 14:16:19Z trasz $ .\" -.Dd April 7, 2018 +.Dd September 10, 2019 .Dt TTYS 5 .Os .Sh NAME @@ -157,7 +157,6 @@ ttyp1 none network off group=pty .Sh SEE ALSO .Xr login 1 , .Xr getttyent 3 , -.Xr ttyslot 3 , .Xr gettytab 5 , .Xr login.conf 5 , .Xr termcap 5 , -- 2.41.0