---
grub-core/fs/android_bootimg.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/grub-core/fs/android_bootimg.c b/grub-core/fs/android_bootimg.c
index 793e0aa..13d77fd 100644
--- a/grub-core/fs/android_bootimg.c
+++ b/grub-core/fs/android_bootimg.c
@@ -67,11 +67,11 @@ typedef enum
bootimg_file_t;
static bootimg_file_t
-grub_android_bootimg_handle_path (const char * path)
+grub_android_bootimg_handle_path (const char *path)
{
if (!path || path[0] != '/')
return BAD_NAME;
- const char * path_iter;
+ const char *path_iter;
for (path_iter = path + 1; *path_iter; ++path_iter) {
if (*path_iter == '/')
continue;
@@ -97,7 +97,7 @@ grub_android_bootimg_handle_path (const char * path)
}
static grub_err_t
-grub_android_bootimg_hdr (grub_disk_t disk, struct boot_img_hdr * hd)
+grub_android_bootimg_hdr (grub_disk_t disk, struct boot_img_hdr *hd)
{
if (grub_disk_read (disk, 0, 0, sizeof *hd, hd))
goto fail;
@@ -116,7 +116,7 @@ fail:
}
static grub_err_t
-grub_android_bootimg_dir (grub_device_t device, const char * path,
+grub_android_bootimg_dir (grub_device_t device, const char *path,
grub_fs_dir_hook_t hook, void *hook_data)
{
struct boot_img_hdr hd;
@@ -175,7 +175,7 @@ grub_android_bootimg_open (grub_file_t file, const char
*name)
if (grub_android_bootimg_hdr (file->device->disk, &hd))
return grub_errno;
- grub_off_t * begin_offset;
+ grub_off_t *begin_offset;
bootimg_file_t fn = grub_android_bootimg_handle_path (name);
switch (fn)
@@ -209,8 +209,19 @@ grub_android_bootimg_open (grub_file_t file, const char
*name)
static grub_ssize_t
grub_android_bootimg_read (grub_file_t file, char *buf, grub_size_t len)
{
- grub_errno = GRUB_ERR_NOT_IMPLEMENTED_YET;
- return -1;
+ grub_size_t len_left = file->size - file->offset;
+ len = len > len_left ? len_left : len;
+ grub_off_t *begin_offset = file->data;
+ grub_off_t actual_offset = *begin_offset + file->offset;
+ file->device->disk->read_hook = file->read_hook;
+ file->device->disk->read_hook_data = file->read_hook_data;
+ grub_errno = grub_disk_read (file->device->disk, 0, actual_offset, len, buf);
+ file->device->disk->read_hook = 0;
+
+ if (grub_errno)
+ return -1;
+ else
+ return len;
}
static grub_err_t
--
2.7.0
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel