Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/plugins/part.c
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,7 @@ gboolean bd_part_set_part_bootable (const gchar *disk, const gchar *part, gboole
*/
gboolean bd_part_set_part_attributes (const gchar *disk, const gchar *part, guint64 attrs, GError **error) {
struct fdisk_context *cxt = NULL;
struct fdisk_partition *pa = NULL;
gint part_num = 0;
gint ret = 0;

Expand All @@ -2222,10 +2223,20 @@ gboolean bd_part_set_part_attributes (const gchar *disk, const gchar *part, guin
if (!cxt)
return FALSE;

ret = fdisk_get_partition (cxt, part_num, &pa);
if (ret != 0) {
g_set_error (error, BD_PART_ERROR, BD_PART_ERROR_FAIL,
"Failed to get partition '%d' on device '%s'.", part_num, disk);
close_context (cxt);
return FALSE;
}
fdisk_unref_partition (pa);

ret = fdisk_gpt_set_partition_attrs (cxt, part_num, attrs);
if (ret < 0) {
g_set_error (error, BD_PART_ERROR, BD_PART_ERROR_FAIL,
"Failed to set GPT attributes: %s", strerror_l (-ret, c_locale));
close_context (cxt);
return FALSE;
}

Expand Down