[syslinux:master] Move modify_adv() into common code

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Thu Jun 24 13:36:13 PDT 2010


Commit-ID:  2e8b89f8b2d711a1689067834113483610fa18cd
Gitweb:     http://syslinux.zytor.com/commit/2e8b89f8b2d711a1689067834113483610fa18cd
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Wed, 23 Jun 2010 16:31:45 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Wed, 23 Jun 2010 16:33:28 -0700

Move modify_adv() into common code

modify_adv() should be used by any installer which uses the common
CLI, so it should go into syslxopt.c.

Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>


---
 extlinux/main.c         |   25 -------------------------
 libinstaller/syslxopt.c |   29 +++++++++++++++++++++++++++++
 libinstaller/syslxopt.h |    1 +
 linux/syslinux.c        |   18 ------------------
 4 files changed, 30 insertions(+), 43 deletions(-)

diff --git a/extlinux/main.c b/extlinux/main.c
index c0a37ef..7b0b467 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -279,31 +279,6 @@ int patch_file_and_bootblock(int fd, const char *dir, int devfd)
 }
 
 /*
- * Make any user-specified ADV modifications
- */
-int modify_adv(void)
-{
-    int rv = 0;
-
-    if (opt.set_once) {
-	if (syslinux_setadv(ADV_BOOTONCE, strlen(opt.set_once), opt.set_once)) {
-	    fprintf(stderr, "%s: not enough space for boot-once command\n",
-		    program);
-	    rv = -1;
-	}
-    }
-    if (opt.menu_save) {
-        if (syslinux_setadv(ADV_MENUSAVE, strlen(opt.menu_save), opt.menu_save)) {
-	    fprintf(stderr, "%s: not enough space for menu-save label\n",
-		    program);
-	    rv = -1;
-        }
-    }
-
-    return rv;
-}
-
-/*
  * Install the boot block on the specified device.
  * Must be run AFTER install_file()!
  */
diff --git a/libinstaller/syslxopt.c b/libinstaller/syslxopt.c
index 9fda16d..0ff2efb 100644
--- a/libinstaller/syslxopt.c
+++ b/libinstaller/syslxopt.c
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdint.h>
+#include <string.h>
 #include <getopt.h>
 #include <sysexits.h>
 #include "../version.h"
@@ -206,3 +207,31 @@ void parse_options(int argc, char *argv[], enum syslinux_mode mode)
     if (argv[optind])
 	usage(EX_USAGE, mode);	/* Excess arguments */
 }
+
+/*
+ * Make any user-specified ADV modifications in memory
+ */
+int modify_adv(void)
+{
+    int rv = 0;
+
+    if (opt.reset_adv)
+	syslinux_reset_adv(syslinux_adv);
+
+    if (opt.set_once) {
+	if (syslinux_setadv(ADV_BOOTONCE, strlen(opt.set_once), opt.set_once)) {
+	    fprintf(stderr, "%s: not enough space for boot-once command\n",
+		    program);
+	    rv = -1;
+	}
+    }
+    if (opt.menu_save) {
+        if (syslinux_setadv(ADV_MENUSAVE, strlen(opt.menu_save), opt.menu_save)) {
+	    fprintf(stderr, "%s: not enough space for menu-save label\n",
+		    program);
+	    rv = -1;
+        }
+    }
+
+    return rv;
+}
diff --git a/libinstaller/syslxopt.h b/libinstaller/syslxopt.h
index ba60ce2..446ab9a 100644
--- a/libinstaller/syslxopt.h
+++ b/libinstaller/syslxopt.h
@@ -29,6 +29,7 @@ enum syslinux_mode {
 
 void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode);
 void parse_options(int argc, char *argv[], enum syslinux_mode mode);
+int modify_adv(void);
 
 extern struct sys_options opt;
 extern const struct option long_options[];
diff --git a/linux/syslinux.c b/linux/syslinux.c
index ed65619..70fadcd 100644
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -219,24 +219,6 @@ void do_umount(const char *mntpath, int cookie)
 }
 
 /*
- * Make any user-specified ADV modifications
- */
-int modify_adv(void)
-{
-    int rv = 0;
-
-    if (opt.set_once) {
-	if (syslinux_setadv(ADV_BOOTONCE, strlen(opt.set_once), opt.set_once)) {
-	    fprintf(stderr, "%s: not enough space for boot-once command\n",
-		    program);
-	    rv = -1;
-	}
-    }
-
-    return rv;
-}
-
-/*
  * Modify the ADV of an existing installation
  */
 int modify_existing_adv(const char *path)



More information about the Syslinux-commits mailing list