Magellan Linux

Diff of /tags/grubby-8_32/grubby.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1692 by niro, Fri Feb 17 23:14:54 2012 UTC revision 1694 by niro, Fri Feb 17 23:23:07 2012 UTC
# Line 36  Line 36 
36  #include <signal.h>  #include <signal.h>
37  #include <blkid/blkid.h>  #include <blkid/blkid.h>
38    
39    #ifndef DEBUG
40  #define DEBUG 0  #define DEBUG 0
41    #endif
42    
43  #if DEBUG  #if DEBUG
44  #define dbgPrintf(format, args...) fprintf(stderr, format , ## args)  #define dbgPrintf(format, args...) fprintf(stderr, format , ## args)
# Line 115  struct configFileInfo { Line 117  struct configFileInfo {
117      struct keywordTypes * keywords;      struct keywordTypes * keywords;
118      int defaultIsIndex;      int defaultIsIndex;
119      int defaultSupportSaved;      int defaultSupportSaved;
120      enum lineType_e entrySeparator;      enum lineType_e entryStart;
121      int needsBootPrefix;      int needsBootPrefix;
122      int argsInQuotes;      int argsInQuotes;
123      int maxTitleLength;      int maxTitleLength;
# Line 143  struct configFileInfo grubConfigType = { Line 145  struct configFileInfo grubConfigType = {
145      .keywords = grubKeywords,      .keywords = grubKeywords,
146      .defaultIsIndex = 1,      .defaultIsIndex = 1,
147      .defaultSupportSaved = 1,      .defaultSupportSaved = 1,
148      .entrySeparator = LT_TITLE,      .entryStart = LT_TITLE,
149      .needsBootPrefix = 1,      .needsBootPrefix = 1,
150      .mbHyperFirst = 1,      .mbHyperFirst = 1,
151      .mbInitRdIsModule = 1,      .mbInitRdIsModule = 1,
# Line 247  int useextlinuxmenu; Line 249  int useextlinuxmenu;
249  struct configFileInfo eliloConfigType = {  struct configFileInfo eliloConfigType = {
250      .defaultConfig = "/boot/efi/EFI/redhat/elilo.conf",      .defaultConfig = "/boot/efi/EFI/redhat/elilo.conf",
251      .keywords = eliloKeywords,      .keywords = eliloKeywords,
252      .entrySeparator = LT_KERNEL,      .entryStart = LT_KERNEL,
253      .needsBootPrefix = 1,      .needsBootPrefix = 1,
254      .argsInQuotes = 1,      .argsInQuotes = 1,
255      .mbConcatArgs = 1,      .mbConcatArgs = 1,
# Line 256  struct configFileInfo eliloConfigType = Line 258  struct configFileInfo eliloConfigType =
258  struct configFileInfo liloConfigType = {  struct configFileInfo liloConfigType = {
259      .defaultConfig = "/etc/lilo.conf",      .defaultConfig = "/etc/lilo.conf",
260      .keywords = liloKeywords,      .keywords = liloKeywords,
261      .entrySeparator = LT_KERNEL,      .entryStart = LT_KERNEL,
262      .argsInQuotes = 1,      .argsInQuotes = 1,
263      .maxTitleLength = 15,      .maxTitleLength = 15,
264  };  };
# Line 264  struct configFileInfo liloConfigType = { Line 266  struct configFileInfo liloConfigType = {
266  struct configFileInfo yabootConfigType = {  struct configFileInfo yabootConfigType = {
267      .defaultConfig = "/etc/yaboot.conf",      .defaultConfig = "/etc/yaboot.conf",
268      .keywords = yabootKeywords,      .keywords = yabootKeywords,
269      .entrySeparator = LT_KERNEL,      .entryStart = LT_KERNEL,
270      .needsBootPrefix = 1,      .needsBootPrefix = 1,
271      .argsInQuotes = 1,      .argsInQuotes = 1,
272      .maxTitleLength = 15,      .maxTitleLength = 15,
# Line 274  struct configFileInfo yabootConfigType = Line 276  struct configFileInfo yabootConfigType =
276  struct configFileInfo siloConfigType = {  struct configFileInfo siloConfigType = {
277      .defaultConfig = "/etc/silo.conf",      .defaultConfig = "/etc/silo.conf",
278      .keywords = siloKeywords,      .keywords = siloKeywords,
279      .entrySeparator = LT_KERNEL,      .entryStart = LT_KERNEL,
280      .needsBootPrefix = 1,      .needsBootPrefix = 1,
281      .argsInQuotes = 1,      .argsInQuotes = 1,
282      .maxTitleLength = 15,      .maxTitleLength = 15,
# Line 283  struct configFileInfo siloConfigType = { Line 285  struct configFileInfo siloConfigType = {
285  struct configFileInfo ziplConfigType = {  struct configFileInfo ziplConfigType = {
286      .defaultConfig = "/etc/zipl.conf",      .defaultConfig = "/etc/zipl.conf",
287      .keywords = ziplKeywords,      .keywords = ziplKeywords,
288      .entrySeparator = LT_TITLE,      .entryStart = LT_TITLE,
289      .argsInQuotes = 1,      .argsInQuotes = 1,
290      .titleBracketed = 1,      .titleBracketed = 1,
291  };  };
# Line 291  struct configFileInfo ziplConfigType = { Line 293  struct configFileInfo ziplConfigType = {
293  struct configFileInfo extlinuxConfigType = {  struct configFileInfo extlinuxConfigType = {
294      .defaultConfig = "/boot/extlinux/extlinux.conf",      .defaultConfig = "/boot/extlinux/extlinux.conf",
295      .keywords = extlinuxKeywords,      .keywords = extlinuxKeywords,
296      .entrySeparator = LT_TITLE,      .entryStart = LT_TITLE,
297      .needsBootPrefix = 1,      .needsBootPrefix = 1,
298      .maxTitleLength = 255,      .maxTitleLength = 255,
299      .mbAllowExtraInitRds = 1,      .mbAllowExtraInitRds = 1,
# Line 437  static int isBracketedTitle(struct singl Line 439  static int isBracketedTitle(struct singl
439      return 0;      return 0;
440  }  }
441    
442  static int isEntrySeparator(struct singleLine * line,  static int isEntryStart(struct singleLine * line,
443                              struct configFileInfo * cfi) {                              struct configFileInfo * cfi) {
444      return line->type == cfi->entrySeparator || line->type == LT_OTHER ||      return line->type == cfi->entryStart || line->type == LT_OTHER ||
445   (cfi->titleBracketed && isBracketedTitle(line));   (cfi->titleBracketed && isBracketedTitle(line));
446  }  }
447    
# Line 762  static struct grubConfig * readConfig(co Line 764  static struct grubConfig * readConfig(co
764      cfg->secondaryIndent = strdup(line->indent);      cfg->secondaryIndent = strdup(line->indent);
765   }   }
766    
767   if (isEntrySeparator(line, cfi)) {   if (isEntryStart(line, cfi)) {
768      sawEntry = 1;      sawEntry = 1;
769      if (!entry) {      if (!entry) {
770   cfg->entries = malloc(sizeof(*entry));   cfg->entries = malloc(sizeof(*entry));
# Line 2673  int addNewKernel(struct grubConfig * con Line 2675  int addNewKernel(struct grubConfig * con
2675   /* don't have a template, so start the entry with the   /* don't have a template, so start the entry with the
2676   * appropriate starting line   * appropriate starting line
2677   */   */
2678   switch (config->cfi->entrySeparator) {   switch (config->cfi->entryStart) {
2679      case LT_KERNEL:      case LT_KERNEL:
2680   if (new->multiboot && config->cfi->mbHyperFirst) {   if (new->multiboot && config->cfi->mbHyperFirst) {
2681      /* fall through to LT_HYPER */      /* fall through to LT_HYPER */
# Line 2725  int addNewKernel(struct grubConfig * con Line 2727  int addNewKernel(struct grubConfig * con
2727    
2728      /* add the remainder of the lines, i.e. those that either      /* add the remainder of the lines, i.e. those that either
2729       * weren't present in the template, or in the case of no template,       * weren't present in the template, or in the case of no template,
2730       * all the lines following the entrySeparator.       * all the lines following the entryStart.
2731       */       */
2732      if (needs & NEED_TITLE) {      if (needs & NEED_TITLE) {
2733   newLine = addLine(new, config->cfi, LT_TITLE,   newLine = addLine(new, config->cfi, LT_TITLE,

Legend:
Removed from v.1692  
changed lines
  Added in v.1694