Magellan Linux

Diff of /trunk/grubby/grubby.c

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

revision 3026 by niro, Tue Jun 27 14:43:04 2017 UTC revision 3029 by niro, Tue Jun 27 14:46:56 2017 UTC
# Line 2525  void setDefaultImage(struct grubConfig * Line 2525  void setDefaultImage(struct grubConfig *
2525   struct singleEntry *bootEntry, *newDefault;   struct singleEntry *bootEntry, *newDefault;
2526   int indexToVerify, firstKernelEntryIndex, currentLookupIndex;   int indexToVerify, firstKernelEntryIndex, currentLookupIndex;
2527    
2528            /* initialize */
2529            currentLookupIndex = FIRST_ENTRY_INDEX;
2530    
2531   /* handle the two cases where the user explictly picks the default   /* handle the two cases where the user explictly picks the default
2532   * boot entry index as it would exist post-modification */   * boot entry index as it would exist post-modification */
2533    
# Line 2590  void setDefaultImage(struct grubConfig * Line 2593  void setDefaultImage(struct grubConfig *
2593   config->defaultImage++;   config->defaultImage++;
2594   }   }
2595   } else {   } else {
2596   /* use pre-existing default entry */                  /* check to see if the default is stored in the environment */
2597   currentLookupIndex = config->defaultImage;                  if (config->defaultImage < FIRST_ENTRY_INDEX) {
2598                        if (config->defaultImage == DEFAULT_SAVED || config->defaultImage == DEFAULT_SAVED_GRUB2)
2599                        {
2600                            if (config->cfi->defaultIsSaved) {
2601                                if (config->cfi->getEnv) {
2602                                    char *defaultTitle = config->cfi->getEnv(config->cfi, "saved_entry");
2603    
2604                                    if (defaultTitle) {
2605                                        if (isnumber(defaultTitle)) {
2606                                            currentLookupIndex = atoi(defaultTitle);
2607                                        } else {
2608                                            findEntryByTitle(config, defaultTitle, &currentLookupIndex);
2609                                        }
2610                                        /* set the default Image to an actual index */
2611                                        config->defaultImage = currentLookupIndex;
2612                                    }
2613                                }
2614                             }
2615                        }
2616                    } else {
2617                            /* use pre-existing default entry from the file*/
2618                            currentLookupIndex = config->defaultImage;
2619                    }
2620    
2621   if (isAddingBootEntry   if (isAddingBootEntry
2622      && (newBootEntryIndex <= config->defaultImage)) {      && (newBootEntryIndex <= config->defaultImage)) {
# Line 2662  void setFallbackImage(struct grubConfig Line 2687  void setFallbackImage(struct grubConfig
2687   }   }
2688  }  }
2689    
2690  void displayEntry(struct singleEntry *entry, const char *prefix, int index)  void displayEntry(struct grubConfig *config, struct singleEntry *entry, const char *prefix, int index)
2691  {  {
2692   struct singleLine *line;   struct singleLine *line;
2693   char *root = NULL;   char *root = NULL;
# Line 2758  void displayEntry(struct singleEntry *en Line 2783  void displayEntry(struct singleEntry *en
2783    
2784   line = getLineByType(LT_TITLE, entry->lines);   line = getLineByType(LT_TITLE, entry->lines);
2785   if (line) {   if (line) {
2786   printf("title=%s\n", line->elements[1].item);                  char *entryTitle;
2787                    /* if we can extractTitle, then it's a zipl config and
2788                     * if not then we go ahead with what's existed prior */
2789                    entryTitle = extractTitle(config, line);
2790                    if (!entryTitle) {
2791                        entryTitle=line->elements[1].item;
2792                    }
2793     printf("title=%s\n", entryTitle);
2794   } else {   } else {
2795   char *title;   char *title;
2796   line = getLineByType(LT_MENUENTRY, entry->lines);   line = getLineByType(LT_MENUENTRY, entry->lines);
# Line 3174  int displayInfo(struct grubConfig *confi Line 3206  int displayInfo(struct grubConfig *confi
3206   printf("lba\n");   printf("lba\n");
3207   }   }
3208    
3209   displayEntry(entry, prefix, i);   displayEntry(config, entry, prefix, i);
3210    
3211   i++;   i++;
3212   while ((entry = findEntryByPath(config, kernel, prefix, &i))) {   while ((entry = findEntryByPath(config, kernel, prefix, &i))) {
3213   displayEntry(entry, prefix, i);   displayEntry(config, entry, prefix, i);
3214   i++;   i++;
3215   }   }
3216    

Legend:
Removed from v.3026  
changed lines
  Added in v.3029