Let's add an API in order to let the applications known whether a media created is bootable or not (according to libosinfo detection). Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- osinfo/libosinfo.syms | 1 + osinfo/osinfo_media.c | 27 +++++++++++++++++++++++++-- osinfo/osinfo_media.h | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms index d6809a8..4e96f16 100644 --- a/osinfo/libosinfo.syms +++ b/osinfo/libosinfo.syms @@ -590,6 +590,7 @@ LIBOSINFO_1.6.0 { osinfo_media_create_from_location_with_flags_async; osinfo_media_create_from_location_with_flags_finish; osinfo_media_detect_flags_get_type; + osinfo_media_is_bootable; osinfo_os_get_kernel_url_argument; } LIBOSINFO_1.5.0; diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c index 69813db..b744a94 100644 --- a/osinfo/osinfo_media.c +++ b/osinfo/osinfo_media.c @@ -144,6 +144,7 @@ struct _CreateFromLocationAsyncData { gchar *publisher; guint flags; + gboolean bootable; }; static void create_from_location_async_data_free @@ -870,6 +871,10 @@ create_from_location_async_data(CreateFromLocationAsyncData *data) OSINFO_MEDIA_PROP_VOLUME_SIZE, vol_size); + osinfo_entity_set_param_boolean(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_BOOTABLE, + data->bootable); + return media; } @@ -1067,15 +1072,18 @@ static void search_ppc_bootinfo_callback(GObject *source, data = (CreateFromLocationAsyncData *)user_data; + data->bootable = TRUE; ret = search_ppc_bootinfo_finish(res, &error); if (!ret) { if (g_error_matches(error, OSINFO_MEDIA_ERROR, OSINFO_MEDIA_ERROR_NOT_BOOTABLE)) { - if ((data->flags & OSINFO_MEDIA_DETECT_REQUIRE_BOOTABLE) != 0) + if ((data->flags & OSINFO_MEDIA_DETECT_REQUIRE_BOOTABLE) != 0) { goto cleanup; - else + } else { g_clear_error(&error); + data->bootable = FALSE; + } } } @@ -1154,6 +1162,7 @@ static void on_svd_read(GObject *source, return; } + data->bootable = TRUE; media = create_from_location_async_data(data); cleanup: @@ -1798,3 +1807,17 @@ OsinfoInstallScriptList *osinfo_media_get_install_script_list(OsinfoMedia *media return OSINFO_INSTALL_SCRIPTLIST(new_list); } + +/** + * osinfo_media_is_bootable: + * @media: and #OsinfoMedia instance + * + * Returns: #TRUE if the @media is bootable. #FALSE otherwise. + */ +gboolean osinfo_media_is_bootable(OsinfoMedia *media) +{ + g_return_val_if_fail(OSINFO_IS_MEDIA(media), FALSE); + + return osinfo_entity_get_param_value_boolean(OSINFO_ENTITY(media), + OSINFO_MEDIA_PROP_BOOTABLE); +} diff --git a/osinfo/osinfo_media.h b/osinfo/osinfo_media.h index 747046b..5b7bd8b 100644 --- a/osinfo/osinfo_media.h +++ b/osinfo/osinfo_media.h @@ -105,6 +105,7 @@ typedef struct _OsinfoMediaPrivate OsinfoMediaPrivate; #define OSINFO_MEDIA_PROP_VOLUME_SIZE "volume-size" #define OSINFO_MEDIA_PROP_EJECT_AFTER_INSTALL "eject-after-install" #define OSINFO_MEDIA_PROP_INSTALLER_SCRIPT "installer-script" +#define OSINFO_MEDIA_PROP_BOOTABLE "bootable" /* object */ struct _OsinfoMedia @@ -161,6 +162,7 @@ const gchar *osinfo_media_get_publisher_id(OsinfoMedia *media); const gchar *osinfo_media_get_application_id(OsinfoMedia *media); const gchar *osinfo_media_get_kernel_path(OsinfoMedia *media); const gchar *osinfo_media_get_initrd_path(OsinfoMedia *media); +gboolean osinfo_media_is_bootable(OsinfoMedia *media); OsinfoOs *osinfo_media_get_os(OsinfoMedia *media); OsinfoOsVariantList *osinfo_media_get_os_variants(OsinfoMedia *media); GList *osinfo_media_get_languages(OsinfoMedia *media); -- 2.21.0 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo