Magellan Linux

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

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

revision 1717 by niro, Sat Feb 18 00:47:17 2012 UTC revision 1718 by niro, Sat Feb 18 00:49:41 2012 UTC
# Line 51  Line 51 
51  #define MAX_EXTRA_INITRDS  16 /* code segment checked by --bootloader-probe */  #define MAX_EXTRA_INITRDS  16 /* code segment checked by --bootloader-probe */
52  #define CODE_SEG_SIZE  128 /* code segment checked by --bootloader-probe */  #define CODE_SEG_SIZE  128 /* code segment checked by --bootloader-probe */
53    
54    #define NOOP_OPCODE 0x90
55    #define JMP_SHORT_OPCODE 0xeb
56    
57  /* comments get lumped in with indention */  /* comments get lumped in with indention */
58  struct lineElement {  struct lineElement {
59      char * item;      char * item;
# Line 2468  int checkDeviceBootloader(const char * d Line 2471  int checkDeviceBootloader(const char * d
2471      if (memcmp(boot, bootSect, 3))      if (memcmp(boot, bootSect, 3))
2472   return 0;   return 0;
2473    
2474      if (boot[1] == 0xeb) {      if (boot[1] == JMP_SHORT_OPCODE) {
2475   offset = boot[2] + 2;   offset = boot[2] + 2;
2476      } else if (boot[1] == 0xe8 || boot[1] == 0xe9) {      } else if (boot[1] == 0xe8 || boot[1] == 0xe9) {
2477   offset = (boot[3] << 8) + boot[2] + 2;   offset = (boot[3] << 8) + boot[2] + 2;
2478      } else if (boot[0] == 0xeb) {      } else if (boot[0] == JMP_SHORT_OPCODE) {
2479   offset = boot[1] + 2;        offset = boot[1] + 2;
2480            /*
2481     * it looks like grub, when copying stage1 into the mbr, patches stage1
2482     * right after the JMP location, replacing other instructions such as
2483     * JMPs for NOOPs. So, relax the check a little bit by skipping those
2484     * different bytes.
2485     */
2486          if ((bootSect[offset + 1] == NOOP_OPCODE)
2487      && (bootSect[offset + 2] == NOOP_OPCODE)) {
2488     offset = offset + 3;
2489          }
2490      } else if (boot[0] == 0xe8 || boot[0] == 0xe9) {      } else if (boot[0] == 0xe8 || boot[0] == 0xe9) {
2491   offset = (boot[2] << 8) + boot[1] + 2;   offset = (boot[2] << 8) + boot[1] + 2;
2492      } else {      } else {

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