summaryrefslogtreecommitdiff
path: root/libinstaller/syslxmod.c
diff options
context:
space:
mode:
Diffstat (limited to 'libinstaller/syslxmod.c')
-rw-r--r--libinstaller/syslxmod.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/libinstaller/syslxmod.c b/libinstaller/syslxmod.c
index a68f19fb..c706f2c2 100644
--- a/libinstaller/syslxmod.c
+++ b/libinstaller/syslxmod.c
@@ -33,26 +33,29 @@
static void generate_extents(struct syslinux_extent *ex, int nptrs,
const sector_t *sectp, int nsect)
{
- uint32_t addr = 0x7c00 + 2*SECTOR_SIZE;
+ uint32_t addr = 0x8000; /* ldlinux.sys starts loading here */
uint32_t base;
sector_t sect, lba;
unsigned int len;
- len = lba = base = 0;
+ base = addr;
+ len = lba = 0;
memset(ex, 0, nptrs * sizeof *ex);
while (nsect) {
sect = *sectp++;
- if (len && sect == lba + len &&
- ((addr ^ (base + len * SECTOR_SIZE)) & 0xffff0000) == 0) {
- /* We can add to the current extent */
- len++;
- goto next;
- }
-
if (len) {
+ uint32_t xbytes = (len + 1) * SECTOR_SIZE;
+
+ if (sect == lba + len && xbytes < 65536 &&
+ ((addr ^ (base + xbytes - 1)) & 0xffff0000) == 0) {
+ /* We can add to the current extent */
+ len++;
+ goto next;
+ }
+
set_64_sl(&ex->lba, lba);
set_16_sl(&ex->len, len);
ex++;
@@ -93,8 +96,6 @@ static inline void *ptr(void *img, uint16_t *offset_p)
* Returns the number of modified bytes in ldlinux.sys if successful,
* otherwise -1.
*/
-#define NADV 2
-
int syslinux_patch(const sector_t *sectp, int nsectors,
int stupid, int raid_mode,
const char *subdir, const char *subvol)
@@ -106,7 +107,7 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
int nsect = ((boot_image_len + SECTOR_SIZE - 1) >> SECTOR_SHIFT) + 2;
uint32_t csum;
int i, dw, nptrs;
- struct boot_sector *sbs = (struct boot_sector *)boot_sector;
+ struct fat_boot_sector *sbs = (struct fat_boot_sector *)boot_sector;
uint64_t *advptrs;
if (nsectors < nsect)