[Glibc-bsd-commits] r3257 - trunk/glibc-ports/kfreebsd
Aurelien Jarno
aurel32 at alioth.debian.org
Tue Feb 8 18:35:15 UTC 2011
Author: aurel32
Date: 2011-02-08 18:35:09 +0000 (Tue, 08 Feb 2011)
New Revision: 3257
Modified:
trunk/glibc-ports/kfreebsd/ptsname.c
Log:
Add a __ptsname_internal() function similarly to what has been done upstream
in commit aa9890239a2aef81e64f3f22a31c7e01b6501f69.
Modified: trunk/glibc-ports/kfreebsd/ptsname.c
===================================================================
--- trunk/glibc-ports/kfreebsd/ptsname.c 2011-02-08 16:32:12 UTC (rev 3256)
+++ trunk/glibc-ports/kfreebsd/ptsname.c 2011-02-08 18:35:09 UTC (rev 3257)
@@ -44,14 +44,10 @@
extern const char __libc_ptyname2[] attribute_hidden;
-/* Store at most BUFLEN characters of the pathname of the slave pseudo
- terminal associated with the master FD is open on in BUF.
- Return 0 on success, otherwise an error number. */
int
-__ptsname_r (int fd, char *buf, size_t buflen)
+__ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp)
{
int saved_errno = errno;
- struct stat64 st;
char *p;
if (buf == NULL)
@@ -62,11 +58,11 @@
/* Don't call isatty (fd) - it usually fails with errno = EAGAIN. */
- if (__fxstat64 (_STAT_VER, fd, &st) < 0)
+ if (__fxstat64 (_STAT_VER, fd, stp) < 0)
return errno;
/* Check if FD really is a master pseudo terminal. */
- if (!(S_ISCHR (st.st_mode)))
+ if (!(S_ISCHR (stp->st_mode)))
{
__set_errno (ENOTTY);
return ENOTTY;
@@ -82,16 +78,16 @@
/* instead of strlen(_PATH_DEV) we use (sizeof (_PATH_DEV) - 1) */
p = __mempcpy (buf, _PATH_DEV, sizeof (_PATH_DEV) - 1);
buflen -= (sizeof (_PATH_DEV) - 1);
- if(__sysctlbyname("kern.devname", p, &buflen, &st.st_rdev, sizeof (st.st_rdev)) < 0)
+ if(__sysctlbyname("kern.devname", p, &buflen, &stp->st_rdev, sizeof (stp->st_rdev)) < 0)
return errno;
p[0] = 't';
- if (__xstat64 (_STAT_VER, buf, &st) < 0)
+ if (__xstat64 (_STAT_VER, buf, stp) < 0)
return errno;
/* Check if the pathname we're about to return might be
slave pseudo terminal of the given master pseudo terminal. */
- if (!(S_ISCHR (st.st_mode)))
+ if (!(S_ISCHR (stp->st_mode)))
{
/* This really is a configuration problem. */
__set_errno (ENOTTY);
@@ -101,4 +97,15 @@
__set_errno (saved_errno);
return 0;
}
+
+
+/* Store at most BUFLEN characters of the pathname of the slave pseudo
+ terminal associated with the master FD is open on in BUF.
+ Return 0 on success, otherwise an error number. */
+int
+__ptsname_r (int fd, char *buf, size_t buflen)
+{
+ struct stat64 st;
+ return __ptsname_internal (fd, buf, buflen, &st);
+}
weak_alias (__ptsname_r, ptsname_r)
More information about the Glibc-bsd-commits
mailing list