diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-06-25 19:49:20 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-06-25 19:49:20 -0700 |
commit | d160380affab95c1375f3981663b97b5d037708e (patch) | |
tree | 0d8c6446ffe72cff315f3747aa47a4545ca9eecd /extlinux/main.c | |
parent | 439da41ccf70f88b8fefb1950808e7dbe1cb82d0 (diff) | |
download | syslinux-d160380affab95c1375f3981663b97b5d037708e.tar.gz |
extlinux: modify the layout for btrfs
Put the btrfs boot code right after the boot sector (they are really
one image anyway). Align the ADV with the end of the boot region, so
we can locate it for modification as necessary, and the offset don't
end up shifting with different boot image sizes.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'extlinux/main.c')
-rw-r--r-- | extlinux/main.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/extlinux/main.c b/extlinux/main.c index ad173516..884a0254 100644 --- a/extlinux/main.c +++ b/extlinux/main.c @@ -67,13 +67,14 @@ typedef uint64_t u64; #endif /* the btrfs partition first 64K blank area is used to store boot sector and - boot image, the boot sector is from 0~512, the boot image starts at 2K */ -#define BTRFS_EXTLINUX_OFFSET (2*1024) + boot image, the boot sector is from 0~512, the boot image starts after */ +#define BTRFS_BOOTSECT_AREA 65536 +#define BTRFS_EXTLINUX_OFFSET SECTOR_SIZE #define BTRFS_SUBVOL_OPT "subvol=" #define BTRFS_SUBVOL_MAX 256 /* By btrfs specification */ static char subvol[BTRFS_SUBVOL_MAX]; -#define BTRFS_ADV_OFFSET (BTRFS_EXTLINUX_OFFSET + boot_image_len) +#define BTRFS_ADV_OFFSET (BTRFS_BOOTSECT_AREA - 2 * ADV_SIZE) /* * Get the size of a block device @@ -265,9 +266,12 @@ int patch_file_and_bootblock(int fd, const char *dir, int devfd) } } else if (fs_type == BTRFS) { int i; + sector_t *sp = sectp; - for (i = 0; i < nsect; i++) - sectp[i] = BTRFS_EXTLINUX_OFFSET/SECTOR_SIZE + i; + for (i = 0; i < nsect - 2; i++) + *sp++ = BTRFS_EXTLINUX_OFFSET/SECTOR_SIZE + i; + for (i = 0; i < 2; i++) + *sp++ = BTRFS_ADV_OFFSET/SECTOR_SIZE + i; } /* Create the modified image in memory */ @@ -441,13 +445,13 @@ int btrfs_install_file(const char *path, int devfd, struct stat *rst) perror("writing bootblock"); return 1; } - printf("write boot_image to 0x%x\n", BTRFS_EXTLINUX_OFFSET); - if (xpwrite(devfd, syslinux_adv, 2 * ADV_SIZE, - BTRFS_EXTLINUX_OFFSET + boot_image_len) != 2 * ADV_SIZE) { + dprintf("write boot_image to 0x%x\n", BTRFS_EXTLINUX_OFFSET); + if (xpwrite(devfd, syslinux_adv, 2 * ADV_SIZE, BTRFS_ADV_OFFSET) + != 2 * ADV_SIZE) { perror("writing adv"); return 1; } - printf("write adv to 0x%x\n", BTRFS_EXTLINUX_OFFSET + boot_image_len); + dprintf("write adv to 0x%x\n", BTRFS_ADV_OFFSET); if (stat(path, rst)) { perror(path); return 1; |