aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/get_key.c
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-10-31 15:55:02 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-02 14:06:18 +0000
commit7cb503fd746b80c8613a3e76dde93aedb6e75830 (patch)
treeebd1d5e082729d25c2b3d603b7bb8336cecfbc28 /com32/elflink/ldlinux/get_key.c
parent06f042df3c483c442f1150b862ef043711288f5e (diff)
downloadsyslinux-7cb503fd746b80c8613a3e76dde93aedb6e75830.tar.gz
syslinux-7cb503fd746b80c8613a3e76dde93aedb6e75830.tar.xz
syslinux-7cb503fd746b80c8613a3e76dde93aedb6e75830.zip
ldlinux: get_key() requires raw access to user input
commit 4503e6260c0 ("ldlinux: Use stdcon instead of rawcon for the console") broke get_key() because it was no longer possible to read raw data from stdin. Provide a new function raw_read() that will return user input a character at a time. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/elflink/ldlinux/get_key.c')
-rw-r--r--com32/elflink/ldlinux/get_key.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/com32/elflink/ldlinux/get_key.c b/com32/elflink/ldlinux/get_key.c
index 0be06b98..123171ae 100644
--- a/com32/elflink/ldlinux/get_key.c
+++ b/com32/elflink/ldlinux/get_key.c
@@ -41,6 +41,7 @@
#include <sys/times.h>
#include <getkey.h>
#include <libutil.h>
+#include <sys/file.h>
struct keycode {
int code;
@@ -146,6 +147,25 @@ int get_key_decode(char *buffer, int nc, int *code)
return rv;
}
+#ifdef __COM32__
+extern ssize_t __rawcon_read(struct file_info *fp, void *buf, size_t count);
+
+int raw_read(int fd, void *buf, size_t count)
+{
+ (void)fd;
+
+ /*
+ * Instead of using the read(2) stdlib function use
+ * __rawcon_read() directly since we want a single key and
+ * don't want any processing/batching of the user input to
+ * occur - we want the raw data.
+ */
+ return __rawcon_read(NULL, buf, count);
+}
+#else
+extern int raw_read(int fd, void *buf, size_t count);
+#endif
+
int get_key(FILE * f, clock_t timeout)
{
char buffer[KEY_MAXLEN];
@@ -162,7 +182,7 @@ int get_key(FILE * f, clock_t timeout)
nc = 0;
start = times(NULL);
do {
- rv = read(fileno(f), &ch, 1);
+ rv = raw_read(fileno(f), &ch, 1);
if (rv == 0 || (rv == -1 && errno == EAGAIN)) {
clock_t lateness = times(NULL) - start;
if (nc && lateness > 1 + KEY_TIMEOUT) {