From 93d66ddc2095c19a19df0f7d32cfda0560b3dfe6 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 14 Apr 2004 09:12:04 +0000 Subject: [PATCH] * cygwin.din: Export rand_r and ttyname_r. * syscalls.cc (ttyname_r): New function. (ttyname): Move functionality to ttyname_r. Call it from here. * include/cygwin/version.h: Bump API minor number. --- winsup/cygwin/ChangeLog | 19 +++++++++----- winsup/cygwin/cygwin.din | 2 ++ winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/syscalls.cc | 35 +++++++++++++++++++++----- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5be12c968..db6a4c78f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,11 +1,18 @@ +2004-04-14 Corinna Vinschen + + * cygwin.din: Export rand_r and ttyname_r. + * syscalls.cc (ttyname_r): New function. + (ttyname): Move functionality to ttyname_r. Call it from here. + * include/cygwin/version.h: Bump API minor number. + 2004-04-14 Pierre Humblet - * path.h (path_conv::set_symlink): Add argument. - (path_conv::get_symlink_length): New method. - (path_conv::symlink_length): New member. - * path.cc (path_conv::check): Pass symlen to set_symlink. - * fhandler_disk_file.cc (fhandler_base::fstat_helper): For symlinks - set st_size from get_symlink_length. + * path.h (path_conv::set_symlink): Add argument. + (path_conv::get_symlink_length): New method. + (path_conv::symlink_length): New member. + * path.cc (path_conv::check): Pass symlen to set_symlink. + * fhandler_disk_file.cc (fhandler_base::fstat_helper): For symlinks + set st_size from get_symlink_length. 2004-04-13 Corinna Vinschen diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index bb322360b..dd8cbee58 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -1067,6 +1067,7 @@ raise SIGFE _raise = raise SIGFE rand NOSIGFE _rand = rand NOSIGFE +rand_r NOSIGFE random NOSIGFE read SIGFE _read = read SIGFE @@ -1438,6 +1439,7 @@ truncf NOSIGFE tsearch SIGFE ttyname SIGFE _ttyname = ttyname SIGFE +ttyname_r SIGFE ttyslot NOSIGFE twalk NOSIGFE tzset SIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 2db2e9bdc..b63fcc15b 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -240,12 +240,13 @@ details. */ 112: Redefine some mtget fields. 113: Again redefine some mtget fields. Use mt_fileno and mt_blkno as on Linux. + 114: Export rand_r, ttyname_r. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 113 +#define CYGWIN_VERSION_API_MINOR 114 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index ed8b902d6..daae8a38f 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1511,15 +1511,38 @@ pathconf (const char *file, int v) } } +extern "C" int +ttyname_r (int fd, char *buf, size_t buflen) +{ + int ret = 0; + if (__check_null_invalid_struct (buf, buflen)) + ret = EINVAL; + else + { + cygheap_fdget cfd (fd, true); + if (cfd < 0) + ret = EBADF; + else if (!cfd->is_tty ()) + ret = ENOTTY; + else if (buflen < strlen (cfd->ttyname ()) + 1) + ret = ERANGE; + else + strcpy (buf, cfd->ttyname ()); + } + debug_printf ("returning %d tty: %s", ret, ret ? "NULL" : buf); + return ret; +} + extern "C" char * ttyname (int fd) { - char *name; - cygheap_fdget cfd (fd); - if (cfd < 0 || !cfd->is_tty ()) - return 0; - name = (char *) (cfd->ttyname ()); - debug_printf ("returning %s", name); + static char name[CYG_MAX_PATH]; + int ret = ttyname_r (fd, name, CYG_MAX_PATH); + if (ret) + { + set_errno (ret); + return NULL; + } return name; }