mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-11 20:24:04 +00:00
Tag the FuFirmwareImage objects with the filename
For containers with multiple images it is sometimes very helpful to know what file they've been loaded from. This would also allow us to 'explode' the firmware container into seporate image files on disk.
This commit is contained in:
parent
9a1e8e44e0
commit
f17db477eb
@ -24,6 +24,7 @@ typedef struct {
|
||||
guint64 addr;
|
||||
guint64 idx;
|
||||
gchar *version;
|
||||
gchar *filename;
|
||||
} FuFirmwareImagePrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (FuFirmwareImage, fu_firmware_image, G_TYPE_OBJECT)
|
||||
@ -65,6 +66,42 @@ fu_firmware_image_set_version (FuFirmwareImage *self, const gchar *version)
|
||||
priv->version = g_strdup (version);
|
||||
}
|
||||
|
||||
/**
|
||||
* fu_firmware_image_get_filename:
|
||||
* @self: A #FuFirmwareImage
|
||||
*
|
||||
* Gets an optional filename that represents the image source or destination.
|
||||
*
|
||||
* Returns: a string, or %NULL
|
||||
*
|
||||
* Since: 1.5.0
|
||||
**/
|
||||
const gchar *
|
||||
fu_firmware_image_get_filename (FuFirmwareImage *self)
|
||||
{
|
||||
FuFirmwareImagePrivate *priv = GET_PRIVATE (self);
|
||||
g_return_val_if_fail (FU_IS_FIRMWARE_IMAGE (self), NULL);
|
||||
return priv->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* fu_firmware_image_set_filename:
|
||||
* @self: A #FuFirmwareImage
|
||||
* @filename: (nullable): A string filename, or %NULL
|
||||
*
|
||||
* Sets an optional filename that represents the image source or destination.
|
||||
*
|
||||
* Since: 1.5.0
|
||||
**/
|
||||
void
|
||||
fu_firmware_image_set_filename (FuFirmwareImage *self, const gchar *filename)
|
||||
{
|
||||
FuFirmwareImagePrivate *priv = GET_PRIVATE (self);
|
||||
g_return_if_fail (FU_IS_FIRMWARE_IMAGE (self));
|
||||
g_free (priv->filename);
|
||||
priv->filename = g_strdup (filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* fu_firmware_image_set_id:
|
||||
* @self: a #FuPlugin
|
||||
@ -333,6 +370,8 @@ fu_firmware_image_add_string (FuFirmwareImage *self, guint idt, GString *str)
|
||||
fu_common_string_append_kx (str, idt, "Address", priv->addr);
|
||||
if (priv->version != NULL)
|
||||
fu_common_string_append_kv (str, idt, "Version", priv->version);
|
||||
if (priv->filename != NULL)
|
||||
fu_common_string_append_kv (str, idt, "Filename", priv->filename);
|
||||
if (priv->bytes != NULL) {
|
||||
fu_common_string_append_kx (str, idt, "Data",
|
||||
g_bytes_get_size (priv->bytes));
|
||||
@ -373,6 +412,7 @@ fu_firmware_image_finalize (GObject *object)
|
||||
FuFirmwareImagePrivate *priv = GET_PRIVATE (self);
|
||||
g_free (priv->id);
|
||||
g_free (priv->version);
|
||||
g_free (priv->filename);
|
||||
if (priv->bytes != NULL)
|
||||
g_bytes_unref (priv->bytes);
|
||||
G_OBJECT_CLASS (fu_firmware_image_parent_class)->finalize (object);
|
||||
|
@ -38,6 +38,9 @@ gchar *fu_firmware_image_to_string (FuFirmwareImage *self);
|
||||
const gchar *fu_firmware_image_get_version (FuFirmwareImage *self);
|
||||
void fu_firmware_image_set_version (FuFirmwareImage *self,
|
||||
const gchar *version);
|
||||
const gchar *fu_firmware_image_get_filename (FuFirmwareImage *self);
|
||||
void fu_firmware_image_set_filename (FuFirmwareImage *self,
|
||||
const gchar *filename);
|
||||
const gchar *fu_firmware_image_get_id (FuFirmwareImage *self);
|
||||
void fu_firmware_image_set_id (FuFirmwareImage *self,
|
||||
const gchar *id);
|
||||
|
@ -1594,6 +1594,7 @@ fu_firmware_func (void)
|
||||
fu_firmware_image_set_addr (img1, 0x200);
|
||||
fu_firmware_image_set_idx (img1, 13);
|
||||
fu_firmware_image_set_id (img1, "primary");
|
||||
fu_firmware_image_set_filename (img1, "BIOS.bin");
|
||||
fu_firmware_add_image (firmware, img1);
|
||||
fu_firmware_image_set_addr (img2, 0x400);
|
||||
fu_firmware_image_set_idx (img2, 23);
|
||||
@ -1628,6 +1629,7 @@ fu_firmware_func (void)
|
||||
" ID: primary\n"
|
||||
" Index: 0xd\n"
|
||||
" Address: 0x200\n"
|
||||
" Filename: BIOS.bin\n"
|
||||
" FuFirmwareImage:\n"
|
||||
" ID: secondary\n"
|
||||
" Index: 0x17\n"
|
||||
|
@ -621,7 +621,9 @@ LIBFWUPDPLUGIN_1.5.0 {
|
||||
fu_firmware_flag_from_string;
|
||||
fu_firmware_flag_to_string;
|
||||
fu_firmware_has_flag;
|
||||
fu_firmware_image_get_filename;
|
||||
fu_firmware_image_parse;
|
||||
fu_firmware_image_set_filename;
|
||||
fu_fmap_firmware_get_type;
|
||||
fu_fmap_firmware_new;
|
||||
fu_plugin_runner_add_security_attrs;
|
||||
|
Loading…
Reference in New Issue
Block a user