summaryrefslogtreecommitdiff
path: root/mtools
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-19 16:30:09 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-19 16:30:09 -0700
commit0fa4369624b4637a7e36ed22e89a759031f08327 (patch)
tree4aa1cf5c87d36153cee3c727d5f77498c0042983 /mtools
parentc9ad266f64f9ee81a859bdf70c1190ee0cc1bc19 (diff)
downloadsyslinux-0fa4369624b4637a7e36ed22e89a759031f08327.tar.gz
FAT: change DOS installer to EXE; additional 32K limit fixes
Additional fixes for the 32K limits in the installers. In the case of the DOS installer, that means changing it from COM format to EXE format (since COM format has a 63K hard limit); retain the name syslinux.com for user compatibility, though (DOS doesn't care what the extension except for pathname search; if it finds an MZ EXE header it will use it.) With the change to EXE means having to handle more than one segment. Since we don't have a real DOS compiler we have to wing it a bit. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'mtools')
-rw-r--r--mtools/syslinux.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/mtools/syslinux.c b/mtools/syslinux.c
index 46b33f4e..8ddf42ec 100644
--- a/mtools/syslinux.c
+++ b/mtools/syslinux.c
@@ -134,10 +134,13 @@ int main(int argc, char *argv[])
int mtc_fd;
FILE *mtc, *mtp;
struct libfat_filesystem *fs;
- libfat_sector_t s, *secp, sectors[65]; /* 65 is maximum possible */
+ libfat_sector_t s, *secp;
+ libfat_sector_t *sectors;
int32_t ldlinux_cluster;
int nsectors;
const char *errmsg;
+ int ldlinux_sectors, patch_sectors;
+ int i;
int force = 0; /* -f (force) option */
int stupid = 0; /* -s (stupid) option */
@@ -247,12 +250,14 @@ int main(int argc, char *argv[])
/*
* Now, use libfat to create a block map
*/
+ ldlinux_sectors = (syslinux_ldlinux_len+SECTOR_SIZE-1) >> SECTOR_BITS;
+ sectors = calloc(ldlinux_sectors, sizeof *sectors);
fs = libfat_open(libfat_xpread, dev_fd);
ldlinux_cluster = libfat_searchdir(fs, 0, "LDLINUX SYS", NULL);
secp = sectors;
nsectors = 0;
s = libfat_clustertosector(fs, ldlinux_cluster);
- while ( s && nsectors < 65 ) {
+ while ( s && nsectors < ldlinux_sectors ) {
*secp++ = s;
nsectors++;
s = libfat_nextsector(fs, s);
@@ -260,11 +265,14 @@ int main(int argc, char *argv[])
libfat_close(fs);
/* Patch ldlinux.sys and the boot sector */
- syslinux_patch(sectors, nsectors, stupid, raid_mode);
+ i = syslinux_patch(sectors, nsectors, stupid, raid_mode);
+ patch_sectors = (i + 511) >> 9;
- /* Write the now-patched first sector of ldlinux.sys */
- xpwrite(dev_fd, syslinux_ldlinux, 512,
- filesystem_offset + ((off_t)sectors[0] << 9));
+ /* Write the now-patched first sectors of ldlinux.sys */
+ for (i = 0; i < patch_sectors; i++) {
+ xpwrite(dev_fd, syslinux_ldlinux + i*512, 512,
+ filesystem_offset + ((off_t)sectors[i] << 9));
+ }
/* Move ldlinux.sys to the desired location */
if (subdir) {