Skip to content

Commit 2cf510d

Browse files
authored
Check ESP size in bytes not sectors (#953)
1 parent 8d8ac82 commit 2cf510d

6 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎common/DBusStructures.vala‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public struct InstallerDaemon.Mount {
155155
string parent_disk;
156156
string mount_point;
157157
uint64 sectors;
158+
uint64 sector_size;
158159
FileSystem filesystem;
159160
MountFlags flags;
160161

‎src/Objects/Mount.vala‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ public class Installer.Mount {
2323
public string parent_disk;
2424
public string mount_point;
2525
public uint64 sectors;
26+
public uint64 sector_size;
2627
public InstallerDaemon.FileSystem filesystem;
2728
public InstallerDaemon.MountFlags flags;
2829
public PartitionMenu menu;
2930

3031
public Mount (string partition, string parent_disk, string mount,
31-
uint64 sectors, InstallerDaemon.MountFlags flags, InstallerDaemon.FileSystem fs,
32+
uint64 sectors, uint64 sector_size, InstallerDaemon.MountFlags flags, InstallerDaemon.FileSystem fs,
3233
PartitionMenu menu) {
3334
filesystem = fs;
3435
mount_point = mount;
@@ -37,6 +38,7 @@ public class Installer.Mount {
3738
this.menu = menu;
3839
this.parent_disk = parent_disk;
3940
this.sectors = sectors;
41+
this.sector_size = sector_size;
4042
}
4143

4244
public bool is_valid_boot_mount () {

‎src/Views/PartitioningView.vala‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
4141
EFI
4242
}
4343

44-
const uint64 REQUIRED_EFI_SECTORS = 524288;
44+
const uint64 REQUIRED_ESP_SIZE = 256 * 1024 * 1024;
4545

4646
construct {
4747
mounts = new Gee.ArrayList<Installer.Mount> ();
@@ -218,7 +218,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
218218
partition.menu = new DecryptMenu (part.device_path);
219219
((DecryptMenu) partition.menu).decrypted.connect (on_partition_decrypted);
220220
} else {
221-
partition.menu = new PartitionMenu (part.device_path, disk.device_path, part.filesystem, lvm, this.set_mount, this.unset_mount, this.mount_is_set, partition);
221+
partition.menu = new PartitionMenu (part.device_path, disk.device_path, part.filesystem, lvm, this.set_mount, this.unset_mount, this.mount_is_set, partition, disk.sector_size);
222222
}
223223

224224
partitions.add (partition);
@@ -281,7 +281,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
281281
if (mount.mount_point == "/boot/efi") {
282282
if (!mount.is_valid_boot_mount ()) {
283283
throw new GLib.IOError.FAILED (_("EFI partition has the wrong file system"));
284-
} else if (mount.sectors < REQUIRED_EFI_SECTORS) {
284+
} else if ((mount.sectors * mount.sector_size) < REQUIRED_ESP_SIZE) {
285285
throw new GLib.IOError.FAILED (_("EFI partition is too small"));
286286
}
287287
} else if (mount.mount_point == "/" && !mount.is_valid_root_mount ()) {

‎src/Views/ProgressView.vala‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public class ProgressView : Adw.NavigationPage {
175175
parent_disk = m.parent_disk,
176176
mount_point = m.mount_point,
177177
sectors = m.sectors,
178+
sector_size = m.sector_size,
178179
filesystem = m.filesystem,
179180
flags = m.flags
180181
};

‎src/Widgets/PartitionBlock.vala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ public class Installer.PartitionBlock : Adw.Bin {
5151
}
5252

5353
public uint64 get_partition_size_in_sectors () {
54-
return partition.end_sector - partition.start_sector;
54+
return (partition.end_sector - partition.start_sector) + 1;
5555
}
5656
}

‎src/Widgets/PartitionMenu.vala‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Installer.PartitionMenu : Gtk.Popover {
2828
private bool is_lvm;
2929
private string parent_disk;
3030
private string partition_path;
31+
private uint64 sector_size;
3132
private InstallerDaemon.FileSystem original_filesystem;
3233

3334
private Granite.SwitchModelButton format_partition;
@@ -42,8 +43,9 @@ public class Installer.PartitionMenu : Gtk.Popover {
4243

4344
public PartitionMenu (string path, string parent, InstallerDaemon.FileSystem fs,
4445
bool lvm, SetMount set_mount, UnsetMount unset_mount,
45-
MountSetFn mount_set, PartitionBlock partition_bar) {
46+
MountSetFn mount_set, PartitionBlock partition_bar, uint64 sector_size) {
4647
this.partition_bar = partition_bar;
48+
this.sector_size = sector_size;
4749
original_filesystem = fs;
4850
is_lvm = lvm;
4951
partition_path = path;
@@ -271,6 +273,7 @@ public class Installer.PartitionMenu : Gtk.Popover {
271273
parent_disk,
272274
mount,
273275
partition_bar.get_partition_size_in_sectors (),
276+
sector_size,
274277
(format_partition.active ? InstallerDaemon.MountFlags.FORMAT : 0)
275278
+ (is_lvm ? InstallerDaemon.MountFlags.LVM : 0),
276279
filesystem,

0 commit comments

Comments
 (0)