Magellan Linux

Diff of /trunk/grubby/grubby.c

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

revision 2684 by niro, Wed Jul 16 09:51:14 2014 UTC revision 2685 by niro, Wed Jul 16 10:38:09 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 3705  int addNewKernel(struct grubConfig * con Line 3708  int addNewKernel(struct grubConfig * con
3708   const char * newKernelPath, const char * newKernelTitle,   const char * newKernelPath, const char * newKernelTitle,
3709   const char * newKernelArgs, const char * newKernelInitrd,   const char * newKernelArgs, const char * newKernelInitrd,
3710   const char ** extraInitrds, int extraInitrdCount,   const char ** extraInitrds, int extraInitrdCount,
3711                   const char * newMBKernel, const char * newMBKernelArgs) {                   const char * newMBKernel, const char * newMBKernelArgs,
3712     const char * newDevTreePath) {
3713      struct singleEntry * new;      struct singleEntry * new;
3714      struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL;      struct singleLine * newLine = NULL, * tmplLine = NULL, * masterLine = NULL;
3715      int needs;      int needs;
# Line 3746  int addNewKernel(struct grubConfig * con Line 3750  int addNewKernel(struct grubConfig * con
3750          needs |= NEED_MB;          needs |= NEED_MB;
3751          new->multiboot = 1;          new->multiboot = 1;
3752      }      }
3753        if (newDevTreePath && getKeywordByType(LT_DEVTREE, config->cfi))
3754     needs |= NEED_DEVTREE;
3755    
3756      if (template) {      if (template) {
3757   for (masterLine = template->lines;   for (masterLine = template->lines;
# Line 3931  int addNewKernel(struct grubConfig * con Line 3937  int addNewKernel(struct grubConfig * con
3937   newLine = addLineTmpl(new, tmplLine, newLine, NULL,   newLine = addLineTmpl(new, tmplLine, newLine, NULL,
3938   config->cfi);   config->cfi);
3939      }      }
3940        } else if (tmplLine->type == LT_DEVTREE &&
3941           tmplLine->numElements == 2 && newDevTreePath) {
3942            newLine = addLineTmpl(new, tmplLine, newLine,
3943          newDevTreePath + strlen(prefix),
3944          config->cfi);
3945     needs &= ~NEED_DEVTREE;
3946        } else if (tmplLine->type == LT_ENTRY_END && needs & NEED_DEVTREE) {
3947     const char *ndtp = newDevTreePath;
3948     if (!strncmp(newDevTreePath, prefix, strlen(prefix)))
3949        ndtp += strlen(prefix);
3950     newLine = addLine(new, config->cfi, LT_DEVTREE,
3951      config->secondaryIndent,
3952      ndtp);
3953     needs &= ~NEED_DEVTREE;
3954     newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi);
3955      } else {      } else {
3956   /* pass through other lines from the template */   /* pass through other lines from the template */
3957   newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi);   newLine = addLineTmpl(new, tmplLine, newLine, NULL, config->cfi);
# Line 4051  int addNewKernel(struct grubConfig * con Line 4072  int addNewKernel(struct grubConfig * con
4072   free(initrdVal);   free(initrdVal);
4073   needs &= ~NEED_INITRD;   needs &= ~NEED_INITRD;
4074      }      }
4075        if (needs & NEED_DEVTREE) {
4076     newLine = addLine(new, config->cfi, LT_DEVTREE,
4077      config->secondaryIndent,
4078      newDevTreePath);
4079     needs &= ~NEED_DEVTREE;
4080        }
4081    
4082        /* NEEDS_END must be last on bootloaders that need it... */
4083      if (needs & NEED_END) {      if (needs & NEED_END) {
4084   newLine = addLine(new, config->cfi, LT_ENTRY_END,   newLine = addLine(new, config->cfi, LT_ENTRY_END,
4085   config->secondaryIndent, NULL);   config->secondaryIndent, NULL);
4086   needs &= ~NEED_END;   needs &= ~NEED_END;
4087      }      }
   
