132 |
#define NEED_DEVTREE (1 << 6) |
#define NEED_DEVTREE (1 << 6) |
133 |
|
|
134 |
#define MAIN_DEFAULT (1 << 0) |
#define MAIN_DEFAULT (1 << 0) |
135 |
|
#define FIRST_ENTRY_INDEX 0 /* boot entry index value begin and increment |
136 |
|
from this initial value */ |
137 |
|
#define NO_DEFAULT_ENTRY -1 /* indicates that no specific default boot |
138 |
|
entry was set or currently exists */ |
139 |
#define DEFAULT_SAVED -2 |
#define DEFAULT_SAVED -2 |
140 |
#define DEFAULT_SAVED_GRUB2 -3 |
#define DEFAULT_SAVED_GRUB2 -3 |
141 |
|
|
681 |
int fallbackImage; /* just like defaultImage */ |
int fallbackImage; /* just like defaultImage */ |
682 |
int flags; |
int flags; |
683 |
struct configFileInfo *cfi; |
struct configFileInfo *cfi; |
684 |
|
int isModified; /* assumes only one entry added |
685 |
|
per invocation of grubby */ |
686 |
}; |
}; |
687 |
|
|
688 |
blkid_cache blkid; |
blkid_cache blkid; |
1302 |
cfg->theLines = NULL; |
cfg->theLines = NULL; |
1303 |
cfg->entries = NULL; |
cfg->entries = NULL; |
1304 |
cfg->fallbackImage = 0; |
cfg->fallbackImage = 0; |
1305 |
|
cfg->isModified = 0; |
1306 |
|
|
1307 |
/* copy everything we have */ |
/* copy everything we have */ |
1308 |
while (*head) { |
while (*head) { |
1622 |
*end == ' ' || *end == '\t')) |
*end == ' ' || *end == '\t')) |
1623 |
end++; |
end++; |
1624 |
if (*end) |
if (*end) |
1625 |
cfg->defaultImage = -1; |
cfg->defaultImage = NO_DEFAULT_ENTRY; |
1626 |
} else if (defaultLine->numElements == 3) { |
} else if (defaultLine->numElements == 3) { |
1627 |
char *value = defaultLine->elements[2].item; |
char *value = defaultLine->elements[2].item; |
1628 |
while (*value && (*value == '"' || |
while (*value && (*value == '"' || |
1635 |
*end == ' ' || *end == '\t')) |
*end == ' ' || *end == '\t')) |
1636 |
end++; |
end++; |
1637 |
if (*end) |
if (*end) |
1638 |
cfg->defaultImage = -1; |
cfg->defaultImage = NO_DEFAULT_ENTRY; |
1639 |
} |
} |
1640 |
} else if (cfi->defaultSupportSaved && |
} else if (cfi->defaultSupportSaved && |
1641 |
!strncmp(defaultLine->elements[1].item, "saved", |
!strncmp(defaultLine->elements[1].item, "saved", |
1645 |
cfg->defaultImage = |
cfg->defaultImage = |
1646 |
strtol(defaultLine->elements[1].item, &end, 10); |
strtol(defaultLine->elements[1].item, &end, 10); |
1647 |
if (*end) |
if (*end) |
1648 |
cfg->defaultImage = -1; |
cfg->defaultImage = NO_DEFAULT_ENTRY; |
1649 |
} else if (defaultLine->numElements >= 2) { |
} else if (defaultLine->numElements >= 2) { |
1650 |
int i = 0; |
int i = 0; |
1651 |
while ((entry = findEntryByIndex(cfg, i))) { |
while ((entry = findEntryByIndex(cfg, i))) { |
1673 |
if (entry) { |
if (entry) { |
1674 |
cfg->defaultImage = i; |
cfg->defaultImage = i; |
1675 |
} else { |
} else { |
1676 |
cfg->defaultImage = -1; |
cfg->defaultImage = NO_DEFAULT_ENTRY; |
1677 |
} |
} |
1678 |
} |
} |
1679 |
} else if (cfg->cfi->defaultIsSaved && cfg->cfi->getEnv) { |
} else if (cfg->cfi->defaultIsSaved && cfg->cfi->getEnv) { |
1690 |
cfg->defaultImage = index; |
cfg->defaultImage = index; |
1691 |
} |
} |
1692 |
} else { |
} else { |
1693 |
cfg->defaultImage = 0; |
cfg->defaultImage = FIRST_ENTRY_INDEX; |
1694 |
} |
} |
1695 |
|
|
1696 |
return cfg; |
return cfg; |
1710 |
fprintf(out, "%sdefault%ssaved\n", indent, separator); |
fprintf(out, "%sdefault%ssaved\n", indent, separator); |
1711 |
else if (cfg->cfi->defaultIsSaved) { |
else if (cfg->cfi->defaultIsSaved) { |
1712 |
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent); |
fprintf(out, "%sset default=\"${saved_entry}\"\n", indent); |
1713 |
if (cfg->defaultImage >= 0 && 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); |
1736 |
"saved_entry", title); |
"saved_entry", title); |
1737 |
} |
} |
1738 |
} |
} |
1739 |
} else if (cfg->defaultImage > -1) { |
} else if (cfg->defaultImage >= FIRST_ENTRY_INDEX) { |
1740 |
if (cfg->cfi->defaultIsIndex) { |
if (cfg->cfi->defaultIsIndex) { |
1741 |
if (cfg->cfi->defaultIsVariable) { |
if (cfg->cfi->defaultIsVariable) { |
1742 |
fprintf(out, "%sset default=\"%d\"\n", indent, |
fprintf(out, "%sset default=\"%d\"\n", indent, |
1792 |
int needs = MAIN_DEFAULT; |
int needs = MAIN_DEFAULT; |
1793 |
struct stat sb; |
struct stat sb; |
1794 |
int i; |
int i; |
1795 |
|
int rc = 0; |
1796 |
|
|
1797 |
if (!strcmp(outName, "-")) { |
if (!strcmp(outName, "-")) { |
1798 |
out = stdout; |
out = stdout; |
1907 |
} |
} |
1908 |
|
|
1909 |
if (tmpOutName) { |
if (tmpOutName) { |
1910 |
if (rename(tmpOutName, outName)) { |
/* write userspace buffers */ |
1911 |
fprintf(stderr, |
if (fflush(out)) |
1912 |
_("grubby: error moving %s to %s: %s\n"), |
rc = 1; |
1913 |
tmpOutName, outName, strerror(errno)); |
|
1914 |
unlink(outName); |
/* purge the write-back cache with fsync() */ |
1915 |
return 1; |
if (fsync(fileno(out))) |
1916 |
|
rc = 1; |
1917 |
|
|
1918 |
|
if (fclose(out)) |
1919 |
|
rc = 1; |
1920 |
|
|
1921 |
|
if (rc == 0 && rename(tmpOutName, outName)) { |
1922 |
|
unlink(tmpOutName); |
1923 |
|
rc = 1; |
1924 |
} |
} |
1925 |
|
|
1926 |
|
/* fsync() the destination directory after rename */ |
1927 |
|
if (rc == 0) { |
1928 |
|
int dirfd; |
1929 |
|
|
1930 |
|
dirfd = open(dirname(strdupa(outName)), O_RDONLY); |
1931 |
|
if (dirfd < 0) |
1932 |
|
rc = 1; |
1933 |
|
else if (fsync(dirfd)) |
1934 |
|
rc = 1; |
1935 |
|
|
1936 |
|
if (dirfd >= 0) |
1937 |
|
close(dirfd); |
1938 |
|
} |
1939 |
|
|
1940 |
|
if (rc == 1) |
1941 |
|
fprintf(stderr, |
1942 |
|
_("grubby: error flushing data: %m\n")); |
1943 |
} |
} |
1944 |
|
|
1945 |
return 0; |
return rc; |
1946 |
} |
} |
1947 |
|
|
1948 |
static int numEntries(struct grubConfig *cfg) |
static int numEntries(struct grubConfig *cfg) |
2467 |
} |
} |
2468 |
} |
} |
2469 |
} |
} |
2470 |
} else if (cfg->defaultImage > -1) { |
} else if (cfg->defaultImage >= FIRST_ENTRY_INDEX) { |
2471 |
entry = findEntryByIndex(cfg, cfg->defaultImage); |
entry = findEntryByIndex(cfg, cfg->defaultImage); |
2472 |
if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { |
if (entry && suitableImage(entry, prefix, skipRemoved, flags)) { |
2473 |
if (indexPtr) |
if (indexPtr) |
2479 |
index = 0; |
index = 0; |
2480 |
while ((entry = findEntryByIndex(cfg, index))) { |
while ((entry = findEntryByIndex(cfg, index))) { |
2481 |
if (suitableImage(entry, prefix, skipRemoved, flags)) { |
if (suitableImage(entry, prefix, skipRemoved, flags)) { |
2482 |
int j; |
int j, unmodifiedIndex; |
2483 |
for (j = 0; j < index; j++) { |
|
2484 |
|
unmodifiedIndex = index; |
2485 |
|
|
2486 |
|
for (j = 0; j < unmodifiedIndex; j++) { |
2487 |
entry2 = findEntryByIndex(cfg, j); |
entry2 = findEntryByIndex(cfg, j); |
2488 |
if (entry2->skip) |
if (entry2->skip) |
2489 |
index--; |
index--; |
2544 |
entry->skip = 1; |
entry->skip = 1; |
2545 |
} |
} |
2546 |
|
|
2547 |
void setDefaultImage(struct grubConfig *config, int hasNew, |
void setDefaultImage(struct grubConfig *config, int isAddingBootEntry, |
2548 |
const char *defaultKernelPath, int newIsDefault, |
const char *defaultKernelPath, int newBootEntryIsDefault, |
2549 |
const char *prefix, int flags, int index) |
const char *prefix, int flags, |
2550 |
{ |
int newDefaultBootEntryIndex, int newBootEntryIndex) |
2551 |
struct singleEntry *entry, *entry2, *newDefault; |
{ |
2552 |
int i, j; |
struct singleEntry *bootEntry, *newDefault; |
2553 |
|
int indexToVerify, firstKernelEntryIndex, currentLookupIndex; |
2554 |
if (newIsDefault) { |
|
2555 |
config->defaultImage = 0; |
/* initialize */ |
2556 |
|
currentLookupIndex = FIRST_ENTRY_INDEX; |
2557 |
|
|
2558 |
|
/* handle the two cases where the user explictly picks the default |
2559 |
|
* boot entry index as it would exist post-modification */ |
2560 |
|
|
2561 |
|
/* Case 1: user chose to make the latest boot entry the default */ |
2562 |
|
if (newBootEntryIsDefault) { |
2563 |
|
config->defaultImage = newBootEntryIndex; |
2564 |
return; |
return; |
2565 |
} else if ((index >= 0) && config->cfi->defaultIsIndex) { |
} |
2566 |
if (findEntryByIndex(config, index)) |
|
2567 |
config->defaultImage = index; |
/* Case 2: user picked an arbitrary index as the default boot entry */ |
2568 |
else |
if (newDefaultBootEntryIndex >= FIRST_ENTRY_INDEX) { |
2569 |
config->defaultImage = -1; |
indexToVerify = newDefaultBootEntryIndex; |
2570 |
return; |
|
2571 |
} else if (defaultKernelPath) { |
/* user chose to make latest boot entry the default */ |
2572 |
i = 0; |
if (newDefaultBootEntryIndex == newBootEntryIndex) { |
2573 |
if (findEntryByPath(config, defaultKernelPath, prefix, &i)) { |
config->defaultImage = newBootEntryIndex; |
|
config->defaultImage = i; |
|
|
} else { |
|
|
config->defaultImage = -1; |
|
2574 |
return; |
return; |
2575 |
} |
} |
|
} |
|
2576 |
|
|
2577 |
/* defaultImage now points to what we'd like to use, but before any |
/* the user picks the default index based on the |
2578 |
* order changes */ |
* order of the bootloader configuration after |
2579 |
if ((config->defaultImage == DEFAULT_SAVED) || |
* modification; ensure we are checking for the |
2580 |
(config->defaultImage == DEFAULT_SAVED_GRUB2)) |
* existence of the correct entry */ |
2581 |
/* default is set to saved, we don't want to change it */ |
if (newBootEntryIndex < newDefaultBootEntryIndex) { |
2582 |
|
if (!config->isModified) |
2583 |
|
indexToVerify--; |
2584 |
|
} |
2585 |
|
|
2586 |
|
/* verify the user selected index will exist */ |
2587 |
|
if (findEntryByIndex(config, indexToVerify)) { |
2588 |
|
config->defaultImage = newDefaultBootEntryIndex; |
2589 |
|
} else { |
2590 |
|
config->defaultImage = NO_DEFAULT_ENTRY; |
2591 |
|
} |
2592 |
|
|
2593 |
return; |
return; |
2594 |
|
} |
2595 |
|
|
2596 |
if (config->defaultImage > -1) |
/* handle cases where the index value may shift */ |
|
entry = findEntryByIndex(config, config->defaultImage); |
|
|
else |
|
|
entry = NULL; |
|
2597 |
|
|
2598 |
if (entry && !entry->skip) { |
/* check validity of existing default or first-entry-found |
2599 |
/* we can preserve the default */ |
selection */ |
2600 |
if (hasNew) |
if (defaultKernelPath) { |
2601 |
config->defaultImage++; |
/* we must initialize this */ |
2602 |
|
firstKernelEntryIndex = 0; |
2603 |
|
/* user requested first-entry-found */ |
2604 |
|
if (!findEntryByPath(config, defaultKernelPath, |
2605 |
|
prefix, &firstKernelEntryIndex)) { |
2606 |
|
/* don't change default if can't find match */ |
2607 |
|
config->defaultImage = NO_DEFAULT_ENTRY; |
2608 |
|
return; |
2609 |
|
} |
2610 |
|
|
2611 |
/* count the number of entries erased before this one */ |
config->defaultImage = firstKernelEntryIndex; |
2612 |
for (j = 0; j < config->defaultImage; j++) { |
|
2613 |
entry2 = findEntryByIndex(config, j); |
/* this is where we start looking for decrement later */ |
2614 |
if (entry2->skip) |
currentLookupIndex = config->defaultImage; |
2615 |
config->defaultImage--; |
|
2616 |
|
if (isAddingBootEntry && !config->isModified && |
2617 |
|
(newBootEntryIndex < config->defaultImage)) { |
2618 |
|
/* increment because new entry added before default */ |
2619 |
|
config->defaultImage++; |
2620 |
} |
} |
|
} else if (hasNew) { |
|
|
config->defaultImage = 0; |
|
2621 |
} else { |
} else { |
2622 |
/* Either we just erased the default (or the default line was |
/* check to see if the default is stored in the environment */ |
2623 |
* bad to begin with) and didn't put a new one in. We'll use |
if (config->defaultImage < FIRST_ENTRY_INDEX) { |
2624 |
* the first valid image. */ |
if (config->defaultImage == DEFAULT_SAVED || config->defaultImage == DEFAULT_SAVED_GRUB2) |
2625 |
|
{ |
2626 |
|
if (config->cfi->defaultIsSaved) { |
2627 |
|
if (config->cfi->getEnv) { |
2628 |
|
char *defaultTitle = config->cfi->getEnv(config->cfi, "saved_entry"); |
2629 |
|
|
2630 |
|
if (defaultTitle) { |
2631 |
|
if (isnumber(defaultTitle)) { |
2632 |
|
currentLookupIndex = atoi(defaultTitle); |
2633 |
|
} else { |
2634 |
|
findEntryByTitle(config, defaultTitle, ¤tLookupIndex); |
2635 |
|
} |
2636 |
|
/* set the default Image to an actual index */ |
2637 |
|
config->defaultImage = currentLookupIndex; |
2638 |
|
} |
2639 |
|
} |
2640 |
|
} |
2641 |
|
} |
2642 |
|
} else { |
2643 |
|
/* use pre-existing default entry from the file*/ |
2644 |
|
currentLookupIndex = config->defaultImage; |
2645 |
|
} |
2646 |
|
|
2647 |
|
if (isAddingBootEntry |
2648 |
|
&& (newBootEntryIndex <= config->defaultImage)) { |
2649 |
|
config->defaultImage++; |
2650 |
|
|
2651 |
|
if (config->isModified) { |
2652 |
|
currentLookupIndex++; |
2653 |
|
} |
2654 |
|
} |
2655 |
|
} |
2656 |
|
|
2657 |
|
/* sanity check - is this entry index valid? */ |
2658 |
|
bootEntry = findEntryByIndex(config, currentLookupIndex); |
2659 |
|
|
2660 |
|
if ((bootEntry && bootEntry->skip) || !bootEntry) { |
2661 |
|
/* entry is to be skipped or is invalid */ |
2662 |
|
if (isAddingBootEntry) { |
2663 |
|
config->defaultImage = newBootEntryIndex; |
2664 |
|
return; |
2665 |
|
} |
2666 |
newDefault = |
newDefault = |
2667 |
findTemplate(config, prefix, &config->defaultImage, 1, |
findTemplate(config, prefix, &config->defaultImage, 1, |
2668 |
flags); |
flags); |
2669 |
if (!newDefault) |
if (!newDefault) { |
2670 |
config->defaultImage = -1; |
config->defaultImage = NO_DEFAULT_ENTRY; |
2671 |
|
} |
2672 |
|
|
2673 |
|
return; |
2674 |
|
} |
2675 |
|
|
2676 |
|
currentLookupIndex--; |
2677 |
|
|
2678 |
|
/* decrement index by the total number of entries deleted */ |
2679 |
|
|
2680 |
|
for (indexToVerify = currentLookupIndex; |
2681 |
|
indexToVerify >= FIRST_ENTRY_INDEX; indexToVerify--) { |
2682 |
|
|
2683 |
|
bootEntry = findEntryByIndex(config, indexToVerify); |
2684 |
|
|
2685 |
|
if (bootEntry && bootEntry->skip) { |
2686 |
|
config->defaultImage--; |
2687 |
|
} |
2688 |
} |
} |
2689 |
} |
} |
2690 |
|
|
2713 |
} |
} |
2714 |
} |
} |
2715 |
|
|
2716 |
void displayEntry(struct singleEntry *entry, const char *prefix, int index) |
void displayEntry(struct grubConfig *config, struct singleEntry *entry, const char *prefix, int index) |
2717 |
{ |
{ |
2718 |
struct singleLine *line; |
struct singleLine *line; |
2719 |
char *root = NULL; |
char *root = NULL; |
2809 |
|
|
2810 |
line = getLineByType(LT_TITLE, entry->lines); |
line = getLineByType(LT_TITLE, entry->lines); |
2811 |
if (line) { |
if (line) { |
2812 |
printf("title=%s\n", line->elements[1].item); |
char *entryTitle; |
2813 |
|
/* if we can extractTitle, then it's a zipl config and |
2814 |
|
* if not then we go ahead with what's existed prior */ |
2815 |
|
entryTitle = extractTitle(config, line); |
2816 |
|
if (!entryTitle) { |
2817 |
|
entryTitle=line->elements[1].item; |
2818 |
|
} |
2819 |
|
printf("title=%s\n", entryTitle); |
2820 |
} else { |
} else { |
2821 |
char *title; |
char *title; |
2822 |
line = getLineByType(LT_MENUENTRY, entry->lines); |
line = getLineByType(LT_MENUENTRY, entry->lines); |
3232 |
printf("lba\n"); |
printf("lba\n"); |
3233 |
} |
} |
3234 |
|
|
3235 |
displayEntry(entry, prefix, i); |
displayEntry(config, entry, prefix, i); |
3236 |
|
|
3237 |
i++; |
i++; |
3238 |
while ((entry = findEntryByPath(config, kernel, prefix, &i))) { |
while ((entry = findEntryByPath(config, kernel, prefix, &i))) { |
3239 |
displayEntry(entry, prefix, i); |
displayEntry(config, entry, prefix, i); |
3240 |
i++; |
i++; |
3241 |
} |
} |
3242 |
|
|
3566 |
line->numElements--; |
line->numElements--; |
3567 |
} |
} |
3568 |
|
|
3569 |
int argMatch(const char *one, const char *two) |
static int argNameMatch(const char *one, const char *two) |
3570 |
{ |
{ |
3571 |
char *first, *second; |
char *first, *second; |
3572 |
char *chptr; |
char *chptra, *chptrb; |
3573 |
|
int rc; |
3574 |
|
|
3575 |
first = strcpy(alloca(strlen(one) + 1), one); |
first = strcpy(alloca(strlen(one) + 1), one); |
3576 |
second = strcpy(alloca(strlen(two) + 1), two); |
second = strcpy(alloca(strlen(two) + 1), two); |
3577 |
|
|
3578 |
chptr = strchr(first, '='); |
chptra = strchr(first, '='); |
3579 |
if (chptr) |
if (chptra) |
3580 |
*chptr = '\0'; |
*chptra = '\0'; |
3581 |
|
|
3582 |
|
chptrb = strchr(second, '='); |
3583 |
|
if (chptrb) |
3584 |
|
*chptrb = '\0'; |
3585 |
|
|
3586 |
|
rc = strcmp(first, second); |
3587 |
|
|
3588 |
|
if (chptra) |
3589 |
|
*chptra = '='; |
3590 |
|
if (chptrb) |
3591 |
|
*chptrb = '='; |
3592 |
|
|
3593 |
chptr = strchr(second, '='); |
return rc; |
3594 |
|
} |
3595 |
|
|
3596 |
|
static int argHasValue(const char *arg) |
3597 |
|
{ |
3598 |
|
char *chptr; |
3599 |
|
|
3600 |
|
chptr = strchr(arg, '='); |
3601 |
if (chptr) |
if (chptr) |
3602 |
*chptr = '\0'; |
return 1; |
3603 |
|
return 0; |
3604 |
|
} |
3605 |
|
|
3606 |
|
static int argValueMatch(const char *one, const char *two) |
3607 |
|
{ |
3608 |
|
char *first, *second; |
3609 |
|
char *chptra, *chptrb; |
3610 |
|
|
3611 |
return strcmp(first, second); |
first = strcpy(alloca(strlen(one) + 1), one); |
3612 |
|
second = strcpy(alloca(strlen(two) + 1), two); |
3613 |
|
|
3614 |
|
chptra = strchr(first, '='); |
3615 |
|
if (chptra) |
3616 |
|
chptra += 1; |
3617 |
|
|
3618 |
|
chptrb = strchr(second, '='); |
3619 |
|
if (chptrb) |
3620 |
|
chptrb += 1; |
3621 |
|
|
3622 |
|
if (!chptra && !chptrb) |
3623 |
|
return 0; |
3624 |
|
else if (!chptra) |
3625 |
|
return *chptrb - 0; |
3626 |
|
else if (!chptrb) |
3627 |
|
return 0 - *chptra; |
3628 |
|
else |
3629 |
|
return strcmp(chptra, chptrb); |
3630 |
} |
} |
3631 |
|
|
3632 |
int updateActualImage(struct grubConfig *cfg, const char *image, |
int updateActualImage(struct grubConfig *cfg, const char *image, |
3770 |
} |
} |
3771 |
if (usedElements[i]) |
if (usedElements[i]) |
3772 |
continue; |
continue; |
3773 |
if (!argMatch(line->elements[i].item, *arg)) { |
if (!argNameMatch(line->elements[i].item, *arg)) { |
3774 |
usedElements[i] = 1; |
usedElements[i] = 1; |
3775 |
break; |
break; |
3776 |
} |
} |
3829 |
!strcmp(line->elements[i].item, "--")) |
!strcmp(line->elements[i].item, "--")) |
3830 |
/* reached the end of hyper args, stop here */ |
/* reached the end of hyper args, stop here */ |
3831 |
break; |
break; |
3832 |
if (!argMatch(line->elements[i].item, *arg)) { |
if (!argNameMatch(line->elements[i].item, *arg)) { |
3833 |
removeElement(line, i); |
if (!argHasValue(*arg) || |
3834 |
break; |
!argValueMatch(line->elements[i].item, *arg)) { |
3835 |
|
removeElement(line, i); |
3836 |
|
break; |
3837 |
|
} |
3838 |
} |
} |
3839 |
} |
} |
3840 |
/* handle removing LT_ROOT line too */ |
/* handle removing LT_ROOT line too */ |
4910 |
} |
} |
4911 |
|
|
4912 |
if (updateImage(config, indexs, prefix, newKernelArgs, NULL, |
if (updateImage(config, indexs, prefix, newKernelArgs, NULL, |
4913 |
newMBKernelArgs, NULL)) |
newMBKernelArgs, NULL)) { |
4914 |
|
config->isModified = 1; |
4915 |
return 1; |
return 1; |
4916 |
|
} |
4917 |
|
|
4918 |
return 0; |
return 0; |
4919 |
} |
} |
5154 |
if (!cfi) { |
if (!cfi) { |
5155 |
if (grub2FindConfig(&grub2ConfigType)) { |
if (grub2FindConfig(&grub2ConfigType)) { |
5156 |
cfi = &grub2ConfigType; |
cfi = &grub2ConfigType; |
5157 |
|
configureGrub2 = 1; |
5158 |
if (envPath) |
if (envPath) |
5159 |
cfi->envFile = envPath; |
cfi->envFile = envPath; |
5160 |
} else |
} else { |
5161 |
#ifdef __ia64__ |
#ifdef __ia64__ |
5162 |
cfi = &eliloConfigType; |
cfi = &eliloConfigType; |
5163 |
#elif __powerpc__ |
configureLilo = 1; |
5164 |
|
#elif defined(__powerpc__) |
5165 |
cfi = &yabootConfigType; |
cfi = &yabootConfigType; |
5166 |
#elif __sparc__ |
configureYaboot = 1; |
5167 |
|
#elif defined(__sparc__) |
5168 |
cfi = &siloConfigType; |
cfi = &siloConfigType; |
5169 |
#elif __s390__ |
configureSilo = 1; |
5170 |
|
#elif defined(__s390__) || defined(__s390x__) |
5171 |
cfi = &ziplConfigType; |
cfi = &ziplConfigType; |
5172 |
#elif __s390x__ |
configureZipl = 1; |
|
cfi = &ziplConfigtype; |
|
5173 |
#else |
#else |
5174 |
cfi = &grubConfigType; |
cfi = &grubConfigType; |
5175 |
|
configureGrub = 1; |
5176 |
#endif |
#endif |
5177 |
|
} |
5178 |
} |
} |
5179 |
|
|
5180 |
if (!grubConfig) { |
if (!grubConfig) { |
5370 |
struct singleEntry *entry; |
struct singleEntry *entry; |
5371 |
char *rootspec; |
char *rootspec; |
5372 |
|
|
5373 |
if (config->defaultImage == -1) |
if (config->defaultImage == NO_DEFAULT_ENTRY) |
5374 |
return 0; |
return 0; |
5375 |
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
5376 |
cfi->defaultIsSaved) |
cfi->defaultIsSaved) |
5377 |
config->defaultImage = 0; |
config->defaultImage = FIRST_ENTRY_INDEX; |
5378 |
entry = findEntryByIndex(config, config->defaultImage); |
entry = findEntryByIndex(config, config->defaultImage); |
5379 |
if (!entry) |
if (!entry) |
5380 |
return 0; |
return 0; |
5397 |
struct singleLine *line; |
struct singleLine *line; |
5398 |
struct singleEntry *entry; |
struct singleEntry *entry; |
5399 |
|
|
5400 |
if (config->defaultImage == -1) |
if (config->defaultImage == NO_DEFAULT_ENTRY) |
5401 |
return 0; |
return 0; |
5402 |
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
5403 |
cfi->defaultIsSaved) |
cfi->defaultIsSaved) |
5404 |
config->defaultImage = 0; |
config->defaultImage = FIRST_ENTRY_INDEX; |
5405 |
entry = findEntryByIndex(config, config->defaultImage); |
entry = findEntryByIndex(config, config->defaultImage); |
5406 |
if (!entry) |
if (!entry) |
5407 |
return 0; |
return 0; |
5431 |
return 0; |
return 0; |
5432 |
|
|
5433 |
} else if (displayDefaultIndex) { |
} else if (displayDefaultIndex) { |
5434 |
if (config->defaultImage == -1) |
if (config->defaultImage == NO_DEFAULT_ENTRY) |
5435 |
return 0; |
return 0; |
5436 |
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
if (config->defaultImage == DEFAULT_SAVED_GRUB2 && |
5437 |
cfi->defaultIsSaved) |
cfi->defaultIsSaved) |
5438 |
config->defaultImage = 0; |
config->defaultImage = FIRST_ENTRY_INDEX; |
5439 |
printf("%i\n", config->defaultImage); |
printf("%i\n", config->defaultImage); |
5440 |
return 0; |
return 0; |
5441 |
|
|
5451 |
markRemovedImage(config, removeKernelPath, bootPrefix); |
markRemovedImage(config, removeKernelPath, bootPrefix); |
5452 |
markRemovedImage(config, removeMBKernel, bootPrefix); |
markRemovedImage(config, removeMBKernel, bootPrefix); |
5453 |
setDefaultImage(config, newKernelPath != NULL, defaultKernel, |
setDefaultImage(config, newKernelPath != NULL, defaultKernel, |
5454 |
makeDefault, bootPrefix, flags, defaultIndex); |
makeDefault, bootPrefix, flags, defaultIndex, |
5455 |
|
newIndex); |
5456 |
setFallbackImage(config, newKernelPath != NULL); |
setFallbackImage(config, newKernelPath != NULL); |
5457 |
if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, |
if (updateImage(config, updateKernelPath, bootPrefix, newKernelArgs, |
5458 |
removeArgs, newMBKernelArgs, removeMBKernelArgs)) |
removeArgs, newMBKernelArgs, removeMBKernelArgs)) |