summaryrefslogtreecommitdiff
path: root/term
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1999-10-04 14:39:04 +0000
committerThomas Bushnell <thomas@gnu.org>1999-10-04 14:39:04 +0000
commit6edeb62e3980f1a3769ed74cb81567744b5b6e92 (patch)
tree22add65c288e7b6fccbae236ef56fabfddf194db /term
parentffca5c4649a2808f523532728c4f1e9a0be0b912 (diff)
1999-10-04 Thomas Bushnell, BSG <tb@mit.edu>
* term.h, devio.c, users.c: Revert previous change. Do it this way instead: * users.c (report_carrier_error): New function. (carrier_error): New static global variable. (open_hook): Deal with errors from carrier open. * devio.c (device_open_reply): Move the !RETURNCODE case out of the "initial open" case and use report_carrier_error. * term.h (report_carrier_error): Declare new function.
Diffstat (limited to 'term')
-rw-r--r--term/ChangeLog12
-rw-r--r--term/devio.c35
-rw-r--r--term/term.h5
-rw-r--r--term/users.c41
4 files changed, 46 insertions, 47 deletions
diff --git a/term/ChangeLog b/term/ChangeLog
index 29bb8b73..be515205 100644
--- a/term/ChangeLog
+++ b/term/ChangeLog
@@ -1,3 +1,14 @@
+1999-10-04 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * term.h, devio.c, users.c: Revert previous change. Do it this
+ way instead:
+ * users.c (report_carrier_error): New function.
+ (carrier_error): New static global variable.
+ (open_hook): Deal with errors from carrier open.
+ * devio.c (device_open_reply): Move the !RETURNCODE case out of
+ the "initial open" case and use report_carrier_error.
+ * term.h (report_carrier_error): Declare new function.
+
1999-10-01 Roland McGrath <roland@baalperazim.frob.com>
* term.h (NO_DEVICE): New macro, bit for termflags.
@@ -7,6 +18,7 @@
* users.c (open_hook): If NO_DEVICE flag set, return ENXIO immediately.
If we put out an open request, check for that bit as well as
NO_CARRIER changing in termflags and diagnose with ENXIO.
+
* Makefile (device_replyServer-CPPFLAGS): New variable, turn off
TypeCheck for this stub. This is necessary for error replies to get
through to our server-side functions in devio.c.
diff --git a/term/devio.c b/term/devio.c
index ce12b085..2306fa3b 100644
--- a/term/devio.c
+++ b/term/devio.c
@@ -500,32 +500,23 @@ device_open_reply (mach_port_t replyport,
assert (open_pending != NOTPENDING);
- if (open_pending == INITIAL)
+ if (returncode != 0)
{
- /* Special handling for the first open */
-
- if (returncode != 0)
- {
- /* Note that DEVICE is total garbage (not a real port name at all!)
- in this case. */
-
- if (returncode == D_NO_SUCH_DEVICE)
- /* Record that the device does not exist. */
- termflags |= NO_DEVICE;
+ report_carrier_error (returncode);
- /* Bogus. */
- report_carrier_on ();
- report_carrier_off ();
+ mach_port_deallocate (mach_task_self (), phys_reply);
+ phys_reply = MACH_PORT_NULL;
+ ports_port_deref (phys_reply_pi);
+ phys_reply_pi = 0;
- mach_port_deallocate (mach_task_self (), phys_reply);
- phys_reply = MACH_PORT_NULL;
- ports_port_deref (phys_reply_pi);
- phys_reply_pi = 0;
+ open_pending = NOTPENDING;
+ mutex_unlock (&global_lock);
+ return 0;
+ }
- open_pending = NOTPENDING;
- mutex_unlock (&global_lock);
- return 0;
- }
+ if (open_pending == INITIAL)
+ {
+ /* Special handling for the first open */
assert (phys_device == MACH_PORT_NULL);
assert (phys_reply_writes == MACH_PORT_NULL);
diff --git a/term/term.h b/term/term.h
index 64769fc1..4fece7ee 100644
--- a/term/term.h
+++ b/term/term.h
@@ -25,7 +25,6 @@
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
-#include <stdint.h>
#undef MDMBUF
#undef ECHO
@@ -66,7 +65,7 @@
struct termios termstate;
/* Other state with the following bits: */
-uint_fast32_t termflags;
+long termflags;
#define USER_OUTPUT_SUSP 0x00000001 /* user has suspended output */
#define TTY_OPEN 0x00000002 /* someone has us open */
@@ -79,7 +78,6 @@ uint_fast32_t termflags;
#define EXCL_USE 0x00000100 /* user accessible exclusive use */
#define NO_OWNER 0x00000200 /* there is no foreground_id */
#define ICKY_ASYNC 0x00000400 /* some user has set O_ASYNC */
-#define NO_DEVICE 0x00000800 /* the device does not exist */
#define QUEUE_LOWAT 100
#define QUEUE_HIWAT 300
@@ -311,6 +309,7 @@ queue_erase (struct queue *q)
int input_character (int);
void report_carrier_on (void);
void report_carrier_off (void);
+void report_carrier_error (error_t);
/* Other decls */
diff --git a/term/users.c b/term/users.c
index 6a5228b0..1168ca10 100644
--- a/term/users.c
+++ b/term/users.c
@@ -72,6 +72,8 @@ static int sigs_in_progress;
static struct condition input_sig_wait = CONDITION_INITIALIZER;
static int input_sig_wakeup;
+static error_t carrier_error;
+
/* Attach this on the hook of any protid that is a ctty. */
struct protid_hook
{
@@ -144,19 +146,10 @@ open_hook (struct trivfs_control *cntl,
return pty_open_hook (cntl, user, flags);
if ((flags & (O_READ|O_WRITE)) == 0)
- /* Not asking for a port that can do i/o (just stat or chmod or whatnot),
- so there is nothing else we need to think about. */
return 0;
mutex_lock (&global_lock);
- if (termflags & NO_DEVICE)
- {
- /* We previously discovered that the underlying device doesn't exist. */
- mutex_unlock (&global_lock);
- return ENXIO;
- }
-
if (!(termflags & TTY_OPEN))
{
bzero (&termstate, sizeof termstate);
@@ -203,31 +196,28 @@ open_hook (struct trivfs_control *cntl,
}
/* Wait for carrier to turn on. */
- while ((termflags & (NO_CARRIER|NO_DEVICE)) == NO_CARRIER
- && !(termstate.c_cflag & CLOCAL)
+ while (((termflags & NO_CARRIER) && !(termstate.c_cflag & CLOCAL))
&& !(flags & O_NONBLOCK)
&& !cancel)
cancel = hurd_condition_wait (&carrier_alert, &global_lock);
- if (termflags & NO_DEVICE)
- {
- /* The open of the underlying device returned an error indicating
- that no such device exists. */
- mutex_unlock (&global_lock);
- return ENXIO;
- }
-
if (cancel)
{
mutex_unlock (&global_lock);
return EINTR;
}
- termflags |= TTY_OPEN;
- (*bottom->set_bits) ();
+ err = carrier_error;
+ carrier_error = 0;
+
+ if (!err)
+ {
+ termflags |= TTY_OPEN;
+ (*bottom->set_bits) ();
+ }
mutex_unlock (&global_lock);
- return 0;
+ return err;
}
error_t (*trivfs_check_open_hook) (struct trivfs_control *,
struct iouser *, int)
@@ -2162,6 +2152,13 @@ report_carrier_on ()
condition_broadcast (&carrier_alert);
}
+void
+report_carrier_error (error_t err)
+{
+ carrier_error = err;
+ condition_broadcast (&carrier_alert);
+}
+
kern_return_t
S_term_get_nodename (io_t arg,
char *name)