1998-04-24  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* streams/Makefile (headers): Add sys/stropts.h.
	* streams/sys/stropts.h: New file.

1998-04-25  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* sysdeps/unix/sysv/linux/ttyname.c,
	sysdeps/unix/sysv/linux/ttyname_r.c: New files, like
	sysdeps/posix/ttyname*.c, but look in /dev/pts first.

1998-04-25  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* sysdeps/unix/sysv/linux/ptsname.c: Fix off-by-one bug in second
	argument of _itoa_word.

1998-04-24  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* sysdeps/unix/sysv/linux/syscalls.list (s_getcwd, s_getdents,
	s_pread64, s_pwrite64, s_reboot, s_sigpending, s_sigprocmask): Set
	caller to getcwd, getdents, pread64, pwrite64, reboot, sigpending,
	sigprocmask, resp., instead of EXTRA.

	* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove
	s_pread64 and s_pwrite64.
This commit is contained in:
Ulrich Drepper 1998-04-27 09:43:55 +00:00
parent 625094fd7a
commit 45139d5f77
24 changed files with 588 additions and 13 deletions

View File

@ -1,3 +1,29 @@
1998-04-24 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* streams/Makefile (headers): Add sys/stropts.h.
* streams/sys/stropts.h: New file.
1998-04-25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/sysv/linux/ttyname.c,
sysdeps/unix/sysv/linux/ttyname_r.c: New files, like
sysdeps/posix/ttyname*.c, but look in /dev/pts first.
1998-04-25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/sysv/linux/ptsname.c: Fix off-by-one bug in second
argument of _itoa_word.
1998-04-24 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* sysdeps/unix/sysv/linux/syscalls.list (s_getcwd, s_getdents,
s_pread64, s_pwrite64, s_reboot, s_sigpending, s_sigprocmask): Set
caller to getcwd, getdents, pread64, pwrite64, reboot, sigpending,
sigprocmask, resp., instead of EXTRA.
* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove
s_pread64 and s_pwrite64.
1998-04-26 18:44 Ulrich Drepper <drepper@cygnus.com>
* iconvdata/Makefile: Correct rules to generate gap table.

View File

@ -63,3 +63,13 @@ PT PT Y UTF8
PT2 PT2 Y UTF8
SEN_850200_B SEN_850200_B Y UTF8
SEN_850200_C SEN_850200_C Y UTF8
KOI-8 KOI-8 Y UTF8
KOI8-R KOI8-R Y UTF8
CP1250 CP1250 Y UTF8
CP1251 CP1251 Y UTF8
CP1252 CP1252 Y UTF8
CP1253 CP1253 Y UTF8
CP1254 CP1254 Y UTF8
CP1255 CP1255 Y UTF8
CP1256 CP1256 Y UTF8
CP1257 CP1257 Y UTF8

14
iconvdata/testdata/CP1250 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
„ … † ‡ ‰ Š Œ <20> Ž <20>
“ ” • — ™ š œ <20> ž Ÿ
  ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ

14
iconvdata/testdata/CP1250..UTF8 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
„ … † ‡ ‰ Š Ś Ť Ž Ź
“ ” • — ™ š ś ť ž ź
  ˇ ˘ Ł ¤ Ą ¦ § ¨ © Ş « ¬ ­ ® Ż
° ± ˛ ł ´ µ ¶ · ¸ ą ş » Ľ ˝ ľ ż
Ŕ Á Â Ă Ä Ĺ Ć Ç Č É Ę Ë Ě Í Î Ď
Đ Ń Ň Ó Ô Ő Ö × Ř Ů Ú Ű Ü Ý Ţ ß
ŕ á â ă ä ĺ ć ç č é ę ë ě í î ď
đ ń ň ó ô ő ö ÷ ř ů ú ű ü ý ţ ˙

14
iconvdata/testdata/CP1251 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
<20> ƒ „ … † ‡ ‰ Š Œ <20> Ž <20>
<20> “ ” • — ™ š œ <20> ž Ÿ
  ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ

14
iconvdata/testdata/CP1251..UTF8 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
Ђ Ѓ ѓ „ … † ‡ ‰ Љ Њ Ќ Ћ Џ
ђ “ ” • — ™ љ њ ќ ћ џ
  Ў ў Ј ¤ Ґ ¦ § Ё © Є « ¬ ­ ® Ї
° ± І і ґ µ ¶ · ё № є » ј Ѕ ѕ ї
А Б В Г Д Е Ж З И Й К Л М Н О П
Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я
а б в г д е ж з и й к л м н о п
р с т у ф х ц ч ш щ ъ ы ь э ю я

14
iconvdata/testdata/CP1252 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
ƒ „ … † ‡ ˆ ‰ Š Œ
“ ” • ˜ ™ š œ Ÿ
  ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ

