Magellan Linux

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

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

trunk/mkinitrd-magellan/grubby/grubby.c revision 1304 by niro, Fri May 27 16:19:11 2011 UTC trunk/grubby/grubby.c 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 139  struct keywordTypes grubKeywords[] = { Line 141  struct keywordTypes grubKeywords[] = {
141  };  };
142    
143  struct configFileInfo grubConfigType = {  struct configFileInfo grubConfigType = {
144      "/boot/grub/grub.conf",    /* defaultConfig */      .defaultConfig = "/boot/grub/grub.conf",
145      grubKeywords,    /* keywords */      .keywords = grubKeywords,
146      1,    /* defaultIsIndex */      .defaultIsIndex = 1,
147      1,    /* defaultSupportSaved */      .defaultSupportSaved = 1,
148      LT_TITLE,    /* entrySeparator */      .entryStart = LT_TITLE,
149      1,    /* needsBootPrefix */      .needsBootPrefix = 1,
150      0,    /* argsInQuotes */      .mbHyperFirst = 1,
151      0,    /* maxTitleLength */      .mbInitRdIsModule = 1,
152      0,                                      /* titleBracketed */      .mbAllowExtraInitRds = 1,
     1,                                      /* mbHyperFirst */  
     1,                                      /* mbInitRdIsModule */  
     0,                                      /* mbConcatArgs */  
     1,                                      /* mbAllowExtraInitRds */  
153  };  };
154    
155  struct keywordTypes yabootKeywords[] = {  struct keywordTypes yabootKeywords[] = {
# Line 249  struct keywordTypes extlinuxKeywords[] = Line 247  struct keywordTypes extlinuxKeywords[] =
247  };  };
248  int useextlinuxmenu;  int useextlinuxmenu;
249  struct configFileInfo eliloConfigType = {  struct configFileInfo eliloConfigType = {
250      "/boot/efi/EFI/redhat/elilo.conf",    /* defaultConfig */      .defaultConfig = "/boot/efi/EFI/redhat/elilo.conf",
251      eliloKeywords,    /* keywords */      .keywords = eliloKeywords,
252      0,    /* defaultIsIndex */      .entryStart = LT_KERNEL,
253      0,    /* defaultSupportSaved */      .needsBootPrefix = 1,
254      LT_KERNEL,    /* entrySeparator */      .argsInQuotes = 1,
255      1,                    /* needsBootPrefix */      .mbConcatArgs = 1,
     1,    /* argsInQuotes */  
     0,    /* maxTitleLength */  
     0,                                      /* titleBracketed */  
     0,                                      /* mbHyperFirst */  
     0,                                      /* mbInitRdIsModule */  
     1,                                      /* mbConcatArgs */  
     0,                                      /* mbAllowExtraInitRds */  
256  };  };
257    
258  struct configFileInfo liloConfigType = {  struct configFileInfo liloConfigType = {
259      "/etc/lilo.conf",    /* defaultConfig */      .defaultConfig = "/etc/lilo.conf",
260      liloKeywords,    /* keywords */      .keywords = liloKeywords,
261      0,    /* defaultIsIndex */      .entryStart = LT_KERNEL,
262      0,    /* defaultSupportSaved */      .argsInQuotes = 1,
263      LT_KERNEL,    /* entrySeparator */      .maxTitleLength = 15,
     0,    /* needsBootPrefix */  
     1,    /* argsInQuotes */  
     15,    /* maxTitleLength */  
     0,                                      /* titleBracketed */  
     0,                                      /* mbHyperFirst */  
     0,                                      /* mbInitRdIsModule */  
     0,                                      /* mbConcatArgs */  
     0,                                      /* mbAllowExtraInitRds */  
264  };  };
265    
266  struct configFileInfo yabootConfigType = {  struct configFileInfo yabootConfigType = {
267      "/etc/yaboot.conf",    /* defaultConfig */      .defaultConfig = "/etc/yaboot.conf",
268      yabootKeywords,    /* keywords */      .keywords = yabootKeywords,
269      0,    /* defaultIsIndex */      .entryStart = LT_KERNEL,
270      0,    /* defaultSupportSaved */      .needsBootPrefix = 1,
271      LT_KERNEL,    /* entrySeparator */      .argsInQuotes = 1,
272      1,    /* needsBootPrefix */      .maxTitleLength = 15,
273      1,    /* argsInQuotes */      .mbAllowExtraInitRds = 1,
     15,    /* maxTitleLength */  
     0,                                      /* titleBracketed */  
     0,                                      /* mbHyperFirst */  
     0,                                      /* mbInitRdIsModule */  
     0,                                      /* mbConcatArgs */  
     1,                                      /* mbAllowExtraInitRds */  
274  };  };
275    
276  struct configFileInfo siloConfigType = {  struct configFileInfo siloConfigType = {
277      "/etc/silo.conf",    /* defaultConfig */      .defaultConfig = "/etc/silo.conf",
278      siloKeywords,    /* keywords */      .keywords = siloKeywords,
279      0,    /* defaultIsIndex */      .entryStart = LT_KERNEL,
280      0,    /* defaultSupportSaved */      .needsBootPrefix = 1,
281      LT_KERNEL,    /* entrySeparator */      .argsInQuotes = 1,
282      1,    /* needsBootPrefix */      .maxTitleLength = 15,
     1,    /* argsInQuotes */  
     15,    /* maxTitleLength */  
     0,                                      /* titleBracketed */  
     0,                                      /* mbHyperFirst */  
     0,                                      /* mbInitRdIsModule */  
     0,                                      /* mbConcatArgs */  
     0,                                      /* mbAllowExtraInitRds */  
283  };  };
284    
285  struct configFileInfo ziplConfigType = {  struct configFileInfo ziplConfigType = {
286      "/etc/zipl.conf",    /* defaultConfig */      .defaultConfig = "/etc/zipl.conf",
287      ziplKeywords,    /* keywords */      .keywords = ziplKeywords,
288      0,    /* defaultIsIndex */      .entryStart = LT_TITLE,
289      0,    /* defaultSupportSaved */      .argsInQuotes = 1,
290      LT_TITLE,    /* entrySeparator */      .titleBracketed = 1,
     0,    /* needsBootPrefix */  
     1,    /* argsInQuotes */  
     0,    /* maxTitleLength */  
     1,                                      /* titleBracketed */  
     0,                                      /* mbHyperFirst */  
     0,                                      /* mbInitRdIsModule */  
     0,                                      /* mbConcatArgs */  
     0,                                      /* mbAllowExtraInitRds */  
291  };  };
292    
293  struct configFileInfo extlinuxConfigType = {  struct configFileInfo extlinuxConfigType = {
294      "/boot/extlinux/extlinux.conf",         /* defaultConfig */      .defaultConfig = "/boot/extlinux/extlinux.conf",
295      extlinuxKeywords,                       /* keywords */      .keywords = extlinuxKeywords,
296      0,                                      /* defaultIsIndex */      .entryStart = LT_TITLE,
297      0,                                      /* defaultSupportSaved */      .needsBootPrefix = 1,
298      LT_TITLE,                               /* entrySeparator */      .maxTitleLength = 255,
299      1,                                      /* needsBootPrefix */      .mbAllowExtraInitRds = 1,
     0,                                      /* argsInQuotes */  
     255,                                    /* maxTitleLength */  
     0,                                      /* titleBracketed */  
     0,                                      /* mbHyperFirst */  
     0,                                      /* mbInitRdIsModule */  
     0,                                      /* mbConcatArgs */  
     1,                                      /* mbAllowExtraInitRds */  
300  };  };
301    
302  struct grubConfig {  struct grubConfig {
# Line 484  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 809  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 2720  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 2772  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.1304  
changed lines
  Added in v.1694