75bbb8
From db71a9ef9363f9ce01ee1746c827f8a2feac73e7 Mon Sep 17 00:00:00 2001
75bbb8
From: Robert Marshall <rmarshall@redhat.com>
75bbb8
Date: Thu, 8 Dec 2016 16:52:45 -0500
75bbb8
Subject: [PATCH 63/69] Track configuration modifications
75bbb8
75bbb8
The setDefaultImage function had a subtle dependency on being run before
75bbb8
addNewKernel is invoked. Added the ability to track invocation to
75bbb8
prevent them from being so tightly coupled.
75bbb8
75bbb8
Related: rhbz#1285601
75bbb8
---
75bbb8
 grubby.c | 7 ++++++-
75bbb8
 1 file changed, 6 insertions(+), 1 deletion(-)
75bbb8
75bbb8
diff --git a/grubby.c b/grubby.c
75bbb8
index bece23a..3929212 100644
75bbb8
--- a/grubby.c
75bbb8
+++ b/grubby.c
75bbb8
@@ -671,6 +671,8 @@ struct grubConfig {
75bbb8
 	int fallbackImage;	/* just like defaultImage */
75bbb8
 	int flags;
75bbb8
 	struct configFileInfo *cfi;
75bbb8
+	int isModified;		/* assumes only one entry added
75bbb8
+				   per invocation of grubby */
75bbb8
 };
75bbb8
 
75bbb8
 blkid_cache blkid;
75bbb8
@@ -1399,6 +1401,7 @@ static struct grubConfig *readConfig(const char *inName,
75bbb8
 	cfg->theLines = NULL;
75bbb8
 	cfg->entries = NULL;
75bbb8
 	cfg->fallbackImage = 0;
75bbb8
+	cfg->isModified = 0;
75bbb8
 
75bbb8
 	/* copy everything we have */
75bbb8
 	while (*head) {
75bbb8
@@ -4764,8 +4767,10 @@ int addNewKernel(struct grubConfig *config, struct singleEntry *template,
75bbb8
 	}
75bbb8
 
75bbb8
 	if (updateImage(config, indexs, prefix, newKernelArgs, NULL,
75bbb8
-			newMBKernelArgs, NULL))
75bbb8
+			newMBKernelArgs, NULL)) {
75bbb8
+		config->isModified = 1;
75bbb8
 		return 1;
75bbb8
+	}
75bbb8
 
75bbb8
 	return 0;
75bbb8
 }
75bbb8
-- 
75bbb8
2.9.3
75bbb8