From f4e1a06718811cd0891572acfc01dbfa160484ca Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 29 Jun 2007 15:44:29 +0200 Subject: update 'default_entry' according to the savemap, and set the backup_entry If the currently saved entry matches one entry in the save map, then use its real one instead and pre-set the next default boot. --- stage2/builtins.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/stage2/builtins.c b/stage2/builtins.c index 2869db2..7117e3e 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -63,6 +63,8 @@ int fallback_entryno; int fallback_entries[MAX_FALLBACK_ENTRIES]; /* the save map. Ends with saved == -1 */ struct savemap savemap[MAX_SAVEMAP]; +/* the entry which will be used by 'savedefault savemap' */ +int backup_entry; /* The number of current entry. */ int current_entryno; /* The address for Multiboot command-line buffer. */ @@ -99,6 +101,7 @@ void init_config (void) { default_entry = 0; + backup_entry = 0; password = 0; fallback_entryno = -1; fallback_entries[0] = -1; @@ -767,7 +770,18 @@ default_func (char *arg, int flags) #ifndef SUPPORT_DISKLESS if (grub_strcmp (arg, "saved") == 0) { + int i; + default_entry = saved_entryno; + for (i = 0; i < MAX_SAVEMAP && savemap[i].saved != -1; i++) + { + if (savemap[i].saved == default_entry) + { + default_entry = savemap[i].real; + backup_entry = savemap[i].backup; + break; + } + } return 0; } #endif /* SUPPORT_DISKLESS */ -- 1.4.4.3