156 |
{ NULL, 0, 0 }, |
{ NULL, 0, 0 }, |
157 |
}; |
}; |
158 |
|
|
159 |
|
const char *grubFindConfig(struct configFileInfo *cfi) { |
160 |
|
static const char *configFiles[] = { |
161 |
|
"/etc/grub.conf", |
162 |
|
"/boot/grub/grub.conf", |
163 |
|
"/boot/grub/menu.lst", |
164 |
|
NULL |
165 |
|
}; |
166 |
|
static int i = -1; |
167 |
|
|
168 |
|
if (i == -1) { |
169 |
|
for (i = 0; configFiles[i] != NULL; i++) { |
170 |
|
dbgPrintf("Checking \"%s\": ", configFiles[i]); |
171 |
|
if (!access(configFiles[i], R_OK)) { |
172 |
|
dbgPrintf("found\n"); |
173 |
|
return configFiles[i]; |
174 |
|
} |
175 |
|
dbgPrintf("not found\n"); |
176 |
|
} |
177 |
|
} |
178 |
|
return configFiles[i]; |
179 |
|
} |
180 |
|
|
181 |
struct configFileInfo grubConfigType = { |
struct configFileInfo grubConfigType = { |
182 |
.defaultConfig = "/boot/grub/grub.conf", |
.findConfig = grubFindConfig, |
183 |
.keywords = grubKeywords, |
.keywords = grubKeywords, |
184 |
.defaultIsIndex = 1, |
.defaultIsIndex = 1, |
185 |
.defaultSupportSaved = 1, |
.defaultSupportSaved = 1, |
212 |
NULL |
NULL |
213 |
}; |
}; |
214 |
static int i = -1; |
static int i = -1; |
215 |
|
static const char *grub_cfg = "/boot/grub/grub.cfg"; |
216 |
|
|
217 |
if (i == -1) { |
if (i == -1) { |
218 |
for (i = 0; configFiles[i] != NULL; i++) { |
for (i = 0; configFiles[i] != NULL; i++) { |
221 |
dbgPrintf("found\n"); |
dbgPrintf("found\n"); |
222 |
return configFiles[i]; |
return configFiles[i]; |
223 |
} |
} |
|
dbgPrintf("not found\n"); |
|
224 |
} |
} |
225 |
} |
} |
226 |
|
|
227 |
|
/* Ubuntu renames grub2 to grub, so check for the grub.d directory |
228 |
|
* that isn't in grub1, and if it exists, return the config file path |
229 |
|
* that they use. */ |
230 |
|
if (configFiles[i] == NULL && !access("/etc/grub.d/", R_OK)) { |
231 |
|
dbgPrintf("found\n"); |
232 |
|
return grub_cfg; |
233 |
|
} |
234 |
|
|
235 |
|
dbgPrintf("not found\n"); |
236 |
return configFiles[i]; |
return configFiles[i]; |
237 |
} |
} |
238 |
|
|
2616 |
} |
} |
2617 |
|
|
2618 |
int checkForGrub2(struct grubConfig * config) { |
int checkForGrub2(struct grubConfig * config) { |
2619 |
if (!access("/boot/grub2", R_OK)) |
if (!access("/etc/grub.d/", R_OK)) |
2620 |
return 2; |
return 2; |
2621 |
|
|
2622 |
return 1; |
return 1; |
3412 |
gr2c = checkForGrub2(gconfig); |
gr2c = checkForGrub2(gconfig); |
3413 |
} |
} |
3414 |
|
|
3415 |
if (!access(grubConfigType.defaultConfig, F_OK)) { |
const char *grubconfig = grubFindConfig(&grubConfigType); |
3416 |
gconfig = readConfig(grubConfigType.defaultConfig, &grubConfigType); |
if (!access(grubconfig, F_OK)) { |
3417 |
|
gconfig = readConfig(grubconfig, &grubConfigType); |
3418 |
if (!gconfig) |
if (!gconfig) |
3419 |
grc = 1; |
grc = 1; |
3420 |
else |
else |