Magellan Linux

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

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

revision 1852 by niro, Mon Jul 2 13:11:38 2012 UTC revision 1855 by niro, Mon Jul 2 13:13:03 2012 UTC
# Line 3246  int checkForExtLinux(struct grubConfig * Line 3246  int checkForExtLinux(struct grubConfig *
3246      return checkDeviceBootloader(boot, bootSect);      return checkDeviceBootloader(boot, bootSect);
3247  }  }
3248    
3249    int checkForYaboot(struct grubConfig * config) {
3250        /*
3251         * This is a simplistic check that we consider good enough for own puporses
3252         *
3253         * If we were to properly check if yaboot is *installed* we'd need to:
3254         * 1) get the system boot device (LT_BOOT)
3255         * 2) considering it's a raw filesystem, check if the yaboot binary matches
3256         *    the content on the boot device
3257         * 3) if not, copy the binary to a temporary file and run "addnote" on it
3258         * 4) check again if binary and boot device contents match
3259         */
3260        if (!access("/etc/yaboot.conf", R_OK))
3261     return 2;
3262    
3263        return 1;
3264    }
3265    
3266    int checkForElilo(struct grubConfig * config) {
3267        if (!access("/etc/elilo.conf", R_OK))
3268     return 2;
3269    
3270        return 1;
3271    }
3272    
3273  static char * getRootSpecifier(char * str) {  static char * getRootSpecifier(char * str) {
3274      char * idx, * rootspec = NULL;      char * idx, * rootspec = NULL;
3275    
# Line 3733  int main(int argc, const char ** argv) { Line 3757  int main(int argc, const char ** argv) {
3757   { "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0,   { "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0,
3758      _("filestystem which contains /boot directory (for testing only)"),      _("filestystem which contains /boot directory (for testing only)"),
3759      _("bootfs") },      _("bootfs") },
3760  #if defined(__i386__) || defined(__x86_64__)  #if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__) || defined (__ia64__)
3761   { "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0,   { "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0,
3762      _("check if lilo is installed on lilo.conf boot sector") },      _("check which bootloader is installed on boot sector") },
3763  #endif  #endif
3764   { "config-file", 'c', POPT_ARG_STRING, &grubConfig, 0,   { "config-file", 'c', POPT_ARG_STRING, &grubConfig, 0,
3765      _("path to grub config file to update (\"-\" for stdin)"),      _("path to grub config file to update (\"-\" for stdin)"),
# Line 3975  int main(int argc, const char ** argv) { Line 3999  int main(int argc, const char ** argv) {
3999      }      }
4000    
4001      if (bootloaderProbe) {      if (bootloaderProbe) {
4002   int lrc = 0, grc = 0, gr2c = 0, erc = 0;   int lrc = 0, grc = 0, gr2c = 0, extrc = 0, yrc = 0, erc = 0;
4003   struct grubConfig * lconfig, * gconfig;   struct grubConfig * lconfig, * gconfig, * yconfig, * econfig;
4004    
4005   const char *grub2config = grub2FindConfig(&grub2ConfigType);   const char *grub2config = grub2FindConfig(&grub2ConfigType);
4006   if (grub2config) {   if (grub2config) {
# Line 4004  int main(int argc, const char ** argv) { Line 4028  int main(int argc, const char ** argv) {
4028   lrc = checkForLilo(lconfig);   lrc = checkForLilo(lconfig);
4029   }   }
4030    
4031     if (!access(eliloConfigType.defaultConfig, F_OK)) {
4032        econfig = readConfig(eliloConfigType.defaultConfig,
4033     &eliloConfigType);
4034        if (!econfig)
4035     erc = 1;
4036        else
4037     erc = checkForElilo(econfig);
4038     }
4039    
4040   if (!access(extlinuxConfigType.defaultConfig, F_OK)) {   if (!access(extlinuxConfigType.defaultConfig, F_OK)) {
4041      lconfig = readConfig(extlinuxConfigType.defaultConfig, &extlinuxConfigType);      lconfig = readConfig(extlinuxConfigType.defaultConfig, &extlinuxConfigType);
4042      if (!lconfig)      if (!lconfig)
4043   erc = 1;   extrc = 1;
4044      else      else
4045   erc = checkForExtLinux(lconfig);   extrc = checkForExtLinux(lconfig);
4046   }   }
4047    
4048   if (lrc == 1 || grc == 1 || gr2c == 1) return 1;  
4049     if (!access(yabootConfigType.defaultConfig, F_OK)) {
4050        yconfig = readConfig(yabootConfigType.defaultConfig,
4051     &yabootConfigType);
4052        if (!yconfig)
4053     yrc = 1;
4054        else
4055     yrc = checkForYaboot(lconfig);
4056     }
4057    
4058     if (lrc == 1 || grc == 1 || gr2c == 1 || extrc == 1 || yrc == 1 ||
4059     erc == 1)
4060        return 1;
4061    
4062   if (lrc == 2) printf("lilo\n");   if (lrc == 2) printf("lilo\n");
4063   if (gr2c == 2) printf("grub2\n");   if (gr2c == 2) printf("grub2\n");
4064   if (grc == 2) printf("grub\n");   if (grc == 2) printf("grub\n");
4065   if (erc == 2) printf("extlinux\n");   if (extrc == 2) printf("extlinux\n");
4066     if (yrc == 2) printf("yaboot\n");
4067     if (erc == 2) printf("elilo\n");
4068    
4069   return 0;   return 0;
4070      }      }

Legend:
Removed from v.1852  
changed lines
  Added in v.1855