[PATCH 2/2] Look for other possible grub config files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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\n");
+		return configFiles[i];
+	    }
+	    dbgPrintf("not found\n");
+	}
+    }
+    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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux