Browse Source

[ui] Allow Ctrl-C to cancel wait for net device link-up

This really ought to be handled via monojob.c and the usual Ctrl-C
mechanism that handles cancelling DHCP or file downloads.
tags/v0.9.7
Michael Brown 16 years ago
parent
commit
52c596bafb
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      src/usr/ifmgmt.c

+ 9
- 0
src/usr/ifmgmt.c View File

20
 #include <stdio.h>
20
 #include <stdio.h>
21
 #include <unistd.h>
21
 #include <unistd.h>
22
 #include <errno.h>
22
 #include <errno.h>
23
+#include <console.h>
23
 #include <gpxe/netdevice.h>
24
 #include <gpxe/netdevice.h>
24
 #include <gpxe/device.h>
25
 #include <gpxe/device.h>
25
 #include <gpxe/process.h>
26
 #include <gpxe/process.h>
27
+#include <gpxe/keys.h>
26
 #include <usr/ifmgmt.h>
28
 #include <usr/ifmgmt.h>
27
 
29
 
28
 /** @file
30
 /** @file
101
  * @v max_wait_ms	Maximum time to wait, in ms
103
  * @v max_wait_ms	Maximum time to wait, in ms
102
  */
104
  */
103
 int iflinkwait ( struct net_device *netdev, unsigned int max_wait_ms ) {
105
 int iflinkwait ( struct net_device *netdev, unsigned int max_wait_ms ) {
106
+	int key;
107
+
104
 	while ( 1 ) {
108
 	while ( 1 ) {
105
 		if ( netdev_link_ok ( netdev ) )
109
 		if ( netdev_link_ok ( netdev ) )
106
 			return 0;
110
 			return 0;
107
 		if ( max_wait_ms-- == 0 )
111
 		if ( max_wait_ms-- == 0 )
108
 			return -ETIMEDOUT;
112
 			return -ETIMEDOUT;
109
 		step();
113
 		step();
114
+		if ( iskey() ) {
115
+			key = getchar();
116
+			if ( key == CTRL_C )
117
+				return -ECANCELED;
118
+		}
110
 		mdelay ( 1 );
119
 		mdelay ( 1 );
111
 	}
120
 	}
112
 }
121
 }

Loading…
Cancel
Save