1 From a95b831e18dd123f859bc5e6c4cecdcc0184ee37 Mon Sep 17 00:00:00 2001
2 From: Robert Yang <liezhi.yang@windriver.com>
3 Date: Fri, 2 Jan 2015 12:18:02 +0800
4 Subject: [PATCH 7/9] linux/syslinux: implement ext_construct_sectmap_fs()
6 The ext_construct_sectmap_fs() constucts the sector according to the
9 Upstream-Status: Submitted
11 Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
12 Tested-by: Du Dolpher <dolpher.du@intel.com>
14 linux/syslinux.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
15 1 file changed, 50 insertions(+)
17 diff --git a/linux/syslinux.c b/linux/syslinux.c
18 index f0c97a8..c741750 100755
19 --- a/linux/syslinux.c
20 +++ b/linux/syslinux.c
21 @@ -421,10 +421,60 @@ int install_bootblock(int fd, const char *device)
25 +/* The file's block count */
27 +static int get_block_count(ext2_filsys fs EXT2FS_ATTR((unused)),
28 + blk64_t *blocknr EXT2FS_ATTR((unused)),
29 + e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
30 + blk64_t ref_block EXT2FS_ATTR((unused)),
31 + int ref_offset EXT2FS_ATTR((unused)),
32 + void *private EXT2FS_ATTR((unused)))
38 /* Construct the boot file map */
39 int ext_construct_sectmap_fs(ext2_filsys fs, ext2_ino_t newino,
40 sector_t *sectors, int nsect)
42 + blk64_t pblk, blksize, blk = 0;
47 + blksize = fs->blocksize;
48 + blksize >>= SECTOR_SHIFT;
50 + /* Get the total blocks no. */
51 + retval = ext2fs_block_iterate3(fs, newino, BLOCK_FLAG_READ_ONLY,
52 + NULL, get_block_count, NULL);
54 + fprintf(stderr, "%s: ERROR: ext2fs_block_iterate3() failed.\n", program);
59 + if (block_count-- == 0)
62 + /* Get the physical block no. (bmap) */
63 + retval = ext2fs_bmap2(fs, newino, 0, 0, 0, blk, 0, &pblk);
65 + fprintf(stderr, "%s: ERROR: ext2fs_bmap2() failed.\n", program);
70 + sec = (sector_t)pblk * blksize;
71 + for (i = 0; i < blksize; i++) {
81 static int handle_adv_on_ext(void)