Magellan Linux

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

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

revision 1696 by niro, Fri Feb 17 23:46:24 2012 UTC revision 1717 by niro, Sat Feb 18 00:47:17 2012 UTC
# Line 156  struct keywordTypes grubKeywords[] = { Line 156  struct keywordTypes grubKeywords[] = {
156      { NULL,    0, 0 },      { NULL,    0, 0 },
157  };  };
158    
159    const char *grubFindConfig(struct configFileInfo *cfi) {
160        static const char *configFiles[] = {
161     "/etc/grub.conf",
162     "/boot/grub/grub.conf",
163     "/boot/grub/menu.lst",
164     NULL
165        };
166        static int i = -1;
167    
168        if (i == -1) {
169     for (i = 0; configFiles[i] != NULL; i++) {
170        dbgPrintf("Checking \"%s\": ", configFiles[i]);
171        if (!access(configFiles[i], R_OK)) {
172     dbgPrintf("found\n");
173     return configFiles[i];
174        }
175        dbgPrintf("not found\n");
176     }
177        }
178        return configFiles[i];
179    }
180    
181  struct configFileInfo grubConfigType = {  struct configFileInfo grubConfigType = {
182      .defaultConfig = "/boot/grub/grub.conf",      .findConfig = grubFindConfig,
183      .keywords = grubKeywords,      .keywords = grubKeywords,
184      .defaultIsIndex = 1,      .defaultIsIndex = 1,
185      .defaultSupportSaved = 1,      .defaultSupportSaved = 1,
# Line 190  const char *grub2FindConfig(struct confi Line 212  const char *grub2FindConfig(struct confi
212   NULL   NULL
213      };      };
214      static int i = -1;      static int i = -1;
215        static const char *grub_cfg = "/boot/grub/grub.cfg";
216    
217      if (i == -1) {      if (i == -1) {
218   for (i = 0; configFiles[i] != NULL; i++) {   for (i = 0; configFiles[i] != NULL; i++) {
# Line 198  const char *grub2FindConfig(struct confi Line 221  const char *grub2FindConfig(struct confi
221   dbgPrintf("found\n");   dbgPrintf("found\n");
222   return configFiles[i];   return configFiles[i];
223      }      }
     dbgPrintf("not found\n");  
224   }   }
225      }      }
226    
227        /* Ubuntu renames grub2 to grub, so check for the grub.d directory
228         * that isn't in grub1, and if it exists, return the config file path
229         * that they use. */
230        if (configFiles[i] == NULL && !access("/etc/grub.d/", R_OK)) {
231     dbgPrintf("found\n");
232     return grub_cfg;
233        }
234    
235        dbgPrintf("not found\n");
236      return configFiles[i];      return configFiles[i];
237  }  }
238    
# Line 2584  int checkForLilo(struct grubConfig * con Line 2616  int checkForLilo(struct grubConfig * con
2616  }  }
2617    
2618  int checkForGrub2(struct grubConfig * config) {  int checkForGrub2(struct grubConfig * config) {
2619      if (!access("/boot/grub2", R_OK))      if (!access("/etc/grub.d/", R_OK))
2620   return 2;   return 2;
2621    
2622      return 1;      return 1;
# Line 3333  int main(int argc, const char ** argv) { Line 3365  int main(int argc, const char ** argv) {
3365   defaultKernel = NULL;   defaultKernel = NULL;
3366      }      }
3367    
3368      if (!strcmp(grubConfig, "-") && !outputFile) {      if (grubConfig && !strcmp(grubConfig, "-") && !outputFile) {
3369   fprintf(stderr, _("grubby: output file must be specified if stdin "   fprintf(stderr, _("grubby: output file must be specified if stdin "
3370   "is used\n"));   "is used\n"));
3371   return 1;   return 1;
# Line 3380  int main(int argc, const char ** argv) { Line 3412  int main(int argc, const char ** argv) {
3412   gr2c = checkForGrub2(gconfig);   gr2c = checkForGrub2(gconfig);
3413   }   }
3414    
3415   if (!access(grubConfigType.defaultConfig, F_OK)) {   const char *grubconfig = grubFindConfig(&grubConfigType);
3416      gconfig = readConfig(grubConfigType.defaultConfig, &grubConfigType);   if (!access(grubconfig, F_OK)) {
3417        gconfig = readConfig(grubconfig, &grubConfigType);
3418      if (!gconfig)      if (!gconfig)
3419   grc = 1;   grc = 1;
3420      else      else

Legend:
Removed from v.1696  
changed lines
  Added in v.1717