part: Check whether partition exists before setting GPT attributes
Resolves: RHEL-143353
This commit is contained in:
parent
4ff3714ca7
commit
7c287748a4
@ -0,0 +1,46 @@
|
|||||||
|
From 168e3cea4c9d9ef3b858b5862b323900e0344c46 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Thu, 19 Feb 2026 16:23:20 +0100
|
||||||
|
Subject: [PATCH] part: Check whether partition exists before setting GPT
|
||||||
|
attributes
|
||||||
|
|
||||||
|
Other "set" functions already have this check.
|
||||||
|
|
||||||
|
Resolves: RHEL-143353
|
||||||
|
---
|
||||||
|
src/plugins/part.c | 11 +++++++++++
|
||||||
|
1 file changed, 11 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/part.c b/src/plugins/part.c
|
||||||
|
index 35ac5c09f..26e580638 100644
|
||||||
|
--- a/src/plugins/part.c
|
||||||
|
+++ b/src/plugins/part.c
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
@ -86,13 +86,14 @@
|
|||||||
|
|
||||||
Name: libblockdev
|
Name: libblockdev
|
||||||
Version: 3.4.0
|
Version: 3.4.0
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
Summary: A library for low-level manipulation with block devices
|
Summary: A library for low-level manipulation with block devices
|
||||||
License: LGPL-2.1-or-later
|
License: LGPL-2.1-or-later
|
||||||
URL: https://github.com/storaged-project/libblockdev
|
URL: https://github.com/storaged-project/libblockdev
|
||||||
Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}/%{name}-%{version}.tar.gz
|
Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}/%{name}-%{version}.tar.gz
|
||||||
|
|
||||||
Patch0: 0001-lvm-dbus-Show-better-error-for-invalid-LVM-IDs.patch
|
Patch0: 0001-lvm-dbus-Show-better-error-for-invalid-LVM-IDs.patch
|
||||||
|
Patch1: 0002-part-Check-whether-partition-exists-before-setting-GPT-attributes.patch
|
||||||
|
|
||||||
BuildRequires: make
|
BuildRequires: make
|
||||||
BuildRequires: glib2-devel
|
BuildRequires: glib2-devel
|
||||||
@ -948,6 +949,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
|
|||||||
%files plugins-all
|
%files plugins-all
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Mar 23 2026 Vojtech Trefny <vtrefny@redhat.com> - 3.4.0-3
|
||||||
|
- part: Check whether partition exists before setting GPT attributes
|
||||||
|
Resolves: RHEL-143353
|
||||||
|
|
||||||
* Thu Oct 30 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.4.0-2
|
* Thu Oct 30 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.4.0-2
|
||||||
- lvm-dbus: Show better error for invalid LVM IDs
|
- lvm-dbus: Show better error for invalid LVM IDs
|
||||||
Resolves: RHEL-123039
|
Resolves: RHEL-123039
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user