1From 76c465e87312dbc6cffd05427f1f4d2ebdee4f13 Mon Sep 17 00:00:00 2001 2From: Robert Yang <liezhi.yang@windriver.com> 3Date: Fri, 2 Jan 2015 12:28:35 +0800 4Subject: [PATCH 9/9] linux/syslinux: implement install_bootblock() 5 6Refer to the install_bootblock() in extlinux/main.c to make 7linux/syslinux.c's install_bootblock() which only supports ext2/3/4. 8 9Upstream-Status: Submitted 10 11Signed-off-by: Robert Yang <liezhi.yang@windriver.com> 12Tested-by: Du Dolpher <dolpher.du@intel.com> 13--- 14 linux/syslinux.c | 20 ++++++++++++++++++++ 15 1 file changed, 20 insertions(+) 16 17diff --git a/linux/syslinux.c b/linux/syslinux.c 18index c741750..917f83a 100755 19--- a/linux/syslinux.c 20+++ b/linux/syslinux.c 21@@ -419,6 +419,26 @@ static int ext_file_write(ext2_file_t e2_file, const void *buf, size_t count, 22 */ 23 int install_bootblock(int fd, const char *device) 24 { 25+ struct ext2_super_block sb; 26+ 27+ if (xpread(fd, &sb, sizeof sb, EXT2_SUPER_OFFSET + opt.offset) != sizeof sb) { 28+ perror("reading superblock"); 29+ return 1; 30+ } 31+ 32+ if (sb.s_magic != EXT2_SUPER_MAGIC) { 33+ fprintf(stderr, 34+ "no ext2/3/4 superblock found on %s\n", device); 35+ return 1; 36+ } 37+ 38+ if (xpwrite(fd, syslinux_bootsect, syslinux_bootsect_len, 0) 39+ != (signed)syslinux_bootsect_len) { 40+ perror("writing bootblock"); 41+ return 1; 42+ } 43+ 44+ return 0; 45 } 46 47 /* The file's block count */ 48-- 491.9.1 50 51