[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/7] android_bootimg: Implement dir
From: |
Shea Levy |
Subject: |
[PATCH 2/7] android_bootimg: Implement dir |
Date: |
Tue, 26 Jan 2016 13:51:17 -0500 |
---
grub-core/fs/android_bootimg.c | 43 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/grub-core/fs/android_bootimg.c b/grub-core/fs/android_bootimg.c
index f6b2283..de49303 100644
--- a/grub-core/fs/android_bootimg.c
+++ b/grub-core/fs/android_bootimg.c
@@ -60,7 +60,48 @@ static grub_err_t
grub_android_bootimg_dir (grub_device_t device, const char *path_in,
grub_fs_dir_hook_t hook, void *hook_data)
{
- return GRUB_ERR_NOT_IMPLEMENTED_YET;
+ struct boot_img_hdr hd;
+ if (grub_disk_read (device->disk, 0, 0, sizeof hd, &hd))
+ goto fail;
+
+ if (grub_memcmp (hd.magic, BOOT_MAGIC, BOOT_MAGIC_SIZE))
+ goto fail;
+
+ if (hd.unused[0] || hd.unused[1])
+ goto fail;
+
+ const struct grub_dirhook_info info = {
+ .dir = 0,
+ .mtimeset = 0,
+ .case_insensitive = 0,
+ .inodeset = 0,
+ .mtime = 0,
+ .inode = 0
+ };
+
+ if (!grub_strcmp(path_in, "/")) {
+ return GRUB_ERR_FILE_NOT_FOUND;
+ }
+
+ if (hook ("kernel", &info, hook_data)) {
+ return grub_errno;
+ }
+
+ if (hook ("info", &info, hook_data)) {
+ return grub_errno;
+ }
+
+ if (hd.ramdisk_size != 0) {
+ if (hook ("ramdisk", &info, hook_data)) {
+ return grub_errno;
+ }
+ }
+
+ return GRUB_ERR_NONE;
+
+fail:
+ return grub_error (GRUB_ERR_BAD_FS, "%s is not an android bootimg",
+ device->disk->name);
}
static grub_err_t
--
2.7.0
- [PATCH 0/7] Add driver for android bootimg filesystem, Shea Levy, 2016/01/26
- [PATCH 2/7] android_bootimg: Implement dir,
Shea Levy <=
- [PATCH 4/7] android_bootimg: Implement close, Shea Levy, 2016/01/26
- [PATCH 1/7] Add stub module for android bootimgs, Shea Levy, 2016/01/26
- [PATCH 5/7] android_bootimg: Implement read, Shea Levy, 2016/01/26
- [PATCH 6/7] android_bootimg: style fixes, Shea Levy, 2016/01/26
- [PATCH 3/7] android_bootimg: Implement open, Shea Levy, 2016/01/26
- [PATCH 7/7] Add android_bootimg to changelog, Shea Levy, 2016/01/26
- Re: [PATCH 0/7] Add driver for android bootimg filesystem, Vladimir 'phcoder' Serbinenko, 2016/01/26