aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/readconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/elflink/ldlinux/readconfig.c')
-rw-r--r--com32/elflink/ldlinux/readconfig.c85
1 files changed, 46 insertions, 39 deletions
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 9d50c2f3..d6e34bda 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2004-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2009-2013 Intel Corporation; author: H. Peter Anvin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -759,7 +759,6 @@ static uint8_t SerialNotice = 1;
#define DEFAULT_BAUD 9600
#define BAUD_DIVISOR 115200
-#define serial_base 0x0400
extern void sirq_cleanup_nowipe(void);
extern void sirq_install(void);
@@ -771,6 +770,46 @@ extern void loadkeys(char *);
extern char syslinux_banner[];
extern char copyright_str[];
+/*
+ * PATH-based lookup
+ *
+ * Each entry in the PATH directive is separated by a colon, e.g.
+ *
+ * PATH /bar:/bin/foo:/baz/bar/bin
+ */
+static int parse_path(char *p)
+{
+ struct path_entry *entry;
+ const char *str;
+
+ while (*p) {
+ char *c = p;
+
+ /* Find the next directory */
+ while (*c && *c != ':')
+ c++;
+
+ str = refstrndup(p, c - p);
+ if (!str)
+ goto bail;
+
+ entry = path_add(str);
+ refstr_put(str);
+
+ if (!entry)
+ goto bail;
+
+ if (!*c++)
+ break;
+ p = c;
+ }
+
+ return 0;
+
+bail:
+ return -1;
+}
+
static void parse_config_file(FILE * f)
{
char line[MAX_LINE], *p, *ep, ch;
@@ -1185,16 +1224,9 @@ do_include:
refstr_put(filename);
} else if (looking_at(p, "kbdmap")) {
const char *filename;
- char *dst = KernelName;
- size_t len = FILENAME_MAX - 1;
-
- filename = refstrdup(skipspace(p + 4));
-
- while (len-- && not_whitespace(*filename))
- *dst++ = *filename++;
- *dst = '\0';
- loadkeys(KernelName);
+ filename = refstrdup(skipspace(p + 6));
+ loadkeys(filename);
refstr_put(filename);
}
/*
@@ -1280,16 +1312,7 @@ do_include:
baud &= 0xffff;
BaudDivisor = baud;
- /*
- * If port > 3 then port is I/O addr
- */
- if (port <= 3) {
- /* Get the I/O port from the BIOS */
- port <<= 1;
- port = *(volatile uint16_t *)serial_base;
- }
-
-
+ port = get_serial_port(port);
SerialPort = port;
/*
@@ -1347,24 +1370,8 @@ do_include:
} else if (looking_at(p, "say")) {
printf("%s\n", p+4);
} else if (looking_at(p, "path")) {
- /* PATH-based lookup */
- const char *new_path;
- char *_p;
- size_t len, new_len;
-
- new_path = refstrdup(skipspace(p + 4));
- len = strlen(PATH);
- new_len = strlen(new_path);
- _p = malloc(len + new_len + 2);
- if (_p) {
- strncpy(_p, PATH, len);
- _p[len++] = ':';
- strncpy(_p + len, new_path, new_len);
- _p[len + new_len] = '\0';
- free(PATH);
- PATH = _p;
- } else
- printf("Failed to realloc PATH\n");
+ if (parse_path(skipspace(p + 4)))
+ printf("Failed to parse PATH\n");
} else if (looking_at(p, "sendcookies")) {
const union syslinux_derivative_info *sdi;