Look for other possible grub config files
Since debian and Ubuntu don't symlink /boot/grub/menu.lst
to /etc/grub.conf, make it possible to look them over on this original location as well. Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com> --- grubby.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-) diff --git a/grubby.c b/grubby.c index 7ff33ca..c01828e 100644 --- a/grubby.c +++ b/grubby.c @@ -156,8 +156,29 @@ struct keywordTypes grubKeywords[] = { { NULL, 0, 0 }, }; +const char *grubFindConfig(struct configFileInfo *cfi) { + static const char *configFiles[] = { + "/etc/grub.conf", + "/boot/grub/menu.lst", + NULL + }; + static int i = -1; + + if (i == -1) { + for (i = 0; configFiles[i] != NULL; i++) { + dbgPrintf("Checking "%s": ", configFiles[i]); + if (!access(configFiles[i], R_OK)) { + dbgPrintf("found "); + return configFiles[i]; + } + dbgPrintf("not found "); + } + } + return configFiles[i]; +} + struct configFileInfo grubConfigType = { - .defaultConfig = "/etc/grub.conf", + .findConfig = grubFindConfig, .keywords = grubKeywords, .defaultIsIndex = 1, .defaultSupportSaved = 1, @@ -3386,8 +3407,9 @@ int main(int argc, const char ** argv) { gr2c = checkForGrub2(gconfig); } - if (!access(grubConfigType.defaultConfig, F_OK)) { - gconfig = readConfig(grubConfigType.defaultConfig, &grubConfigType); + const char *grubconfig = grubFindConfig(&grubConfigType); + if (!access(grubconfig, F_OK)) { + gconfig = readConfig(grubconfig, &grubConfigType); if (!gconfig) grc = 1; else -- 1.7.6.4 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
Look for other possible grub config files
On 10/11/2011 02:50 PM, Lucas Meneghel Rodrigues wrote:
> Since debian and Ubuntu don't symlink /boot/grub/menu.lst > to /etc/grub.conf, make it possible to look them over on > this original location as well. Looks good; I'll apply it when I get an update for patch 1/2. > > Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com> > --- > grubby.c | 28 +++++++++++++++++++++++++--- > 1 files changed, 25 insertions(+), 3 deletions(-) > > diff --git a/grubby.c b/grubby.c > index 7ff33ca..c01828e 100644 > --- a/grubby.c > +++ b/grubby.c > @@ -156,8 +156,29 @@ struct keywordTypes grubKeywords[] = { > { NULL, 0, 0 }, > }; > > +const char *grubFindConfig(struct configFileInfo *cfi) { > + static const char *configFiles[] = { > + "/etc/grub.conf", > + "/boot/grub/menu.lst", > + NULL > + }; > + static int i = -1; > + > + if (i == -1) { > + for (i = 0; configFiles[i] != NULL; i++) { > + dbgPrintf("Checking "%s": ", configFiles[i]); > + if (!access(configFiles[i], R_OK)) { > + dbgPrintf("found "); > + return configFiles[i]; > + } > + dbgPrintf("not found "); > + } > + } > + return configFiles[i]; > +} > + > struct configFileInfo grubConfigType = { > - .defaultConfig = "/etc/grub.conf", > + .findConfig = grubFindConfig, > .keywords = grubKeywords, > .defaultIsIndex = 1, > .defaultSupportSaved = 1, > @@ -3386,8 +3407,9 @@ int main(int argc, const char ** argv) { > gr2c = checkForGrub2(gconfig); > } > > - if (!access(grubConfigType.defaultConfig, F_OK)) { > - gconfig = readConfig(grubConfigType.defaultConfig, &grubConfigType); > + const char *grubconfig = grubFindConfig(&grubConfigType); > + if (!access(grubconfig, F_OK)) { > + gconfig = readConfig(grubconfig, &grubConfigType); > if (!gconfig) > grc = 1; > else -- Peter If the facts don't fit the theory, change the facts. -- Einstein 01234567890123456789012345678901234567890123456789 012345678901234567890123456789 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@redhat.com https://www.redhat.com/mailman/listinfo/anaconda-devel-list |
| All times are GMT. The time now is 07:43 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.