14
iconvdata/testdata/CP1252..UTF8 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
ƒ „ … † ‡ ˆ ‰ Š Œ
“ ” • ˜ ™ š œ Ÿ
  ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ

14
iconvdata/testdata/CP1253 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
ƒ „ … † ‡ ‰
“ ” • — ™
  ¡ ¢ £ ¤ ¥ ¦ § ¨ © « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ

14
iconvdata/testdata/CP1253..UTF8 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
ƒ „ … † ‡ ‰
“ ” • — ™
  ΅ Ά £ ¤ ¥ ¦ § ¨ © « ¬ ­ ® ―
° ± ² ³ ΄ µ ¶ · Έ Ή Ί » Ό ½ Ύ Ώ
ΐ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο
Π Ρ Σ Τ Υ Φ Χ Ψ Ω Ϊ Ϋ ά έ ή ί
ΰ α β γ δ ε ζ η θ ι κ λ μ ν ξ ο
π ρ ς σ τ υ φ χ ψ ω ϊ ϋ ό ύ ώ

14
iconvdata/testdata/CP1254 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
ƒ „ … † ‡ ˆ ‰ Š Œ
“ ” • ˜ ™ š œ Ÿ
  ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ

14
iconvdata/testdata/CP1254..UTF8 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
ƒ „ … † ‡ ˆ ‰ Š Œ
“ ” • ˜ ™ š œ Ÿ
  ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ğ Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü İ Ş ß
à á â ã ä å æ ç è é ę ë ė í î ī
ğ ñ ò ó ô õ ö ÷ ø ù ú û ü ı ş ÿ

13
iconvdata/testdata/CP1255 vendored Normal file
View File

@ -0,0 +1,13 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
ƒ „ … † ‡ ‰
“ ” • — ™
  ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾
ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú ý þ

13
iconvdata/testdata/CP1255..UTF8 vendored Normal file
View File

@ -0,0 +1,13 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
ƒ „ … † ‡ ‰
“ ” • — ™
  ¢ £ ¤ ¥ ¦ § ¨ © × « ¬ ­ ® ‾
° ± ² ³ ´ µ ¶ · ¸ ¹ ÷ » ¼ ½ ¾
א ב ג ד ה ו ז ח ט י ך כ ל ם מ ן
נ ס ע ף פ ץ צ ק ר ש ת

14
iconvdata/testdata/CP1256 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
<20> ƒ „ … † ‡ ˆ ‰ Š Œ <20> Ž <20>
<20> “ ” • ˜ ™ š œ <20> ž Ÿ
  ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ù û ü ý þ ÿ

14
iconvdata/testdata/CP1256..UTF8 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
، ٠ ١ „ … † ‡ ٢ ٣ ٤ ٥ ٦ ٧ ٨
٩ “ ” • — ؛ ™ ؟ ء آ أ Ÿ
  ؤ إ £ ¤ ئ ¦ § ا © ب « ¬ ­ ® پ
° ± ة ت ث µ ¶ · ج چ ح » خ د ذ ر
À ز Â ژ س ش ص Ç È É Ê Ë ض ط Î Ï
ㄓ ع غ ـ Ô ف ق × ك Ù گ Û Ü ل م ن
à ه â ځ و ى ي ç è é ê ë ً ٌ î ï
ٍ َ ُ ِ ô ّ ْ ÷ ù û ü ÿ

14
iconvdata/testdata/CP1257 vendored Normal file
View File

@ -0,0 +1,14 @@
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~ 
„ … † ‡ ‰
“ ” • — ™
  ¢ £ ¤ ¦ § ¨ © ª « ¬ ­ ® ¯
° ± ² ³ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ

View File

@ -21,7 +21,7 @@
#
subdir := streams
headers = stropts.h bits/stropts.h
headers = stropts.h sys/stropts.h bits/stropts.h
routines = isastream getmsg getpmsg putmsg putpmsg fattach fdetach
include ../Rules

1
streams/sys/stropts.h Normal file
View File

@ -0,0 +1 @@
#include <stropts.h>

View File

@ -82,10 +82,6 @@ sysdep_headers += netinet/in_systm.h netinet/udp.h \
netrom/netrom.h netpacket/packet.h netrose/rose.h
endif
ifeq ($(subdir),posix)
sysdep_routines += s_pread64 s_pwrite64
endif
# Don't compile the ctype glue code, since there is no old non-GNU C library.
inhibit-glue = yes

View File

