Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aO8iG-0001HV-M7 for mharc-grub-devel@gnu.org; Tue, 26 Jan 2016 13:51:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO8iD-0001Ce-PN for grub-devel@gnu.org; Tue, 26 Jan 2016 13:51:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO8iC-0001qY-Sj for grub-devel@gnu.org; Tue, 26 Jan 2016 13:51:33 -0500 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:54582 helo=homiemail-a114.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO8iC-0001qH-O9 for grub-devel@gnu.org; Tue, 26 Jan 2016 13:51:32 -0500 Received: from homiemail-a114.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a114.g.dreamhost.com (Postfix) with ESMTP id 31CBE600CF22F; Tue, 26 Jan 2016 10:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=shealevy.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=shealevy.com; bh=pHWb98ceKlj6jfbDVo8t6ePfmXw=; b=N22zUMZlv+syakpH5NdQc9VDPCGy kHQkpux4NxXuAWDh+79lrI1e8tJTlK2/Z4j7IevPMeaPG9jcAg4f9o2pwpzB5MLK hQAQSx+UROam8nEsaGTCSzDiidDf6oYS4+MN8DsOcp7wxXzXTuRutLU8BqPt45bN SKePzgvWuFA3WbA= Received: from shlevy-laptop.hsd1.nh.comcast.net. (c-73-186-74-217.hsd1.nh.comcast.net [73.186.74.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: shea@shealevy.com) by homiemail-a114.g.dreamhost.com (Postfix) with ESMTPSA id BB64E600CF230; Tue, 26 Jan 2016 10:51:31 -0800 (PST) From: Shea Levy To: The development of GNU GRUB Subject: [PATCH 5/7] android_bootimg: Implement read Date: Tue, 26 Jan 2016 13:51:20 -0500 Message-Id: <1453834282-28691-6-git-send-email-shea@shealevy.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1453834282-28691-1-git-send-email-shea@shealevy.com> References: <1453834282-28691-1-git-send-email-shea@shealevy.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.113.200.129 Cc: Shea Levy X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2016 18:51:34 -0000 --- 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