FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Desktop

 
 
LinkBack Thread Tools
 
Old 10-11-2011, 06:50 PM
Lucas Meneghel Rodrigues
 
Default 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
 
Old 10-11-2011, 07:49 PM
Peter Jones
 
Default 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
 

Thread Tools




All times are GMT. The time now is 07:14 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org