@ -101,7 +101,7 @@ __ptsname_r (fd, buf, buflen)
idbuf[5] = '\0';
__stpcpy (__stpcpy (nbuf, "/dev/pts/"),
_itoa_word (ptyno, &idbuf[4], 10, 0));
_itoa_word (ptyno, &idbuf[5], 10, 0));
if (__xstat (_STAT_VER, nbuf, &st) < 0)
{
if (errno != ENOENT)

View File

@ -40,19 +40,19 @@ rt_sigprocmask - rt_sigprocmask 4 __syscall_rt_sigprocmask
rt_sigqueueinfo - rt_sigqueueinfo 3 __syscall_rt_sigqueueinfo
rt_sigsuspend - rt_sigsuspend 2 __syscall_rt_sigsuspend
rt_sigtimedwait - rt_sigtimedwait 4 __syscall_rt_sigtimedwait
s_getcwd EXTRA getcwd 2 __syscall_getcwd
s_getdents EXTRA getdents 3 __getdents
s_getcwd getcwd getcwd 2 __syscall_getcwd
s_getdents getdents getdents 3 __getdents
s_getpriority getpriority getpriority 2 __syscall_getpriority
s_getresgid getresgid getresgid 3 __syscall_getresgid
s_getresuid getresuid getresuid 3 __syscall_getresuid
s_poll poll poll 3 __syscall_poll
s_pread64 EXTRA pread 5 __syscall_pread64
s_pread64 pread64 pread 5 __syscall_pread64
s_ptrace ptrace ptrace 4 __syscall_ptrace
s_pwrite64 EXTRA pwrite 5 __syscall_pwrite64
s_reboot EXTRA reboot 3 __syscall_reboot
s_pwrite64 pwrite64 pwrite 5 __syscall_pwrite64
s_reboot reboot reboot 3 __syscall_reboot
s_sigaction sigaction sigaction 3 __syscall_sigaction
s_sigpending EXTRA sigpending 1 __syscall_sigpending
s_sigprocmask EXTRA sigprocmask 3 __syscall_sigprocmask
s_sigpending sigpending sigpending 1 __syscall_sigpending
s_sigprocmask sigprocmask sigprocmask 3 __syscall_sigprocmask
s_sigsuspend sigsuspend sigsuspend 3 __syscall_sigsuspend
s_sysctl sysctl _sysctl 1 __syscall__sysctl
s_ustat ustat ustat 2 __syscall_ustat

View File

@ -0,0 +1,152 @@
/* Copyright (C) 1991, 92, 93, 96, 97, 98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
char *__ttyname = NULL;
static char * getttyname __P ((const char *dev, int fd, dev_t mydev,
ino_t myino, int save, int *dostat))
internal_function;
static char *
internal_function
getttyname (dev, fd, mydev, myino, save, dostat)
const char *dev;
int fd;
dev_t mydev;
ino_t myino;
int save;
int *dostat;
{
static char *name;
static size_t namelen = 0;
struct stat st;
DIR *dirstream;
struct dirent *d;
size_t devlen = strlen (dev) + 1;
dirstream = opendir (dev);
if (dirstream == NULL)
{
*dostat = -1;
return NULL;
}
while ((d = readdir (dirstream)) != NULL)
if (((ino_t) d->d_fileno == myino || *dostat)
&& strcmp (d->d_name, "stdin")
&& strcmp (d->d_name, "stdout")
&& strcmp (d->d_name, "stderr"))
{
size_t dlen = _D_ALLOC_NAMLEN (d);
if (devlen + dlen > namelen)
{
free (name);
namelen = 2 * (devlen + dlen); /* Big enough. */
name = malloc (namelen);
if (! name)
{
*dostat = -1;
/* Perhaps it helps to free the directory stream buffer. */
(void) closedir (dirstream);
return NULL;
}
*((char *) __mempcpy (name, dev, devlen - 1)) = '/';
}
memcpy (&name[devlen], d->d_name, dlen);
if (stat (name, &st) == 0
#ifdef _STATBUF_ST_RDEV
&& S_ISCHR (st.st_mode) && st.st_rdev == mydev
#else
&& (ino_t) d->d_fileno == myino && st.st_dev == mydev
#endif
)
{
(void) closedir (dirstream);
__ttyname = name;
__set_errno (save);
return name;
}
}
(void) closedir (dirstream);
__set_errno (save);
return NULL;
}
/* Return the pathname of the terminal FD is open on, or NULL on errors.
The returned storage is good only until the next call to this function. */
char *
ttyname (fd)
int fd;
{
struct stat st, st1;
int dostat = 0;
char *name;
int save = errno;
if (!__isatty (fd))
return NULL;
if (fstat (fd, &st) < 0)
return NULL;
if (stat ("/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
{
#ifdef _STATBUF_ST_RDEV
name = getttyname ("/dev/pts", fd, st.st_rdev, st.st_ino, save, &dostat);
#else
name = getttyname ("/dev/pts", fd, st.st_dev, st.st_ino, save, &dostat);
#endif
}
else
{
__set_errno (save);
name = NULL;
}
if (!name && dostat != -1)
{
#ifdef _STATBUF_ST_RDEV
name = getttyname ("/dev", fd, st.st_rdev, st.st_ino, save, &dostat);
#else
name = getttyname ("/dev", fd, st.st_dev, st.st_ino, save, &dostat);
#endif
}
if (!name && dostat != -1)
{
dostat = 1;
#ifdef _STATBUF_ST_RDEV
name = getttyname ("/dev", fd, st.st_rdev, st.st_ino, save, &dostat);
#else
name = getttyname ("/dev", fd, st.st_dev, st.st_ino, save, &dostat);
#endif
}
return name;
}

View File

@ -0,0 +1,182 @@
/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <errno.h>
#include <limits.h>
#include <stddef.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
static int getttyname_r __P ((int fd, char *buf, size_t buflen,
dev_t mydev, ino_t myino, int save,
int *dostat)) internal_function;
static int
internal_function
getttyname_r (fd, buf, buflen, mydev, myino, save, dostat)
int fd;
char *buf;
size_t buflen;
dev_t mydev;
ino_t myino;
int save;
int *dostat;
{
struct stat st;
DIR *dirstream;
struct dirent *d;
size_t devlen = strlen (buf);
dirstream = opendir (buf);
if (dirstream == NULL)
{
*dostat = -1;
return errno;
}
while ((d = readdir (dirstream)) != NULL)
if (((ino_t) d->d_fileno == myino || *dostat)
&& strcmp (d->d_name, "stdin")
&& strcmp (d->d_name, "stdout")
&& strcmp (d->d_name, "stderr"))
{
char *cp;
size_t needed = _D_EXACT_NAMLEN (d) + 1;
if (needed > buflen)
{
*dostat = -1;
(void) closedir (dirstream);
__set_errno (ERANGE);
return ERANGE;
}
cp = __stpncpy (buf + devlen, d->d_name, needed);
cp[0] = '\0';
if (stat (buf, &st) == 0
#ifdef _STATBUF_ST_RDEV
&& S_ISCHR (st.st_mode) && st.st_rdev == mydev
#else
&& (ino_t) d->d_fileno == myino && st.st_dev == mydev
#endif
)
{
(void) closedir (dirstream);
__set_errno (save);
return 0;
}
}
(void) closedir (dirstream);
__set_errno (save);
/* It is not clear what to return in this case. `isatty' says FD
refers to a TTY but no entry in /dev has this inode. */
return ENOTTY;
}
/* Store at most BUFLEN character of the pathname of the terminal FD is
open on in BUF. Return 0 on success, otherwise an error number. */
int
__ttyname_r (fd, buf, buflen)
int fd;
char *buf;
size_t buflen;
{
struct stat st, st1;
int dostat = 0;
int save = errno;
int ret;
/* Test for the absolute minimal size. This makes life easier inside
the loop. */
if (!buf)
{
__set_errno (EINVAL);
return EINVAL;
}
if (buflen < sizeof ("/dev/pts/"))
{
__set_errno (ERANGE);
return ERANGE;
}
if (!__isatty (fd))
{
__set_errno (ENOTTY);
return ENOTTY;
}
if (fstat (fd, &st) < 0)
return errno;
/* Prepare the result buffer. */
memcpy (buf, "/dev/pts/", sizeof ("/dev/pts/"));
buflen -= sizeof ("/dev/pts/") - 1;
if (stat (buf, &st1) == 0 && S_ISDIR (st1.st_mode))
{
#ifdef _STATBUF_ST_RDEV
ret = getttyname_r (fd, buf, buflen, st.st_rdev, st.st_ino, save,
&dostat);
#else
ret = getttyname_r (fd, buf, buflen, st.st_dev, st.st_ino, save,
&dostat);
#endif
}
else
{
__set_errno (save);
ret = ENOENT;
}
if (ret && dostat != -1)
{
buf[sizeof ("/dev/") - 1] = '\0';
buflen += sizeof ("pts/") - 1;
#ifdef _STATBUF_ST_RDEV
ret = getttyname_r (fd, buf, buflen, st.st_rdev, st.st_ino, save,
&dostat);
#else
ret = getttyname_r (fd, buf, buflen, st.st_dev, st.st_ino, save,
&dostat);
#endif
}
if (ret && dostat != -1)
{
buf[sizeof ("/dev/") - 1] = '\0';
dostat = 1;
#ifdef _STATBUF_ST_RDEV
ret = getttyname_r (fd, buf, buflen, st.st_rdev, st.st_ino,
save, &dostat);
#else
ret = getttyname_r (fd, buf, buflen, st.st_dev, st.st_ino,
save, &dostat);
#endif
}
return ret;
}
weak_alias (__ttyname_r, ttyname_r)