[syslinux:master] btrfs: Move ldlinux.sys to Boot Area B

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Tue May 20 16:51:03 PDT 2014


Commit-ID:  37eef6403a44cd7de97ce997cf899c0824792ce4
Gitweb:     http://www.syslinux.org/commit/37eef6403a44cd7de97ce997cf899c0824792ce4
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Tue, 20 May 2014 16:47:59 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Tue, 20 May 2014 16:47:59 -0700

btrfs: Move ldlinux.sys to Boot Area B

ldlinux.sys is frequently too big to fit into Boot Area A (64K).  Per
a recent ruling by Chris Mason, we have a 768K Boot Area B at offset
256K, so use that to store ldlinux.sys.  In theory we could split it
up and make it slightly larger, however, ldlinux.sys is loaded below
the 640K mark so it has to be smaller than that size anyway.

Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>

---
 extlinux/btrfs.h |  6 ++++++
 extlinux/main.c  | 15 +++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/extlinux/btrfs.h b/extlinux/btrfs.h
index 4e2cb31..17a10be 100644
--- a/extlinux/btrfs.h
+++ b/extlinux/btrfs.h
@@ -13,6 +13,12 @@
 #define BTRFS_FSID_SIZE 16
 #define BTRFS_UUID_SIZE 16
 
+/* Fixed areas reserved for the boot loader */
+#define BTRFS_BOOT_AREA_A_OFFSET	0
+#define BTRFS_BOOT_AREA_A_SIZE		BTRFS_SUPER_INFO_OFFSET
+#define BTRFS_BOOT_AREA_B_OFFSET	(256 * 1024)
+#define BTRFS_BOOT_AREA_B_SIZE		((1024-256) * 1024)
+
 typedef __u64 u64;
 typedef __u32 u32;
 typedef __u16 u16;
diff --git a/extlinux/main.c b/extlinux/main.c
index 47c1e68..7271a76 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------- *
  *
  *   Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
- *   Copyright 2009-2012 Intel Corporation; author: H. Peter Anvin
+ *   Copyright 2009-2014 Intel Corporation; author: H. Peter Anvin
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -76,14 +76,17 @@
 #define XFS_BOOTSECT_OFFSET	(4 << SECTOR_SHIFT)
 #define XFS_SUPPORTED_BLOCKSIZE 4096 /* 4 KiB filesystem block size */
 
-/* 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 after */
-#define BTRFS_BOOTSECT_AREA	65536
-#define BTRFS_EXTLINUX_OFFSET	SECTOR_SIZE
+/*
+ * btrfs has two discontiguous areas reserved for the boot loader.
+ * Use the first one (Boot Area A) for the boot sector and the ADV,
+ * and the second one for "ldlinux.sys".
+ */
+#define BTRFS_EXTLINUX_OFFSET	BTRFS_BOOT_AREA_B_OFFSET
+#define BTRFS_EXTLINUX_SIZE	BTRFS_BOOT_AREA_B_SIZE
 #define BTRFS_SUBVOL_MAX 256	/* By btrfs specification */
 static char subvol[BTRFS_SUBVOL_MAX];
 
-#define BTRFS_ADV_OFFSET (BTRFS_BOOTSECT_AREA - 2 * ADV_SIZE)
+#define BTRFS_ADV_OFFSET (BOOT_AREA_A_OFFSET + BOOT_AREA_A_SIZE - 2*ADV_SIZE)
 
 /*
  * Get the size of a block device


More information about the Syslinux-commits mailing list