4088      if (needs) {      if (needs) {
4089   printf(_("grubby: needs=%d, aborting\n"), needs);   printf(_("grubby: needs=%d, aborting\n"), needs);
4090   abort();   abort();
# Line 4102  int main(int argc, const char ** argv) { Line 4130  int main(int argc, const char ** argv) {
4130      char * newKernelArgs = NULL;      char * newKernelArgs = NULL;
4131      char * newKernelInitrd = NULL;      char * newKernelInitrd = NULL;
4132      char * newKernelTitle = NULL;      char * newKernelTitle = NULL;
4133      char * newKernelVersion = NULL;      char * newDevTreePath = NULL;
4134      char * newMBKernel = NULL;      char * newMBKernel = NULL;
4135      char * newMBKernelArgs = NULL;      char * newMBKernelArgs = NULL;
4136      char * removeMBKernelArgs = NULL;      char * removeMBKernelArgs = NULL;
# Line 4160  int main(int argc, const char ** argv) { Line 4188  int main(int argc, const char ** argv) {
4188      _("display the index of the default kernel") },      _("display the index of the default kernel") },
4189   { "default-title", 0, 0, &displayDefaultTitle, 0,   { "default-title", 0, 0, &displayDefaultTitle, 0,
4190      _("display the title of the default kernel") },      _("display the title of the default kernel") },
4191     { "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0,
4192        _("device tree file for new stanza"), _("dtb-path") },
4193   { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0,   { "elilo", 0, POPT_ARG_NONE, &configureELilo, 0,
4194      _("configure elilo bootloader") },      _("configure elilo bootloader") },
4195   { "efi", 0, POPT_ARG_NONE, &isEfi, 0,   { "efi", 0, POPT_ARG_NONE, &isEfi, 0,
# Line 4325  int main(int argc, const char ** argv) { Line 4355  int main(int argc, const char ** argv) {
4355      grubConfig = cfi->defaultConfig;      grubConfig = cfi->defaultConfig;
4356      }      }
4357    
4358      if (bootloaderProbe && (displayDefault || kernelInfo || newKernelVersion ||      if (bootloaderProbe && (displayDefault || kernelInfo ||
4359      newKernelPath || removeKernelPath || makeDefault ||      newKernelPath || removeKernelPath || makeDefault ||
4360      defaultKernel || displayDefaultIndex || displayDefaultTitle ||      defaultKernel || displayDefaultIndex || displayDefaultTitle ||
4361      (defaultIndex >= 0))) {      (defaultIndex >= 0))) {
# Line 4334  int main(int argc, const char ** argv) { Line 4364  int main(int argc, const char ** argv) {
4364   return 1;   return 1;
4365      }      }
4366    
4367      if ((displayDefault || kernelInfo) && (newKernelVersion || newKernelPath ||      if ((displayDefault || kernelInfo) && (newKernelPath ||
4368     removeKernelPath)) {     removeKernelPath)) {
4369   fprintf(stderr, _("grubby: --default-kernel and --info may not "   fprintf(stderr, _("grubby: --default-kernel and --info may not "
4370    "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 4607  int main(int argc, const char ** argv) {
4607      if (addNewKernel(config, template, bootPrefix, newKernelPath,      if (addNewKernel(config, template, bootPrefix, newKernelPath,
4608                       newKernelTitle, newKernelArgs, newKernelInitrd,                       newKernelTitle, newKernelArgs, newKernelInitrd,
4609                       (const char **)extraInitrds, extraInitrdCount,                       (const char **)extraInitrds, extraInitrdCount,
4610                       newMBKernel, newMBKernelArgs)) return 1;                       newMBKernel, newMBKernelArgs, newDevTreePath)) return 1;
4611            
4612    
4613      if (numEntries(config) == 0) {      if (numEntries(config) == 0) {

Legend:
Removed from v.2684  
changed lines
  Added in v.2685