[gnome-disk-utility/kailueke/auto-max-size: 2/2] Use special parameter when requesting the maximal partition size
- From: Kai Lüke <kailueke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/kailueke/auto-max-size: 2/2] Use special parameter when requesting the maximal partition size
- Date: Sat, 11 Jul 2020 01:52:15 +0000 (UTC)
commit d3dce3a8cec638ab7a5d2be6514d601598d9e900
Author: Kai Lüke <kailueke riseup net>
Date: Sat Jul 11 01:44:50 2020 +0200
Use special parameter when requesting the maximal partition size
This is a workaround and it would be nice to either handle this better
in libblockdev or by creating the partition and then shrinking it.
As having multiple GB partitions is common, I think the corner case can
be ignored for now but it should be documented in the code.
Fixes https://gitlab.gnome.org/GNOME/gnome-disk-utility/-/issues/138
src/disks/gducreateformatdialog.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/src/disks/gducreateformatdialog.c b/src/disks/gducreateformatdialog.c
index c93f3e01..453e9fd2 100644
--- a/src/disks/gducreateformatdialog.c
+++ b/src/disks/gducreateformatdialog.c
@@ -368,6 +368,22 @@ finish_cb (GtkDialog *dialog, gint response_id, CreateFormatData *data) /* the a
}
size = gdu_create_partition_page_get_size (data->partition_page);
+ /* Normal alignments of a few MB are expected to happen and normally it works well
+ * to pass a slightly larger size.
+ * Yet sometimes there are huge amounts of alignment enforced by libblockdev/libparted
+ * and it's unclear how many MB should be left when creating a partition on a 1 TB
+ * drive. The maximal size we present to the user is based on the size of unallocated
+ * space which may be too large.
+ * To address this issue, rely on the maximal size being found automatically by passing
+ * the special argument 0.
+ * However, this won't cover cases where the user substracts a few MB and now wonders
+ * why the partition can't be created. Heuristics for these corner cases could be
+ * implemented or libblockdev improved to handle these cases better but it would be
+ * easier and more accurate to create a partition with a maximal size first and then
+ * shrink it to the user's desired size if needed.
+ */
+ if (size == data->add_partition_maxsize)
+ size = 0;
udisks_partition_table_call_create_partition (data->table,
data->add_partition_offset,
size,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]