fixisohybrid.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. --- syslinux-5.00-orig/utils/isohybrid.pl 2012-12-06 21:51:22.000000000 +0200
  2. +++ syslinux-5.00/utils/isohybrid.pl 2013-02-07 18:55:28.423760149 +0200
  3. @@ -44,6 +44,7 @@
  4. 'id' => [0, 0xffffffff],
  5. 'hd0' => [0, 2],
  6. 'partok' => [0, 1],
  7. + 'fat' => [0, 1],
  8. );
  9. # Boolean options just set other options
  10. @@ -53,6 +54,7 @@
  11. 'ctrlhd0' => ['hd0', 2],
  12. 'nopartok' => ['partok', 0],
  13. 'partok' => ['partok', 1],
  14. + 'fatfirst' => ['fat', 1],
  15. );
  16. sub usage() {
  17. @@ -66,7 +68,8 @@
  18. " -id Specify MBR ID (default random)\n",
  19. " -forcehd0 Always assume we are loaded as disk ID 0\n",
  20. " -ctrlhd0 Assume disk ID 0 if the Ctrl key is pressed\n",
  21. - " -partok Allow booting from within a partition\n";
  22. + " -partok Allow booting from within a partition\n",
  23. + " -fatfirst Create a small fat partition first\n";
  24. exit 1;
  25. }
  26. @@ -221,9 +224,9 @@
  27. # Print partition table
  28. $offset = $opt{'offset'};
  29. -$psize = $c*$h*$s - $offset;
  30. +$psize = $c*$h*$s - $offset - 1;
  31. $bhead = int($offset/$s) % $h;
  32. -$bsect = ($offset % $s) + 1;
  33. +$bsect = ($offset % $s) + 1 + 1;
  34. $bcyl = int($offset/($h*$s));
  35. $bsect += ($bcyl & 0x300) >> 2;
  36. $bcyl &= 0xff;
  37. @@ -233,10 +236,29 @@
  38. $fstype = $opt{'type'}; # Partition type
  39. $pentry = $opt{'entry'}; # Partition slot
  40. +$offset += $psize;
  41. +$psize1 = $cylsize/512;
  42. +$bhead1 = int(($offset+1)/$s) % $h;
  43. +$bsect1 = (($offset+1) % $s) + 1;
  44. +$bcyl1 = int(($offset+1)/($h*$s));
  45. +$bsect1 += ($bcyl1 & 0x300) >> 2;
  46. +$bcyl1 &= 0xff;
  47. +$ehead1 = $h-1;
  48. +$esect1 = $s;
  49. +$ecyl1 = $bcyl1;
  50. +print "ehead1=$ehead1 esect1=$esect1 ecyl1=$ecyl1\n";
  51. +
  52. +if ( $opt{'fat'} == 1 ) {
  53. + $pentry = 2;
  54. +}
  55. +
  56. for ( $i = 1 ; $i <= 4 ; $i++ ) {
  57. - if ( $i == $pentry ) {
  58. + if ( $opt{'fat'} == 1 && $i == 1 ) {
  59. + $mbr .= pack("CCCCCCCCVV", 0x00, $bhead1, $bsect1, $bcyl1, 0xc,
  60. + $ehead1, $esect1, $ecyl1, $offset+1, $psize1);
  61. + } elsif ( $i == $pentry ) {
  62. $mbr .= pack("CCCCCCCCVV", 0x80, $bhead, $bsect, $bcyl, $fstype,
  63. - $ehead, $esect, $ecyl, $offset, $psize);
  64. + $ehead, $esect, $ecyl, $offset + 1, $psize);
  65. } else {
  66. $mbr .= "\0" x 16;
  67. }
  68. @@ -251,6 +273,18 @@
  69. print FILE "\0" x $padding;
  70. }
  71. +# Create fat image and put it into the file
  72. +if($opt{'fat'}) {
  73. + open(FATFILE, "> $file.fat") or die "$0: cannot open $file.fat: $!\n";
  74. + print FATFILE "\0" x ($psize1*512);
  75. + close(FATFILE);
  76. + system("/usr/sbin/mkfs.vfat -n RESIZE_ME $file.fat") and die "$0: cannot format fat\n";
  77. + open(FATFILE, "< $file.fat");
  78. + print FILE <FATFILE>;
  79. + close(FATFILE);
  80. + unlink("$file.fat");
  81. +}
  82. +
  83. # Done...
  84. close(FILE);
  85. --- syslinux-5.00-orig/utils/isohybrid.in 2012-12-06 21:51:22.000000000 +0200
  86. +++ syslinux-5.00/utils/isohybrid.in 2013-02-07 18:55:28.423760149 +0200
  87. @@ -44,6 +44,7 @@
  88. 'id' => [0, 0xffffffff],
  89. 'hd0' => [0, 2],
  90. 'partok' => [0, 1],
  91. + 'fat' => [0, 1],
  92. );
  93. # Boolean options just set other options
  94. @@ -53,6 +54,7 @@
  95. 'ctrlhd0' => ['hd0', 2],
  96. 'nopartok' => ['partok', 0],
  97. 'partok' => ['partok', 1],
  98. + 'fatfirst' => ['fat', 1],
  99. );
  100. sub usage() {
  101. @@ -66,7 +68,8 @@
  102. " -id Specify MBR ID (default random)\n",
  103. " -forcehd0 Always assume we are loaded as disk ID 0\n",
  104. " -ctrlhd0 Assume disk ID 0 if the Ctrl key is pressed\n",
  105. - " -partok Allow booting from within a partition\n";
  106. + " -partok Allow booting from within a partition\n",
  107. + " -fatfirst Create a small fat partition first\n";
  108. exit 1;
  109. }
  110. @@ -221,9 +224,9 @@
  111. # Print partition table
  112. $offset = $opt{'offset'};
  113. -$psize = $c*$h*$s - $offset;
  114. +$psize = $c*$h*$s - $offset - 1;
  115. $bhead = int($offset/$s) % $h;
  116. -$bsect = ($offset % $s) + 1;
  117. +$bsect = ($offset % $s) + 1 + 1;
  118. $bcyl = int($offset/($h*$s));
  119. $bsect += ($bcyl & 0x300) >> 2;
  120. $bcyl &= 0xff;
  121. @@ -233,10 +236,29 @@
  122. $fstype = $opt{'type'}; # Partition type
  123. $pentry = $opt{'entry'}; # Partition slot
  124. +$offset += $psize;
  125. +$psize1 = $cylsize/512;
  126. +$bhead1 = int(($offset+1)/$s) % $h;
  127. +$bsect1 = (($offset+1) % $s) + 1;
  128. +$bcyl1 = int(($offset+1)/($h*$s));
  129. +$bsect1 += ($bcyl1 & 0x300) >> 2;
  130. +$bcyl1 &= 0xff;
  131. +$ehead1 = $h-1;
  132. +$esect1 = $s;
  133. +$ecyl1 = $bcyl1;
  134. +print "ehead1=$ehead1 esect1=$esect1 ecyl1=$ecyl1\n";
  135. +
  136. +if ( $opt{'fat'} == 1 ) {
  137. + $pentry = 2;
  138. +}
  139. +
  140. for ( $i = 1 ; $i <= 4 ; $i++ ) {
  141. - if ( $i == $pentry ) {
  142. + if ( $opt{'fat'} == 1 && $i == 1 ) {
  143. + $mbr .= pack("CCCCCCCCVV", 0x00, $bhead1, $bsect1, $bcyl1, 0xc,
  144. + $ehead1, $esect1, $ecyl1, $offset+1, $psize1);
  145. + } elsif ( $i == $pentry ) {
  146. $mbr .= pack("CCCCCCCCVV", 0x80, $bhead, $bsect, $bcyl, $fstype,
  147. - $ehead, $esect, $ecyl, $offset, $psize);
  148. + $ehead, $esect, $ecyl, $offset + 1, $psize);
  149. } else {
  150. $mbr .= "\0" x 16;
  151. }
  152. @@ -251,6 +273,18 @@
  153. print FILE "\0" x $padding;
  154. }
  155. +# Create fat image and put it into the file
  156. +if($opt{'fat'}) {
  157. + open(FATFILE, "> $file.fat") or die "$0: cannot open $file.fat: $!\n";
  158. + print FATFILE "\0" x ($psize1*512);
  159. + close(FATFILE);
  160. + system("/usr/sbin/mkfs.vfat -n RESIZE_ME $file.fat") and die "$0: cannot format fat\n";
  161. + open(FATFILE, "< $file.fat");
  162. + print FILE <FATFILE>;
  163. + close(FATFILE);
  164. + unlink("$file.fat");
  165. +}
  166. +
  167. # Done...
  168. close(FILE);