summaryrefslogtreecommitdiff
path: root/hurd
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2010-02-22 16:34:12 +0100
committerAndreas Schwab <schwab@redhat.com>2010-02-22 16:41:22 +0100
commit2b6e16c5e2fa8ad12b02a218ba32d63a4dffda18 (patch)
treeb931e143f212d5b656497bb0c3f3e3a413fc78e1 /hurd
parent0c3f133ed106996172dd2c106b22e38ce695e63d (diff)
parent199428c19774c12b3c4b6e6486ea9d4a021288af (diff)
Merge remote branch 'origin/master' into fedora/master
Diffstat (limited to 'hurd')
-rw-r--r--hurd/hurd/ioctl.h2
-rw-r--r--hurd/hurdioctl.c44
2 files changed, 26 insertions, 20 deletions
diff --git a/hurd/hurd/ioctl.h b/hurd/hurd/ioctl.h
index ee156f02f9..e5ab3dc965 100644
--- a/hurd/hurd/ioctl.h
+++ b/hurd/hurd/ioctl.h
@@ -57,7 +57,7 @@ extern int hurd_register_ioctl_handler (int first_request, int last_request,
static const struct ioctl_handler handler##_ioctl_handler##moniker \
__attribute__ ((__unused__)) = \
{ _IOC_NOTYPE (first), _IOC_NOTYPE (last), \
- (int (*) (int, int, void *)) (handler), NULL }; \
+ (ioctl_handler_t) (handler), NULL }; \
text_set_element (_hurd_ioctl_handler_lists, \
handler##_ioctl_handler##moniker)
#define _HURD_HANDLE_IOCTLS(handler, first, last) \
diff --git a/hurd/hurdioctl.c b/hurd/hurdioctl.c
index 7c689841ca..04d98629ef 100644
--- a/hurd/hurdioctl.c
+++ b/hurd/hurdioctl.c
@@ -1,5 +1,5 @@
/* ioctl commands which must be done in the C library.
- Copyright (C) 1994,95,96,97,99,2001,2002,2009
+ Copyright (C) 1994,95,96,97,99,2001,2002,2009,2010
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -239,34 +239,40 @@ _hurd_setcttyid (mach_port_t cttyid)
}
-/* Make FD be the controlling terminal.
- This function is called for `ioctl (fd, TCIOSCTTY)'. */
-
-static int
-tiocsctty (int fd,
- int request) /* Always TIOCSCTTY. */
+static inline error_t
+do_tiocsctty (io_t port, io_t ctty)
{
mach_port_t cttyid;
error_t err;
- /* Get FD's cttyid port, unless it is already ours. */
- err = HURD_DPORT_USE (fd, ctty != MACH_PORT_NULL ? EADDRINUSE :
- __term_getctty (port, &cttyid));
- if (err == EADDRINUSE)
- /* FD is already the ctty. Nothing to do. */
+ if (ctty != MACH_PORT_NULL)
+ /* PORT is already the ctty. Nothing to do. */
return 0;
- else if (err)
- return __hurd_fail (err);
+
+ /* Get PORT's cttyid port. */
+ err = __term_getctty (port, &cttyid);
+ if (err)
+ return err;
/* Change the terminal's pgrp to ours. */
- err = HURD_DPORT_USE (fd, __tioctl_tiocspgrp (port, _hurd_pgrp));
+ err = __tioctl_tiocspgrp (port, _hurd_pgrp);
if (err)
- return __hurd_fail (err);
+ __mach_port_deallocate (__mach_task_self (), cttyid);
+ else
+ /* Make it our own. */
+ install_ctty (cttyid);
- /* Make it our own. */
- install_ctty (cttyid);
+ return err;
+}
- return 0;
+/* Make FD be the controlling terminal.
+ This function is called for `ioctl (fd, TCIOSCTTY)'. */
+
+static int
+tiocsctty (int fd,
+ int request) /* Always TIOCSCTTY. */
+{
+ return __hurd_fail (HURD_DPORT_USE (fd, do_tiocsctty (port, ctty)));
}
_HURD_HANDLE_IOCTL (tiocsctty, TIOCSCTTY);