Magellan Linux

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

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

revision 2683 by niro, Wed Jul 16 09:51:14 2014 UTC revision 2687 by niro, Wed Jul 16 10:41:38 2014 UTC
# Line 92  enum lineType_e { Line 92  enum lineType_e {
92      LT_INITRD_EFI   = 1 << 21,      LT_INITRD_EFI   = 1 << 21,
93      LT_KERNEL_16    = 1 << 22,      LT_KERNEL_16    = 1 << 22,
94      LT_INITRD_16    = 1 << 23,      LT_INITRD_16    = 1 << 23,
95      LT_UNKNOWN      = 1 << 24,      LT_DEVTREE      = 1 << 24,
96        LT_UNKNOWN      = 1 << 25,
97  };  };
98    
99  struct singleLine {  struct singleLine {
# Line 121  struct singleEntry { Line 122  struct singleEntry {
122  #define NEED_ARGS    (1 << 3)  #define NEED_ARGS    (1 << 3)
123  #define NEED_MB      (1 << 4)  #define NEED_MB      (1 << 4)
124  #define NEED_END     (1 << 5)  #define NEED_END     (1 << 5)
125    #define NEED_DEVTREE (1 << 6)
126    
127  #define MAIN_DEFAULT    (1 << 0)  #define MAIN_DEFAULT    (1 << 0)
128  #define DEFAULT_SAVED       -2  #define DEFAULT_SAVED       -2
# Line 231  struct keywordTypes grub2Keywords[] = { Line 233  struct keywordTypes grub2Keywords[] = {
233      { "initrd16",   LT_INITRD_16,   ' ', ' ' },      { "initrd16",   LT_INITRD_16,   ' ', ' ' },
234      { "module",     LT_MBMODULE,    ' ' },      { "module",     LT_MBMODULE,    ' ' },
235      { "kernel",     LT_HYPER,       ' ' },      { "kernel",     LT_HYPER,       ' ' },
236        { "devicetree", LT_DEVTREE,  ' ' },
237      { NULL, 0, 0 },      { NULL, 0, 0 },
238  };  };
239    
# Line 717  static enum lineType_e preferredLineType Line 720  static enum lineType_e preferredLineType
720   struct configFileInfo *cfi) {   struct configFileInfo *cfi) {
721      if (isEfi && cfi == &grub2ConfigType) {      if (isEfi && cfi == &grub2ConfigType) {
722   switch (type) {   switch (type) {
723    #if defined(__aarch64__)
724     case LT_KERNEL:
725        return LT_KERNEL;
726     case LT_INITRD:
727        return LT_INITRD;
728    #else
729   case LT_KERNEL:   case LT_KERNEL:
730      return LT_KERNEL_EFI;      return LT_KERNEL_EFI;
731   case LT_INITRD:   case LT_INITRD:
732      return LT_INITRD_EFI;      return LT_INITRD_EFI;
733    #endif
734   default:   default:
735      return type;      return type;
736   }   }
# Line 3705  int addNewKernel(struct grubConfig * con Line 3715  int addNewKernel(struct grubConfig * con
3715   const char * newKernelPath, const char * newKernelTitle,   const char * newKernelPath, const char * newKernelTitle,
3716   const char * newKernelArgs, const char * newKernelInitrd,   const char * newKernelArgs, const char * newKernelInitrd,
3717   const char ** extraInitrds, int extraInitrdCount,   const char ** extraInitrds, int extraInitrdCount,
3718                   const char * newMBKernel, const char * newMBKernelArgs) {                   const char * newMBKernel, const char * newMBKernelArgs,
3719     const char * newDevTreePath) {
3720      struct singleEntry * new;      struct singleEntry * new;
3721      struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL;      struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL;
3722      int needs;      int needs;
# Line 3746  int addNewKernel(struct grubConfig * con Line 3757  int addNewKernel(struct grubConfig * con
3757          needs |= NEED_MB;          needs |= NEED_MB;
3758          new->multiboot = 1;          new->multiboot = 1;
3759      }      }
3760        if (newDevTreePath && getKeywordByType(LT_DEVTREE, config->cfi))
3761     needs |= NEED_DEVTREE;
3762    
3763      if (template) {      if (template) {
3764   for (masterLine = template->lines;   for (masterLine = template->lines;
# Line 3931  int addNewKernel(struct grubConfig * con Line 3944  int addNewKernel(struct grubConfig * con
3944   newLine = addLineTmpl(new, tmplLine, newLine, NULL,   newLine = addLineTmpl(new, tmplLine, newLine, NULL,
3945   config->cfi);   config->cfi);
3946      }      }
3947        } else if (tmplLine->type == LT_DEVTREE &&
3948           tmplLine->numElements == 2 && newDevTreePath) {
3949            newLine = addLineTmpl(new, tmplLine, newLine,
3950          newDevTreePath + strlen(prefix),
3951          config->cfi);
3952     needs &= ~NEED_DEVTREE;
3953        } else if (tmplLine->type == LT_ENTRY_END && needs & NEED_DEVTREE) {
3954     const char *ndtp = newDevTreePath;
3955     if (!strncmp(newDevTreePath, prefix, strlen(prefix)))
3956        ndtp += strlen(prefix);
3957     newLine = addLine(new, config->cfi, LT_DEVTREE,
3958      config->secondaryIndent,
3959      ndtp);
3960     needs &= ~NEED_DEVTREE;
3961     newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi);
3962      } else {      } else {
3963   /* pass through other lines from the template */   /* pass through other lines from the template */
3964   newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi);   newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi);
# Line 4051  int addNewKernel(struct grubConfig * con Line 4079  int addNewKernel(struct grubConfig * con
4079   free(initrdVal);   free(initrdVal);
4080   needs &= ~NEED_INITRD;   needs &= ~NEED_INITRD;
4081      }      }
4082        if (needs & NEED_DEVTREE) {
4083     newLine = addLine(new, config->cfi, LT_DEVTREE,
4084      config->secondaryIndent,
4085      newDevTreePath);
4086     needs &= ~NEED_DEVTREE;
4087        }
4088    
4089        /* NEEDS_END must be last on bootloaders that need it... */
4090      if (needs & NEED_END) {      if (needs & NEED_END) {
4091   newLine = addLine(new, config->cfi, LT_ENTRY_END,   newLine = addLine(new, config->cfi, LT_ENTRY_END,
4092   config->secondaryIndent, NULL);   config->secondaryIndent, NULL);
4093   needs &= ~NEED_END;   needs &= ~NEED_END;
4094      }      }
   
