summary refs log tree commit diff
path: root/sysdeps/mach/hurd/ptsname.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-03-19 15:32:17 +0000
committerRoland McGrath <roland@gnu.org>1999-03-19 15:32:17 +0000
commit0702b5f4fb6041e8f753b871de8a7152d4103d66 (patch)
tree738b90aa3a9c589d2ca130881f1ddb7ba1570b76 /sysdeps/mach/hurd/ptsname.c
parent6b4bb8747ef7ff509c99635a93d3e1b78e88dc0e (diff)
downloadglibc-0702b5f4fb6041e8f753b871de8a7152d4103d66.tar.gz
glibc-0702b5f4fb6041e8f753b871de8a7152d4103d66.tar.xz
glibc-0702b5f4fb6041e8f753b871de8a7152d4103d66.zip
1999-03-19 Roland McGrath <roland@baalperazim.frob.com>
* sysdeps/mach/hurd/fcntl.c (__fcntl: case F_GETLK,F_SETLK,F_SETLKW): 
Support whole-file locking (only) by using the file_lock RPC.  This 
has very wrong semantics, but is better than nothing for the time 
being.  (Correct POSIX.1 locking will require new RPCs in the Hurd 
protocols that will be somewhat hairy to specify.)
Diffstat (limited to 'sysdeps/mach/hurd/ptsname.c')
-rw-r--r--sysdeps/mach/hurd/ptsname.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/sysdeps/mach/hurd/ptsname.c b/sysdeps/mach/hurd/ptsname.c
new file mode 100644
index 0000000000..95b91cf07e
--- /dev/null
+++ b/sysdeps/mach/hurd/ptsname.c
@@ -0,0 +1,65 @@
+/* ptsname -- return the name of a pty slave given an FD to the pty master
+   Copyright (C) 1999 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 <string.h>
+#include <hurd.h>
+#include <hurd/fd.h>
+#include <hurd/term.h>
+
+
+/* Return the pathname of the pseudo terminal slave associated with
+   the master FD is open on, or NULL on errors.
+   The returned storage is good until the next call to this function.  */
+char *
+ptsname (int fd)
+{
+  static char peername[1024];  /* XXX */
+  error_t err;
+
+  err = __ptsname_r (fd, peername, sizeof (peername));
+  if (err)
+    __set_errno (err);
+
+  return err ? NULL : peername;
+}
+
+
+/* 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)
+{
+  char peername[1024];  /* XXX */
+  size_t len;
+  error_t err;
+
+  peername[0] = '\0';
+  if (err = HURD_DPORT_USE (fd, __term_get_peername (port, peername)))
+    return _hurd_fd_error (fd, err);
+
+  len = strlen (peername) + 1;
+  if (len > buflen)
+    return ERANGE;
+
+  memcpy (buf, peername, len);
+  return 0;
+}
+weak_alias (__ptsname_r, ptsname_r)