Support RomFS label

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-12-15 22:00:18 +01:00
parent 20af857581
commit 4493254156

View file

@ -399,6 +399,40 @@ grub_romfs_close (grub_file_t file)
return GRUB_ERR_NONE; 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 = static struct grub_fs grub_romfs_fs =
{ {
.name = "romfs", .name = "romfs",
@ -406,6 +440,7 @@ static struct grub_fs grub_romfs_fs =
.open = grub_romfs_open, .open = grub_romfs_open,
.read = grub_romfs_read, .read = grub_romfs_read,
.close = grub_romfs_close, .close = grub_romfs_close,
.label = grub_romfs_label,
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
.reserved_first_sector = 0, .reserved_first_sector = 0,
#endif #endif