4095      if (needs) {      if (needs) {
4096   printf(_("grubby: needs=%d, aborting\n"), needs);   printf(_("grubby: needs=%d, aborting\n"), needs);
4097   abort();   abort();
# Line 4102  int main(int argc, const char ** argv) { Line 4137  int main(int argc, const char ** argv) {
4137      char * newKernelArgs = NULL;      char * newKernelArgs = NULL;
4138      char * newKernelInitrd = NULL;      char * newKernelInitrd = NULL;
4139      char * newKernelTitle = NULL;      char * newKernelTitle = NULL;
4140      char * newKernelVersion = NULL;      char * newDevTreePath = NULL;
4141      char * newMBKernel = NULL;      char * newMBKernel = NULL;
4142      char * newMBKernelArgs = NULL;      char * newMBKernelArgs = NULL;
4143      char * removeMBKernelArgs = NULL;      char * removeMBKernelArgs = NULL;
# Line 4160  int main(int argc, const char ** argv) { Line 4195  int main(int argc, const char ** argv) {
4195      _("display the index of the default kernel") },      _("display the index of the default kernel") },
4196   { "default-title", 0, 0, &displayDefaultTitle, 0,   { "default-title", 0, 0, &displayDefaultTitle, 0,
4197      _("display the title of the default kernel") },      _("display the title of the default kernel") },
4198     { "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0,
4199        _("device tree file for new stanza"), _("dtb-path") },
4200   { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0,   { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0,
4201      _("configure elilo bootloader") },      _("configure elilo bootloader") },
4202   { "efi", 0, POPT_ARG_NONE, &isEfi, 0,   { "efi", 0, POPT_ARG_NONE, &isEfi, 0,
# Line 4325  int main(int argc, const char ** argv) { Line 4362  int main(int argc, const char ** argv) {
4362      grubConfig = cfi->defaultConfig;      grubConfig = cfi->defaultConfig;
4363      }      }
4364    
4365      if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||      if (bootloaderProbe && (displayDefault || kernelInfo ||
4366      newKernelPath || removeKernelPath || makeDefault ||      newKernelPath || removeKernelPath || makeDefault ||
4367      defaultKernel || displayDefaultIndex || displayDefaultTitle ||      defaultKernel || displayDefaultIndex || displayDefaultTitle ||
4368      (defaultIndex >= 0))) {      (defaultIndex >= 0))) {
# Line 4334  int main(int argc, const char ** argv) { Line 4371  int main(int argc, const char ** argv) {
4371   return 1;   return 1;
4372      }      }
4373    
4374      if ((displayDefault || kernelInfo) && (newKernelVersion || newKernelPath ||      if ((displayDefault || kernelInfo) && (newKernelPath ||
4375     removeKernelPath)) {     removeKernelPath)) {
4376   fprintf(stderr, _("grubby: --default-kernel and --info may not "   fprintf(stderr, _("grubby: --default-kernel and --info may not "
4377    "be used when adding or removing kernels\n"));    "be used when adding or removing kernels\n"));
# Line 4577  int main(int argc, const char ** argv) { Line 4614  int main(int argc, const char ** argv) {
4614      if (addNewKernel(config, template, bootPrefix, newKernelPath,      if (addNewKernel(config, template, bootPrefix, newKernelPath,
4615                       newKernelTitle, newKernelArgs, newKernelInitrd,                       newKernelTitle, newKernelArgs, newKernelInitrd,
4616                       (const char **)extraInitrds, extraInitrdCount,                       (const char **)extraInitrds, extraInitrdCount,
4617                       newMBKernel, newMBKernelArgs)) return 1;                       newMBKernel, newMBKernelArgs, newDevTreePath)) return 1;
4618            
4619    
4620      if (numEntries(config) == 0) {      if (numEntries(config) == 0) {

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