1712 |
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent); |
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent); |
1713 |
if (cfg->defaultImage >= FIRST_ENTRY_INDEX && cfg->cfi->setEnv) { |
if (cfg->defaultImage >= FIRST_ENTRY_INDEX && cfg->cfi->setEnv) { |
1714 |
char *title; |
char *title; |
1715 |
entry = findEntryByIndex(cfg, cfg->defaultImage); |
int trueIndex, currentIndex; |
1716 |
|
|
1717 |
|
trueIndex = 0; |
1718 |
|
currentIndex = 0; |
1719 |
|
|
1720 |
|
while ((entry = findEntryByIndex(cfg, currentIndex))) { |
1721 |
|
if (!entry->skip) { |
1722 |
|
if (trueIndex == cfg->defaultImage) { |
1723 |
|
break; |
1724 |
|
} |
1725 |
|
trueIndex++; |
1726 |
|
} |
1727 |
|
currentIndex++; |
1728 |
|
} |
1729 |
line = getLineByType(LT_MENUENTRY, entry->lines); |
line = getLineByType(LT_MENUENTRY, entry->lines); |
1730 |
if (!line) |
if (!line) |
1731 |
line = getLineByType(LT_TITLE, entry->lines); |
line = getLineByType(LT_TITLE, entry->lines); |
2452 |
index = 0; |
index = 0; |
2453 |
while ((entry = findEntryByIndex(cfg, index))) { |
while ((entry = findEntryByIndex(cfg, index))) { |
2454 |
if (suitableImage(entry, prefix, skipRemoved, flags)) { |
if (suitableImage(entry, prefix, skipRemoved, flags)) { |
2455 |
int j; |
int j, unmodifiedIndex; |
2456 |
for (j = 0; j < index; j++) { |
|
2457 |
|
unmodifiedIndex = index; |
2458 |
|
|
2459 |
|
for (j = 0; j < unmodifiedIndex; j++) { |
2460 |
entry2 = findEntryByIndex(cfg, j); |
entry2 = findEntryByIndex(cfg, j); |
2461 |
if (entry2->skip) |
if (entry2->skip) |
2462 |
index--; |
index--; |
2525 |
struct singleEntry *bootEntry, *newDefault; |
struct singleEntry *bootEntry, *newDefault; |
2526 |
int indexToVerify, firstKernelEntryIndex, currentLookupIndex; |
int indexToVerify, firstKernelEntryIndex, currentLookupIndex; |
2527 |
|
|
2528 |
|
/* initialize */ |
2529 |
|
currentLookupIndex = FIRST_ENTRY_INDEX; |
2530 |
|
|
2531 |
/* handle the two cases where the user explictly picks the default |
/* handle the two cases where the user explictly picks the default |
2532 |
* boot entry index as it would exist post-modification */ |
* boot entry index as it would exist post-modification */ |
2533 |
|
|
2572 |
/* check validity of existing default or first-entry-found |
/* check validity of existing default or first-entry-found |
2573 |
selection */ |
selection */ |
2574 |
if (defaultKernelPath) { |
if (defaultKernelPath) { |
2575 |
|
/* we must initialize this */ |
2576 |
|
firstKernelEntryIndex = 0; |
2577 |
/* user requested first-entry-found */ |
/* user requested first-entry-found */ |
2578 |
if (!findEntryByPath(config, defaultKernelPath, |
if (!findEntryByPath(config, defaultKernelPath, |
2579 |
prefix, &firstKernelEntryIndex)) { |
prefix, &firstKernelEntryIndex)) { |
2593 |
config->defaultImage++; |
config->defaultImage++; |
2594 |
} |
} |
2595 |
} else { |
} else { |
2596 |
/* use pre-existing default entry */ |
/* check to see if the default is stored in the environment */ |
2597 |
currentLookupIndex = config->defaultImage; |
if (config->defaultImage < FIRST_ENTRY_INDEX) { |
2598 |
|
if (config->defaultImage == DEFAULT_SAVED || config->defaultImage == DEFAULT_SAVED_GRUB2) |
2599 |
|
{ |
2600 |
|
if (config->cfi->defaultIsSaved) { |
2601 |
|
if (config->cfi->getEnv) { |
2602 |
|
char *defaultTitle = config->cfi->getEnv(config->cfi, "saved_entry"); |
2603 |
|
|
2604 |
|
if (defaultTitle) { |
2605 |
|
if (isnumber(defaultTitle)) { |
2606 |
|
currentLookupIndex = atoi(defaultTitle); |
2607 |
|
} else { |
2608 |
|
findEntryByTitle(config, defaultTitle, ¤tLookupIndex); |
2609 |
|
} |
2610 |
|
/* set the default Image to an actual index */ |
2611 |
|
config->defaultImage = currentLookupIndex; |
2612 |
|
} |
2613 |
|
} |
2614 |
|
} |
2615 |
|
} |
2616 |
|
} else { |
2617 |
|
/* use pre-existing default entry from the file*/ |
2618 |
|
currentLookupIndex = config->defaultImage; |
2619 |
|
} |
2620 |
|
|
2621 |
if (isAddingBootEntry |
if (isAddingBootEntry |
2622 |
&& (newBootEntryIndex <= config->defaultImage)) { |
&& (newBootEntryIndex <= config->defaultImage)) { |