Magellan Linux

Diff of /tags/grubby-8_40_20170706/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 1853 by niro, Mon Jul 2 13:12:07 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  static char * getRootSpecifier(char * str) {  static char * getRootSpecifier(char * str) {
3267      char * idx, * rootspec = NULL;      char * idx, * rootspec = NULL;
3268    
# Line 3733  int main(int argc, const char ** argv) { Line 3750  int main(int argc, const char ** argv) {
3750   { "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0,   { "boot-filesystem", 0, POPT_ARG_STRING, &bootPrefix, 0,
3751      _("filestystem which contains /boot directory (for testing only)"),      _("filestystem which contains /boot directory (for testing only)"),
3752      _("bootfs") },      _("bootfs") },
3753  #if defined(__i386__) || defined(__x86_64__)  #if defined(__i386__) || defined(__x86_64__) || defined (__powerpc64__)
3754   { "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0,   { "bootloader-probe", 0, POPT_ARG_NONE, &bootloaderProbe, 0,
3755      _("check if lilo is installed on lilo.conf boot sector") },      _("check which bootloader is installed on boot sector") },
3756  #endif  #endif
3757   { "config-file", 'c', POPT_ARG_STRING, &grubConfig, 0,   { "config-file", 'c', POPT_ARG_STRING, &grubConfig, 0,
3758      _("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 3992  int main(int argc, const char ** argv) {
3992      }      }
3993    
3994      if (bootloaderProbe) {      if (bootloaderProbe) {
3995   int lrc = 0, grc = 0, gr2c = 0, erc = 0;   int lrc = 0, grc = 0, gr2c = 0, erc = 0, yrc = 0;
3996   struct grubConfig * lconfig, * gconfig;   struct grubConfig * lconfig, * gconfig, * yconfig;
3997    
3998   const char *grub2config = grub2FindConfig(&grub2ConfigType);   const char *grub2config = grub2FindConfig(&grub2ConfigType);
3999   if (grub2config) {   if (grub2config) {
# Line 4012  int main(int argc, const char ** argv) { Line 4029  int main(int argc, const char ** argv) {
4029   erc = checkForExtLinux(lconfig);   erc = checkForExtLinux(lconfig);
4030   }   }
4031    
4032   if (lrc == 1 || grc == 1 || gr2c == 1) return 1;  
4033     if (!access(yabootConfigType.defaultConfig, F_OK)) {
4034        yconfig = readConfig(yabootConfigType.defaultConfig,
4035     &yabootConfigType);
4036        if (!yconfig)
4037     yrc = 1;
4038        else
4039          yrc = checkForYaboot(lconfig);
4040     }
4041    
4042     if (lrc == 1 || grc == 1 || gr2c == 1 || yrc == 1) return 1;
4043    
4044   if (lrc == 2) printf("lilo\n");   if (lrc == 2) printf("lilo\n");
4045   if (gr2c == 2) printf("grub2\n");   if (gr2c == 2) printf("grub2\n");
4046   if (grc == 2) printf("grub\n");   if (grc == 2) printf("grub\n");
4047   if (erc == 2) printf("extlinux\n");   if (erc == 2) printf("extlinux\n");
4048     if (yrc == 2) printf("yaboot\n");
4049    
4050   return 0;   return 0;
4051      }      }

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