summaryrefslogtreecommitdiff
path: root/linux
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 /linux
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 'linux')
-rw-r--r--linux/syslinux.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/linux/syslinux.c b/linux/syslinux.c
index 37a54fd0..e1b464ec 100644
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -48,10 +48,12 @@
#include <sys/ioctl.h>
#include <linux/fs.h> /* FIGETBSZ, FIBMAP */
-#include <linux/msdos_fs.h> /* FAT_IOCTL_SET_ATTRIBUTES, SECTOR_* */
+#include <linux/msdos_fs.h> /* FAT_IOCTL_SET_ATTRIBUTES */
#ifndef FAT_IOCTL_SET_ATTRIBUTES
# define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, uint32_t)
#endif
+#undef SECTOR_SIZE
+#undef SECTOR_BITS
#include <paths.h>
#ifndef _PATH_MOUNT
@@ -325,10 +327,13 @@ int main(int argc, char *argv[])
char mntname[128];
char *ldlinux_name, **argp, *opt;
const char *subdir = NULL;
- uint32_t sectors[65]; /* 65 is maximum possible */
+ uint32_t *sectors;
+ int ldlinux_sectors;
int nsectors = 0;
const char *errmsg;
int mnt_cookie;
+ int patch_sectors;
+ int i;
int force = 0; /* -f (force) option */
int stupid = 0; /* -s (stupid) option */
@@ -514,6 +519,8 @@ int main(int argc, char *argv[])
/*
* Create a block map.
*/
+ ldlinux_sectors = (syslinux_ldlinux_len+SECTOR_SIZE-1) >> SECTOR_BITS;
+ sectors = calloc(ldlinux_sectors, sizeof *sectors);
nsectors = make_block_map(sectors, syslinux_ldlinux_len, dev_fd, fd);
close(fd);
@@ -530,13 +537,16 @@ umount:
/*
* 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 + SECTOR_SIZE - 1) >> SECTOR_BITS;
/*
- * Write the now-patched first sector of ldlinux.sys
+ * Write the now-patched first sectors of ldlinux.sys
*/
- xpwrite(dev_fd, syslinux_ldlinux, SECTOR_SIZE,
- filesystem_offset+((off_t)sectors[0] << SECTOR_BITS));
+ for (i = 0; i < patch_sectors; i++) {
+ xpwrite(dev_fd, syslinux_ldlinux + i*SECTOR_SIZE, SECTOR_SIZE,
+ filesystem_offset+((off_t)sectors[i] << SECTOR_BITS));
+ }
/*
* To finish up, write the boot sector