Mercurial > gnulib
annotate lib/ptsname_r.c @ 19190:9759915b2aca
all: prefer https: URLs
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 13 Sep 2017 00:48:18 -0700 |
parents | 12df2165ec1c |
children | d86e08b1f555 |
rev | line source |
---|---|
16067 | 1 /* Determine name of the slave side of a pseudo-terminal. |
18626 | 2 Copyright (C) 1998, 2002, 2010-2017 Free Software Foundation, Inc. |
16067 | 3 |
4 This program is free software: you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 3 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
16067 | 16 |
17 #include <config.h> | |
18 | |
19 #include <stdlib.h> | |
20 | |
21 #include <errno.h> | |
16940
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
22 #include <fcntl.h> |
16067 | 23 #include <string.h> |
24 #include <sys/stat.h> | |
25 #include <unistd.h> | |
26 | |
27 #ifdef _LIBC | |
28 # include <paths.h> | |
29 #else | |
30 # ifndef _PATH_TTY | |
31 # define _PATH_TTY "/dev/tty" | |
32 # endif | |
33 # ifndef _PATH_DEV | |
34 # define _PATH_DEV "/dev/" | |
35 # endif | |
36 | |
18372
d9961cf477d9
maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents:
18189
diff
changeset
|
37 # undef __set_errno |
d9961cf477d9
maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents:
18189
diff
changeset
|
38 # undef __stat |
d9961cf477d9
maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents:
18189
diff
changeset
|
39 # undef __ttyname_r |
d9961cf477d9
maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents:
18189
diff
changeset
|
40 # undef __ptsname_r |
d9961cf477d9
maint: preprocessor changes to support z/OS
Daniel Richard G <skunk@iSKUNK.ORG>
parents:
18189
diff
changeset
|
41 |
16067 | 42 # define __set_errno(e) errno = (e) |
43 # define __isatty isatty | |
44 # define __stat stat | |
45 # define __ttyname_r ttyname_r | |
46 # define __ptsname_r ptsname_r | |
47 | |
48 #endif | |
49 | |
18532
93a8694eca79
ptsname_r: leverage AC_HEADER_MAJOR
Mike Frysinger <vapier@gentoo.org>
parents:
18372
diff
changeset
|
50 /* Get the major, minor macros. */ |
93a8694eca79
ptsname_r: leverage AC_HEADER_MAJOR
Mike Frysinger <vapier@gentoo.org>
parents:
18372
diff
changeset
|
51 #if MAJOR_IN_MKDEV |
93a8694eca79
ptsname_r: leverage AC_HEADER_MAJOR
Mike Frysinger <vapier@gentoo.org>
parents:
18372
diff
changeset
|
52 # include <sys/mkdev.h> |
93a8694eca79
ptsname_r: leverage AC_HEADER_MAJOR
Mike Frysinger <vapier@gentoo.org>
parents:
18372
diff
changeset
|
53 #endif |
93a8694eca79
ptsname_r: leverage AC_HEADER_MAJOR
Mike Frysinger <vapier@gentoo.org>
parents:
18372
diff
changeset
|
54 #if MAJOR_IN_SYSMACROS |
93a8694eca79
ptsname_r: leverage AC_HEADER_MAJOR
Mike Frysinger <vapier@gentoo.org>
parents:
18372
diff
changeset
|
55 # include <sys/sysmacros.h> |
93a8694eca79
ptsname_r: leverage AC_HEADER_MAJOR
Mike Frysinger <vapier@gentoo.org>
parents:
18372
diff
changeset
|
56 #endif |
93a8694eca79
ptsname_r: leverage AC_HEADER_MAJOR
Mike Frysinger <vapier@gentoo.org>
parents:
18372
diff
changeset
|
57 |
16942
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
58 #ifdef __sun |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
59 /* Get ioctl() and 'struct strioctl'. */ |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
60 # include <stropts.h> |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
61 /* Get ISPTM. */ |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
62 # include <sys/stream.h> |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
63 # include <sys/ptms.h> |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
64 # include <stdio.h> |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
65 #endif |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
66 |
16945
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
67 #if defined _AIX || defined __osf__ |
16944
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
68 /* Get ioctl(), ISPTM. */ |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
69 # include <sys/ioctl.h> |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
70 # include <stdio.h> |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
71 #endif |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
72 |
16067 | 73 |
74 /* Store at most BUFLEN characters of the pathname of the slave pseudo | |
75 terminal associated with the master FD is open on in BUF. | |
76 Return 0 on success, otherwise an error number. */ | |
77 int | |
78 __ptsname_r (int fd, char *buf, size_t buflen) | |
79 { | |
80 int save_errno = errno; | |
81 int err; | |
82 struct stat st; | |
83 | |
84 if (buf == NULL) | |
85 { | |
86 __set_errno (EINVAL); | |
87 return EINVAL; | |
88 } | |
89 | |
16942
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
90 #if defined __sun /* Solaris */ |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
91 if (fstat (fd, &st) < 0) |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
92 return errno; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
93 if (!(S_ISCHR (st.st_mode) && major (st.st_rdev) == 0)) |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
94 { |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
95 errno = ENOTTY; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
96 return errno; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
97 } |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
98 { |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
99 /* Master ptys can be recognized through a STREAMS ioctl. See |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
100 "STREAMS-based Pseudo-Terminal Subsystem" |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
101 <http://docs.oracle.com/cd/E18752_01/html/816-4855/termsub15-44781.html> |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
102 and "STREAMS ioctl commands" |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
103 <http://docs.oracle.com/cd/E18752_01/html/816-5177/streamio-7i.html> |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
104 */ |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
105 struct strioctl ioctl_arg; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
106 ioctl_arg.ic_cmd = ISPTM; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
107 ioctl_arg.ic_timout = 0; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
108 ioctl_arg.ic_len = 0; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
109 ioctl_arg.ic_dp = NULL; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
110 |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
111 if (ioctl (fd, I_STR, &ioctl_arg) < 0) |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
112 { |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
113 errno = ENOTTY; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
114 return errno; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
115 } |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
116 } |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
117 { |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
118 char tmpbuf[9 + 10 + 1]; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
119 int n = sprintf (tmpbuf, "/dev/pts/%u", minor (st.st_rdev)); |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
120 if (n >= buflen) |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
121 { |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
122 errno = ERANGE; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
123 return errno; |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
124 } |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
125 memcpy (buf, tmpbuf, n + 1); |
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
126 } |
16945
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
127 #elif defined _AIX || defined __osf__ /* AIX, OSF/1 */ |
16944
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
128 /* This implementation returns /dev/pts/N, like ptsname() does. |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
129 Whereas the generic implementation below returns /dev/ttypN. |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
130 Both are correct, but let's be consistent with ptsname(). */ |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
131 if (fstat (fd, &st) < 0) |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
132 return errno; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
133 if (!S_ISCHR (st.st_mode)) |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
134 { |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
135 errno = ENOTTY; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
136 return errno; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
137 } |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
138 { |
16945
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
139 int ret; |
16944
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
140 int dev; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
141 char tmpbuf[9 + 10 + 1]; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
142 int n; |
16945
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
143 # ifdef _AIX |
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
144 ret = ioctl (fd, ISPTM, &dev); |
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
145 # endif |
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
146 # ifdef __osf__ |
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
147 ret = ioctl (fd, ISPTM, NULL); |
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
148 dev = ret; |
af6492941f0d
ptsname_r: Make it consistent with ptsname on AIX.
Bruno Haible <bruno@clisp.org>
parents:
16944
diff
changeset
|
149 # endif |
16946
f34e11adfc84
ptsname_r: Fix typo in last commit.
Bruno Haible <bruno@clisp.org>
parents:
16945
diff
changeset
|
150 if (ret < 0) |
16944
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
151 { |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
152 errno = ENOTTY; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
153 return errno; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
154 } |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
155 n = sprintf (tmpbuf, "/dev/pts/%u", minor (dev)); |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
156 if (n >= buflen) |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
157 { |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
158 errno = ERANGE; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
159 return errno; |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
160 } |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
161 memcpy (buf, tmpbuf, n + 1); |
00ae3faf06c6
ptsname_r: Make it consistent with ptsname on OSF/1.
Bruno Haible <bruno@clisp.org>
parents:
16942
diff
changeset
|
162 } |
16942
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
163 #else |
16067 | 164 if (!__isatty (fd)) |
16940
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
165 { |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
166 #if ISATTY_FAILS_WITHOUT_SETTING_ERRNO && defined F_GETFL /* IRIX, Solaris */ |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
167 /* Set errno. */ |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
168 if (fcntl (fd, F_GETFL) != -1) |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
169 errno = ENOTTY; |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
170 #else |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
171 /* We rely on isatty to set errno properly (i.e. EBADF or ENOTTY). */ |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
172 #endif |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
173 return errno; |
f0c9b2dc0596
ptsname_r: Fix test failures on IRIX, Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
174 } |
16067 | 175 |
176 if (buflen < strlen (_PATH_TTY) + 3) | |
177 { | |
178 __set_errno (ERANGE); | |
179 return ERANGE; | |
180 } | |
181 | |
182 err = __ttyname_r (fd, buf, buflen); | |
183 if (err != 0) | |
184 { | |
185 __set_errno (err); | |
186 return errno; | |
187 } | |
188 | |
17125
99a0d94bccb1
ptsname_r: support ptys returned by FreeBSD posix_openpt
Eric Blake <eblake@redhat.com>
parents:
16946
diff
changeset
|
189 if (strncmp(buf, "/dev/pts/", strlen("/dev/pts/")) != 0) |
99a0d94bccb1
ptsname_r: support ptys returned by FreeBSD posix_openpt
Eric Blake <eblake@redhat.com>
parents:
16946
diff
changeset
|
190 buf[sizeof (_PATH_DEV) - 1] = 't'; |
16942
17843e284264
ptsname_r: Add support for Solaris.
Bruno Haible <bruno@clisp.org>
parents:
16940
diff
changeset
|
191 #endif |
16067 | 192 |
193 if (__stat (buf, &st) < 0) | |
194 return errno; | |
195 | |
196 __set_errno (save_errno); | |
197 return 0; | |
198 } |