]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Support RomFS label
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 15 Dec 2010 21:00:18 +0000 (22:00 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 15 Dec 2010 21:00:18 +0000 (22:00 +0100)
grub-core/fs/romfs.c

index 342bdd73397fd8c38aaa99795bd79523dbb1f330..07632e635d49dc916f9e69cf8433f34bd90ab225 100644 (file)
@@ -399,6 +399,40 @@ grub_romfs_close (grub_file_t file)
   return GRUB_ERR_NONE;
 }
 
+static grub_err_t
+grub_romfs_label (grub_device_t device, char **label)
+{
+  struct grub_romfs_data *data;
+  grub_err_t err;
+
+  *label = NULL;
+
+  data = grub_romfs_mount (device);
+  if (!data)
+    return grub_errno;
+  *label = grub_malloc (data->first_file + 1
+                       - sizeof (struct grub_romfs_superblock));
+  if (!*label)
+    {
+      grub_free (data);
+      return grub_errno;
+    }
+  err = grub_disk_read (device->disk, 0, sizeof (struct grub_romfs_superblock),
+                       data->first_file
+                       - sizeof (struct grub_romfs_superblock),
+                       *label);
+  if (err)
+    {
+      grub_free (data);
+      grub_free (*label);
+      *label = NULL;
+      return err;
+    }
+  (*label)[data->first_file - sizeof (struct grub_romfs_superblock)] = 0;
+  return GRUB_ERR_NONE;
+}
+
+
 static struct grub_fs grub_romfs_fs =
   {
     .name = "romfs",
@@ -406,6 +440,7 @@ static struct grub_fs grub_romfs_fs =
     .open = grub_romfs_open,
     .read = grub_romfs_read,
     .close = grub_romfs_close,
+    .label = grub_romfs_label,
 #ifdef GRUB_UTIL
     .reserved_first_sector = 0,
 #endif