[syslinux:elflink] EXTLINUX: Add sanity check for XFS filesystems
syslinux-bot for Paulo Alcantara
pcacjr at zytor.com
Tue Nov 27 12:57:22 PST 2012
Commit-ID: 7997877811d9ce99efed65604bba2bae91332c79
Gitweb: http://www.syslinux.org/commit/7997877811d9ce99efed65604bba2bae91332c79
Author: Paulo Alcantara <pcacjr at zytor.com>
AuthorDate: Sat, 28 Jul 2012 19:41:55 -0300
Committer: Paulo Alcantara <pcacjr at zytor.com>
CommitDate: Sun, 29 Jul 2012 02:15:40 -0300
EXTLINUX: Add sanity check for XFS filesystems
Syslinux won't work on >4 KiB filesystem block sizes since there is no
left space in MBR to determine where to install Syslinux bootsector.
If one is trying to install Syslinux in a XFS partition with a
filesystem block size different of 4 KiB, a proper error will be
returned to the user informing that the current filesystem block size
isn't supported by Syslinux.
Reported-by: Gene Cumm <gene.cumm at gmail.com>
Signed-off-by: Paulo Alcantara <pcacjr at zytor.com>
---
extlinux/main.c | 20 +++++++++++++++++---
{core/fs/xfs => extlinux}/misc.h | 0
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/extlinux/main.c b/extlinux/main.c
index bbcc8db..d1a800c 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -14,7 +14,8 @@
/*
* extlinux.c
*
- * Install the syslinux boot block on an fat, ntfs, ext2/3/4 and btrfs filesystem
+ * Install the syslinux boot block on an fat, ntfs, ext2/3/4, btrfs and xfs
+ * filesystem.
*/
#define _GNU_SOURCE /* Enable everything */
@@ -49,6 +50,7 @@
#include "xfs.h"
#include "xfs_types.h"
#include "xfs_sb.h"
+#include "misc.h"
#include "../version.h"
#include "syslxint.h"
#include "syslxcom.h" /* common functions shared with extlinux and syslinux */
@@ -71,7 +73,8 @@
* we will use the first 0~512 bytes starting from 2048 for the Syslinux
* boot sector.
*/
-#define XFS_BOOTSECT_OFFSET 4 * SECTOR_SIZE
+#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 */
@@ -379,8 +382,19 @@ int install_bootblock(int fd, const char *device)
return 1;
}
- if (sb5.sb_magicnum == *(u32 *)XFS_SB_MAGIC)
+ if (sb5.sb_magicnum == *(u32 *)XFS_SB_MAGIC) {
+ if (be32_to_cpu(sb5.sb_blocksize) != XFS_SUPPORTED_BLOCKSIZE) {
+ fprintf(stderr,
+ "You need to have 4 KiB filesystem block size for "
+ " being able to install Syslinux in your XFS "
+ "partition (because there is no enough space in MBR to "
+ "determine where Syslinux bootsector can be installed "
+ "regardless the filesystem block size)\n");
+ return 1;
+ }
+
ok = true;
+ }
}
if (!ok) {
diff --git a/core/fs/xfs/misc.h b/extlinux/misc.h
similarity index 100%
copy from core/fs/xfs/misc.h
copy to extlinux/misc.h
More information about the Syslinux-commits
mailing list