diff options
Diffstat (limited to 'meta/recipes-devtools/syslinux/syslinux/0003-linux-syslinux-implement-install_to_ext2.patch')
-rw-r--r-- | meta/recipes-devtools/syslinux/syslinux/0003-linux-syslinux-implement-install_to_ext2.patch | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/meta/recipes-devtools/syslinux/syslinux/0003-linux-syslinux-implement-install_to_ext2.patch b/meta/recipes-devtools/syslinux/syslinux/0003-linux-syslinux-implement-install_to_ext2.patch new file mode 100644 index 0000000000..84ba10526a --- /dev/null +++ b/meta/recipes-devtools/syslinux/syslinux/0003-linux-syslinux-implement-install_to_ext2.patch | |||
@@ -0,0 +1,116 @@ | |||
1 | From 64d856b243812907068776b204a003a3a8fa122a Mon Sep 17 00:00:00 2001 | ||
2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
3 | Date: Wed, 31 Dec 2014 16:17:42 +0800 | ||
4 | Subject: [PATCH 3/9] linux/syslinux: implement install_to_ext2() | ||
5 | |||
6 | * The handle_adv_on_ext() checks whether we only need update adv. | ||
7 | * The write_to_ext() installs files (ldlinux.sys or ldlinux.c32) to the | ||
8 | device. | ||
9 | * The install_bootblock() installs the boot block. | ||
10 | |||
11 | Upstream-Status: Submitted | ||
12 | |||
13 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
14 | Tested-by: Du Dolpher <dolpher.du@intel.com> | ||
15 | --- | ||
16 | linux/syslinux.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
17 | 1 file changed, 79 insertions(+) | ||
18 | |||
19 | diff --git a/linux/syslinux.c b/linux/syslinux.c | ||
20 | index cc4e7da..45f080d 100755 | ||
21 | --- a/linux/syslinux.c | ||
22 | +++ b/linux/syslinux.c | ||
23 | @@ -346,11 +346,90 @@ static int open_ext2_fs(const char *device, const char *subdir) | ||
24 | fail: | ||
25 | (void) ext2fs_close(e2fs); | ||
26 | return -1; | ||
27 | + | ||
28 | +} | ||
29 | + | ||
30 | +/* | ||
31 | + * Install the boot block on the specified device. | ||
32 | + * Must be run AFTER file installed. | ||
33 | + */ | ||
34 | +int install_bootblock(int fd, const char *device) | ||
35 | +{ | ||
36 | +} | ||
37 | + | ||
38 | +static int handle_adv_on_ext(void) | ||
39 | +{ | ||
40 | +} | ||
41 | + | ||
42 | +/* Write files, adv, boot sector */ | ||
43 | +static int write_to_ext(const char *filename, const char *str, int length, | ||
44 | + int i_flags, int dev_fd, const char *subdir) | ||
45 | +{ | ||
46 | } | ||
47 | |||
48 | /* The install func for ext2, ext3 and ext4 */ | ||
49 | static int install_to_ext2(const char *device, int dev_fd, const char *subdir) | ||
50 | { | ||
51 | + int retval; | ||
52 | + ext2_ino_t oldino; | ||
53 | + | ||
54 | + const char *file = "ldlinux.sys"; | ||
55 | + const char *oldfile = "extlinux.sys"; | ||
56 | + const char *c32file = "ldlinux.c32"; | ||
57 | + | ||
58 | + /* Handle the adv */ | ||
59 | + if (handle_adv_on_ext() < 0) { | ||
60 | + fprintf(stderr, "%s: error while handling ADV on %s\n", | ||
61 | + program, device); | ||
62 | + retval = 1; | ||
63 | + goto fail; | ||
64 | + } | ||
65 | + | ||
66 | + /* Return if only need update the adv */ | ||
67 | + if (opt.update_only == -1) { | ||
68 | + return ext2fs_close(e2fs); | ||
69 | + } | ||
70 | + | ||
71 | + /* Write ldlinux.sys, adv, boot sector */ | ||
72 | + retval = write_to_ext(file, (const char _force *)boot_image, | ||
73 | + boot_image_len, EXT2_IMMUTABLE_FL, dev_fd, subdir); | ||
74 | + if (retval) { | ||
75 | + fprintf(stderr, "%s: ERROR: while writing: %s.\n", | ||
76 | + program, file); | ||
77 | + goto fail; | ||
78 | + } | ||
79 | + | ||
80 | + /* Write ldlinux.c32 */ | ||
81 | + retval = write_to_ext(c32file, | ||
82 | + (const char _force *)syslinux_ldlinuxc32, | ||
83 | + syslinux_ldlinuxc32_len, 0, dev_fd, subdir); | ||
84 | + if (retval) { | ||
85 | + fprintf(stderr, "%s: ERROR: while writing: %s.\n", | ||
86 | + program, c32file); | ||
87 | + goto fail; | ||
88 | + } | ||
89 | + | ||
90 | + /* Look if we have the extlinux.sys and remove it*/ | ||
91 | + retval = ext2fs_namei(e2fs, root, cwd, oldfile, &oldino); | ||
92 | + if (retval == 0) { | ||
93 | + retval = ext2fs_unlink(e2fs, cwd, oldfile, oldino, 0); | ||
94 | + if (retval) { | ||
95 | + fprintf(stderr, "%s: ERROR: failed to unlink: %s\n", | ||
96 | + program, oldfile); | ||
97 | + goto fail; | ||
98 | + } | ||
99 | + } else { | ||
100 | + retval = 0; | ||
101 | + } | ||
102 | + | ||
103 | + sync(); | ||
104 | + retval = install_bootblock(dev_fd, device); | ||
105 | + close(dev_fd); | ||
106 | + sync(); | ||
107 | + | ||
108 | +fail: | ||
109 | + (void) ext2fs_close(e2fs); | ||
110 | + return retval; | ||
111 | } | ||
112 | |||
113 | int main(int argc, char *argv[]) | ||
114 | -- | ||
115 | 1.9.1 | ||
116 | |||