summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/syslinux/syslinux/0004-linux-syslinux-add-ext_file_read-and-ext_file_write.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/syslinux/syslinux/0004-linux-syslinux-add-ext_file_read-and-ext_file_write.patch')
-rw-r--r--meta/recipes-devtools/syslinux/syslinux/0004-linux-syslinux-add-ext_file_read-and-ext_file_write.patch91
1 files changed, 91 insertions, 0 deletions
diff --git a/meta/recipes-devtools/syslinux/syslinux/0004-linux-syslinux-add-ext_file_read-and-ext_file_write.patch b/meta/recipes-devtools/syslinux/syslinux/0004-linux-syslinux-add-ext_file_read-and-ext_file_write.patch
new file mode 100644
index 0000000000..64b56d92e0
--- /dev/null
+++ b/meta/recipes-devtools/syslinux/syslinux/0004-linux-syslinux-add-ext_file_read-and-ext_file_write.patch
@@ -0,0 +1,91 @@
1From 35d3842cc4b930c5102eed2921e0189b7f4fd069 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Wed, 31 Dec 2014 16:43:37 +0800
4Subject: [PATCH 4/9] linux/syslinux: add ext_file_read() and ext_file_write()
5
6Will use them to read and write on the extX device.
7
8Upstream-Status: Submitted
9
10Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
11Tested-by: Du Dolpher <dolpher.du@intel.com>
12---
13 linux/syslinux.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 62 insertions(+)
15
16diff --git a/linux/syslinux.c b/linux/syslinux.c
17index 45f080d..247c86a 100755
18--- a/linux/syslinux.c
19+++ b/linux/syslinux.c
20@@ -349,6 +349,68 @@ fail:
21
22 }
23
24+/* Read from an ext2_file */
25+static int ext_file_read(ext2_file_t e2_file, void *buf, size_t count,
26+ off_t offset, const char *msg)
27+{
28+ int retval;
29+ char *ptr = (char *) buf;
30+ unsigned int got = 0;
31+ size_t done = 0;
32+
33+ /* Always lseek since e2_file is uncontrolled by this func */
34+ if (ext2fs_file_lseek(e2_file, offset, EXT2_SEEK_SET, NULL)) {
35+ fprintf(stderr, "%s: ext2fs_file_lseek() failed.\n",
36+ program);
37+ return -1;
38+ }
39+
40+ while (1) {
41+ retval = ext2fs_file_read(e2_file, ptr, count, &got);
42+ if (retval) {
43+ fprintf(stderr, "%s: error while reading %s\n",
44+ program, msg);
45+ return -1;
46+ }
47+ count -= got;
48+ ptr += got;
49+ done += got;
50+ if (got == 0 || count == 0)
51+ break;
52+ }
53+
54+ return done;
55+}
56+
57+/* Write to an ext2_file */
58+static int ext_file_write(ext2_file_t e2_file, const void *buf, size_t count,
59+ off_t offset)
60+{
61+ const char *ptr = (const char *) buf;
62+ unsigned int written = 0;
63+ size_t done = 0;
64+
65+ /* Always lseek since e2_file is uncontrolled by this func */
66+ if (ext2fs_file_lseek(e2_file, offset, EXT2_SEEK_SET, NULL)) {
67+ fprintf(stderr, "%s: ext2fs_file_lseek() failed.\n",
68+ program);
69+ return -1;
70+ }
71+
72+ while (count > 0) {
73+ if (ext2fs_file_write(e2_file, ptr, count, &written)) {
74+ fprintf(stderr, "%s: failed to write syslinux adv.\n",
75+ program);
76+ return -1;
77+ }
78+ count -= written;
79+ ptr += written;
80+ done += written;
81+ }
82+
83+ return done;
84+}
85+
86 /*
87 * Install the boot block on the specified device.
88 * Must be run AFTER file installed.
89--
901.9.1
91