Magellan Linux

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

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

revision 2682 by niro, Wed Jul 16 09:49:24 2014 UTC revision 2683 by niro, Wed Jul 16 09:51:14 2014 UTC
# Line 90  enum lineType_e { Line 90  enum lineType_e {
90      LT_SET_VARIABLE = 1 << 19,      LT_SET_VARIABLE = 1 << 19,
91      LT_KERNEL_EFI   = 1 << 20,      LT_KERNEL_EFI   = 1 << 20,
92      LT_INITRD_EFI   = 1 << 21,      LT_INITRD_EFI   = 1 << 21,
93      LT_UNKNOWN      = 1 << 22,      LT_KERNEL_16    = 1 << 22,
94        LT_INITRD_16    = 1 << 23,
95        LT_UNKNOWN      = 1 << 24,
96  };  };
97    
98  struct singleLine {  struct singleLine {
# Line 223  struct keywordTypes grub2Keywords[] = { Line 225  struct keywordTypes grub2Keywords[] = {
225      { "fallback",   LT_FALLBACK,    ' ' },      { "fallback",   LT_FALLBACK,    ' ' },
226      { "linux",      LT_KERNEL,      ' ' },      { "linux",      LT_KERNEL,      ' ' },
227      { "linuxefi",   LT_KERNEL_EFI,  ' ' },      { "linuxefi",   LT_KERNEL_EFI,  ' ' },
228        { "linux16",    LT_KERNEL_16,   ' ' },
229      { "initrd",     LT_INITRD,      ' ', ' ' },      { "initrd",     LT_INITRD,      ' ', ' ' },
230      { "initrdefi",  LT_INITRD_EFI,  ' ', ' ' },      { "initrdefi",  LT_INITRD_EFI,  ' ', ' ' },
231        { "initrd16",   LT_INITRD_16,   ' ', ' ' },
232      { "module",     LT_MBMODULE,    ' ' },      { "module",     LT_MBMODULE,    ' ' },
233      { "kernel",     LT_HYPER,       ' ' },      { "kernel",     LT_HYPER,       ' ' },
234      { NULL, 0, 0 },      { NULL, 0, 0 },
# Line 398  static int isquote(char q) Line 402  static int isquote(char q)
402  }  }
403    
404  static int iskernel(enum lineType_e type) {  static int iskernel(enum lineType_e type) {
405      return (type == LT_KERNEL || type == LT_KERNEL_EFI);      return (type == LT_KERNEL || type == LT_KERNEL_EFI || type == LT_KERNEL_16);
406  }  }
407    
408  static int isinitrd(enum lineType_e type) {  static int isinitrd(enum lineType_e type) {
409      return (type == LT_INITRD || type == LT_INITRD_EFI);      return (type == LT_INITRD || type == LT_INITRD_EFI || type == LT_INITRD_16);
410  }  }
411    
412  char *grub2ExtractTitle(struct singleLine * line) {  char *grub2ExtractTitle(struct singleLine * line) {
# Line 720  static enum lineType_e preferredLineType Line 724  static enum lineType_e preferredLineType
724   default:   default:
725      return type;      return type;
726   }   }
727    #if defined(__i386__) || defined(__x86_64__)
728        } else if (cfi == &grub2ConfigType) {
729     switch (type) {
730     case LT_KERNEL:
731        return LT_KERNEL_16;
732     case LT_INITRD:
733        return LT_INITRD_16;
734     default:
735        return type;
736     }
737    #endif
738      }      }
739      return type;      return type;
740  }  }
# Line 1807  int suitableImage(struct singleEntry * e Line 1822  int suitableImage(struct singleEntry * e
1822   return 0;   return 0;
1823      }      }
1824    
1825      line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI, entry->lines);      line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
1826      if (!line) {      if (!line) {
1827   notSuitablePrintf(entry, 0, "no line found\n");   notSuitablePrintf(entry, 0, "no line found\n");
1828   return 0;   return 0;
# Line 1941  struct singleEntry * findEntryByPath(str Line 1956  struct singleEntry * findEntryByPath(str
1956   entry = findEntryByIndex(config, indexVars[i]);   entry = findEntryByIndex(config, indexVars[i]);
1957   if (!entry) return NULL;   if (!entry) return NULL;
1958    
1959   line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI, entry->lines);   line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
1960   if (!line) return NULL;   if (!line) return NULL;
1961    
1962   if (index) *index = indexVars[i];   if (index) *index = indexVars[i];
# Line 1992  struct singleEntry * findEntryByPath(str Line 2007  struct singleEntry * findEntryByPath(str
2007      for (line = entry->lines; line; line = line->next) {      for (line = entry->lines; line; line = line->next) {
2008   enum lineType_e ct = checkType;   enum lineType_e ct = checkType;
2009   if (entry->multiboot && checkType == LT_KERNEL)   if (entry->multiboot && checkType == LT_KERNEL)
2010      ct = LT_KERNEL|LT_KERNEL_EFI|LT_MBMODULE|LT_HYPER;      ct = LT_KERNEL|LT_KERNEL_EFI|LT_MBMODULE|LT_HYPER|LT_KERNEL_16;
2011   else if (checkType & LT_KERNEL)   else if (checkType & LT_KERNEL)
2012      ct = checkType | LT_KERNEL_EFI;      ct = checkType | LT_KERNEL_EFI | LT_KERNEL_16;
2013   line = getLineByType(ct, line);   line = getLineByType(ct, line);
2014   if (!line)   if (!line)
2015      break;  /* not found in this entry */      break;  /* not found in this entry */
# Line 2016  struct singleEntry * findEntryByPath(str Line 2031  struct singleEntry * findEntryByPath(str
2031       * non-Linux boot entries (could find netbsd etc, though, which is       * non-Linux boot entries (could find netbsd etc, though, which is
2032       * unfortunate)       * unfortunate)
2033       */       */
2034      if (line && getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI, entry->lines))      if (line && getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines))
2035   break; /* found 'im! */   break; /* found 'im! */
2036   }   }
2037    
# Line 2250  void displayEntry(struct singleEntry * e Line 2265  void displayEntry(struct singleEntry * e
2265    
2266      printf("index=%d\n", index);      printf("index=%d\n", index);
2267    
2268      line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI, entry->lines);      line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
2269      if (!line) {      if (!line) {
2270          printf("non linux entry\n");          printf("non linux entry\n");
2271          return;          return;
# Line 2315  void displayEntry(struct singleEntry * e Line 2330  void displayEntry(struct singleEntry * e
2330   printf("root=%s\n", s);   printf("root=%s\n", s);
2331      }      }
2332    
2333      line = getLineByType(LT_INITRD|LT_INITRD_EFI, entry->lines);      line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines);
2334    
2335      if (line && line->numElements >= 2) {      if (line && line->numElements >= 2) {
2336   if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))   if (!strncmp(prefix, line->elements[1].item, strlen(prefix)))
# Line 2732  struct singleLine * addLineTmpl(struct s Line 2747  struct singleLine * addLineTmpl(struct s
2747   insertElement(newLine, val, 1, cfi);   insertElement(newLine, val, 1, cfi);
2748    
2749   /* but try to keep the rootspec from the template... sigh */   /* but try to keep the rootspec from the template... sigh */
2750   if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI)) {   if (tmplLine->type & (LT_HYPER|LT_KERNEL|LT_MBMODULE|LT_INITRD|LT_KERNEL_EFI|LT_INITRD_EFI|LT_KERNEL_16|LT_INITRD_16)) {
2751      char * rootspec = getRootSpecifier(tmplLine->elements[1].item);      char * rootspec = getRootSpecifier(tmplLine->elements[1].item);
2752      if (rootspec != NULL) {      if (rootspec != NULL) {
2753   free(newLine->elements[1].item);   free(newLine->elements[1].item);
# Line 3102  int updateActualImage(struct grubConfig Line 3117  int updateActualImage(struct grubConfig
3117      firstElement = 2;      firstElement = 2;
3118    
3119   } else {   } else {
3120      line = getLineByType(LT_KERNEL|LT_MBMODULE|LT_KERNEL_EFI, entry->lines);      line = getLineByType(LT_KERNEL|LT_MBMODULE|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
3121      if (!line) {      if (!line) {
3122   /* no LT_KERNEL or LT_MBMODULE in this entry? */   /* no LT_KERNEL or LT_MBMODULE in this entry? */
3123   continue;   continue;
# Line 3303  int updateInitrd(struct grubConfig * cfg Line 3318  int updateInitrd(struct grubConfig * cfg
3318      if (!image) return 0;      if (!image) return 0;
3319    
3320      for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) {      for (; (entry = findEntryByPath(cfg, image, prefix, &index)); index++) {
3321          kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI, entry->lines);          kernelLine = getLineByType(LT_KERNEL|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
3322          if (!kernelLine) continue;          if (!kernelLine) continue;
3323    
3324          line = getLineByType(LT_INITRD|LT_INITRD_EFI, entry->lines);          line = getLineByType(LT_INITRD|LT_INITRD_EFI|LT_INITRD_16, entry->lines);
3325          if (line)          if (line)
3326              removeLine(entry, line);              removeLine(entry, line);
3327          if (prefix) {          if (prefix) {
# Line 3317  int updateInitrd(struct grubConfig * cfg Line 3332  int updateInitrd(struct grubConfig * cfg
3332   endLine = getLineByType(LT_ENTRY_END, entry->lines);   endLine = getLineByType(LT_ENTRY_END, entry->lines);
3333   if (endLine)   if (endLine)
3334      removeLine(entry, endLine);      removeLine(entry, endLine);
3335          line = addLine(entry, cfg->cfi, preferredLineType(LT_INITRD, cfg->cfi),   enum lineType_e lt;
3336   kernelLine->indent, initrd);   switch(kernelLine->type) {
3337        case LT_KERNEL:
3338            lt = LT_INITRD;
3339     break;
3340        case LT_KERNEL_EFI:
3341            lt = LT_INITRD_EFI;
3342     break;
3343        case LT_KERNEL_16:
3344            lt = LT_INITRD_16;
3345     break;
3346        default:
3347            lt = preferredLineType(LT_INITRD, cfg->cfi);
3348     }
3349            line = addLine(entry, cfg->cfi, lt, kernelLine->indent, initrd);
3350          if (!line)          if (!line)
3351      return 1;      return 1;
3352   if (endLine) {   if (endLine) {
# Line 3916  int addNewKernel(struct grubConfig * con Line 3944  int addNewKernel(struct grubConfig * con
3944   switch (config->cfi->entryStart) {   switch (config->cfi->entryStart) {
3945      case LT_KERNEL:      case LT_KERNEL:
3946      case LT_KERNEL_EFI:      case LT_KERNEL_EFI:
3947        case LT_KERNEL_16:
3948   if (new->multiboot && config->cfi->mbHyperFirst) {   if (new->multiboot && config->cfi->mbHyperFirst) {
3949      /* fall through to LT_HYPER */      /* fall through to LT_HYPER */
3950   } else {   } else {
# Line 4474  int main(int argc, const char ** argv) { Line 4503  int main(int argc, const char ** argv) {
4503   if (!entry) return 0;   if (!entry) return 0;
4504   if (!suitableImage(entry, bootPrefix, 0, flags)) return 0;   if (!suitableImage(entry, bootPrefix, 0, flags)) return 0;
4505    
4506   line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI, entry->lines);   line = getLineByType(LT_KERNEL|LT_HYPER|LT_KERNEL_EFI|LT_KERNEL_16, entry->lines);
4507   if (!line) return 0;   if (!line) return 0;
4508    
4509          rootspec = getRootSpecifier(line->elements[1].item);          rootspec = getRootSpecifier(line->elements[1].item);

Legend:
Removed from v.2682  
changed lines
  Added in v.2683