]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Support ZFS embedding.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 12 Nov 2011 20:46:52 +0000 (21:46 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 12 Nov 2011 20:46:52 +0000 (21:46 +0100)
* grub-core/fs/zfs/zfs.c (grub_zfs_embed): New function.
(grub_zfs_fs): Register grub_zfs_embed.

ChangeLog
grub-core/fs/zfs/zfs.c

index 15389a335e398a8fe46be182bb795dc54335be7a..c12f19951685c0d65e1f06ca7beb635e005521df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-11-12  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Support ZFS embedding.
+
+       * grub-core/fs/zfs/zfs.c (grub_zfs_embed): New function.
+       (grub_zfs_fs): Register grub_zfs_embed.
+
 2011-11-12  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Fix MIPS compilation.
index 20cba35090301b61c7076bd92fa877ca9a3598ea..83a067237e2a1904ebdc487ca5b10ad013ca5ea8 100644 (file)
@@ -3806,6 +3806,35 @@ grub_zfs_dir (grub_device_t device, const char *path,
   return grub_errno;
 }
 
+#ifdef GRUB_UTIL
+static grub_err_t
+grub_zfs_embed (grub_device_t device __attribute__ ((unused)),
+               unsigned int *nsectors,
+               grub_embed_type_t embed_type,
+               grub_disk_addr_t **sectors)
+{
+  unsigned i;
+
+  if (embed_type != GRUB_EMBED_PCBIOS)
+    return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+                      "ZFS currently supports only PC-BIOS embedding");
+
+ if ((VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS) < *nsectors)
+    return grub_error (GRUB_ERR_OUT_OF_RANGE,
+                      "Your core.img is unusually large.  "
+                      "It won't fit in the embedding area.");
+
+  *nsectors = (VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS);
+  *sectors = grub_malloc (*nsectors * sizeof (**sectors));
+  if (!*sectors)
+    return grub_errno;
+  for (i = 0; i < *nsectors; i++)
+    (*sectors)[i] = i + (VDEV_BOOT_OFFSET >> GRUB_DISK_SECTOR_BITS);
+
+  return GRUB_ERR_NONE;
+}
+#endif
+
 static struct grub_fs grub_zfs_fs = {
   .name = "zfs",
   .dir = grub_zfs_dir,
@@ -3815,6 +3844,10 @@ static struct grub_fs grub_zfs_fs = {
   .label = zfs_label,
   .uuid = zfs_uuid,
   .mtime = zfs_mtime,
+#ifdef GRUB_UTIL
+  .embed = grub_zfs_embed,
+  .reserved_first_sector = 1,
+#endif
   .next = 0
 };