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 3031 by niro, Tue Jun 27 14:48:09 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 2535  void setDefaultImage(struct grubConfig * Line 2538  void setDefaultImage(struct grubConfig *
2538   }   }
2539    
2540   /* Case 2: user picked an arbitrary index as the default boot entry */   /* Case 2: user picked an arbitrary index as the default boot entry */
2541   if (newDefaultBootEntryIndex >= FIRST_ENTRY_INDEX   if (newDefaultBootEntryIndex >= FIRST_ENTRY_INDEX) {
     && config->cfi->defaultIsIndex) {  
2542   indexToVerify = newDefaultBootEntryIndex;   indexToVerify = newDefaultBootEntryIndex;
2543    
2544   /* user chose to make latest boot entry the default */   /* user chose to make latest boot entry the default */
# Line 2590  void setDefaultImage(struct grubConfig * Line 2592  void setDefaultImage(struct grubConfig *
2592   config->defaultImage++;   config->defaultImage++;
2593   }   }
2594   } else {   } else {
2595   /* use pre-existing default entry */                  /* check to see if the default is stored in the environment */
2596   currentLookupIndex = config->defaultImage;                  if (config->defaultImage < FIRST_ENTRY_INDEX) {
2597                        if (config->defaultImage == DEFAULT_SAVED || config->defaultImage == DEFAULT_SAVED_GRUB2)
2598                        {
2599                            if (config->cfi->defaultIsSaved) {
2600                                if (config->cfi->getEnv) {
2601                                    char *defaultTitle = config->cfi->getEnv(config->cfi, "saved_entry");
2602    
2603                                    if (defaultTitle) {
2604                                        if (isnumber(defaultTitle)) {
2605                                            currentLookupIndex = atoi(defaultTitle);
2606                                        } else {
2607                                            findEntryByTitle(config, defaultTitle, &currentLookupIndex);
2608                                        }
2609                                        /* set the default Image to an actual index */
2610                                        config->defaultImage = currentLookupIndex;
2611                                    }
2612                                }
2613                             }
2614                        }
2615                    } else {
2616                            /* use pre-existing default entry from the file*/
2617                            currentLookupIndex = config->defaultImage;
2618                    }
2619    
2620   if (isAddingBootEntry   if (isAddingBootEntry
2621      && (newBootEntryIndex <= config->defaultImage)) {      && (newBootEntryIndex <= config->defaultImage)) {
# Line 2662  void setFallbackImage(struct grubConfig Line 2686  void setFallbackImage(struct grubConfig
2686   }   }
2687  }  }
2688    
2689  void displayEntry(struct singleEntry *entry, const char *prefix, int index)  void displayEntry(struct grubConfig *config, struct singleEntry *entry, const char *prefix, int index)
2690  {  {
2691   struct singleLine *line;   struct singleLine *line;
2692   char *root = NULL;   char *root = NULL;
# Line 2758  void displayEntry(struct singleEntry *en Line 2782  void displayEntry(struct singleEntry *en
2782    
2783   line = getLineByType(LT_TITLE, entry->lines);   line = getLineByType(LT_TITLE, entry->lines);
2784   if (line) {   if (line) {
2785   printf("title=%s\n", line->elements[1].item);                  char *entryTitle;
2786                    /* if we can extractTitle, then it's a zipl config and
2787                     * if not then we go ahead with what's existed prior */
2788                    entryTitle = extractTitle(config, line);
2789                    if (!entryTitle) {
2790                        entryTitle=line->elements[1].item;
2791                    }
2792     printf("title=%s\n", entryTitle);
2793   } else {   } else {
2794   char *title;   char *title;
2795   line = getLineByType(LT_MENUENTRY, entry->lines);   line = getLineByType(LT_MENUENTRY, entry->lines);
# Line 3174  int displayInfo(struct grubConfig *confi Line 3205  int displayInfo(struct grubConfig *confi
3205   printf("lba\n");   printf("lba\n");
3206   }   }
3207    
3208   displayEntry(entry, prefix, i);   displayEntry(config, entry, prefix, i);
3209    
3210   i++;   i++;
3211   while ((entry = findEntryByPath(config, kernel, prefix, &i))) {   while ((entry = findEntryByPath(config, kernel, prefix, &i))) {
3212   displayEntry(entry, prefix, i);   displayEntry(config, entry, prefix, i);
3213   i++;   i++;
3214   }   }
3215    

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