[syslinux:elflink] com32: Add com32_cmdline() which returns argv[ 1..argc-1]

syslinux-bot for Matt Fleming matt.fleming at intel.com
Sat Feb 23 04:30:04 PST 2013


Commit-ID:  41c29c26d70fde563d7c255872bbadad87a39dfa
Gitweb:     http://www.syslinux.org/commit/41c29c26d70fde563d7c255872bbadad87a39dfa
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Fri, 22 Feb 2013 15:13:38 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Sat, 23 Feb 2013 11:52:17 +0000

com32: Add com32_cmdline() which returns argv[1..argc-1]

cmd.c32 needs an equivalent of __com32.cs_cmdline now that the COMBOOT
code is dead. Introducing com32_cmdline(), which returns a string
consisting of module arguments from argv[1] to argv[argc-1], separated
by spaces.

Reported-by: Gene Cumm <gene.cumm at gmail.com>
Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/include/com32.h     |  2 ++
 com32/modules/cmd.c       |  2 +-
 core/elflink/load_env32.c | 12 ++++++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/com32/include/com32.h b/com32/include/com32.h
index 148d08e..795b9fb 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -206,4 +206,6 @@ static inline far_ptr_t FAR_PTR(void *__ptr)
     return __fptr;
 }
 
+extern const char *com32_cmdline(void);
+
 #endif /* _COM32_H */
diff --git a/com32/modules/cmd.c b/com32/modules/cmd.c
index 5d3f891..233c7ca 100644
--- a/com32/modules/cmd.c
+++ b/com32/modules/cmd.c
@@ -21,6 +21,6 @@
 
 int main(void)
 {
-    syslinux_run_command(__com32.cs_cmdline);
+    syslinux_run_command(com32_cmdline());
     return -1;
 }
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index 50ec266..0483d86 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -186,6 +186,12 @@ out:
 	writestr("\nFailed to load ldlinux.c32");
 }
 
+static const char *__cmdline;
+__export const char *com32_cmdline(void)
+{
+	return __cmdline;
+}
+
 __export int create_args_and_load(char *cmdline)
 {
 	char *p, **argv;
@@ -237,6 +243,12 @@ __export int create_args_and_load(char *cmdline)
 		 */
 		while (*p && isspace(*p))
 			p++;
+
+		/*
+		 * Point __cmdline at "argv[1] ... argv[argc-1]"
+		 */
+		if (i == 0)
+			__cmdline = p;
 	}
 
 	/* NUL-terminate */


More information about the Syslinux-commits mailing list