Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle disk sector size #621

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/Objects/Mount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ public class Installer.Mount {
public string parent_disk;
public string mount_point;
public uint64 sectors;
public uint64 sector_size;
public Distinst.FileSystem filesystem;
public InstallerDaemon.MountFlags flags;
public PartitionMenu menu;

public Mount (string partition, string parent_disk, string mount,
uint64 sectors, InstallerDaemon.MountFlags flags, Distinst.FileSystem fs,
uint64 sectors, uint64 sector_size, InstallerDaemon.MountFlags flags, Distinst.FileSystem fs,
PartitionMenu menu) {
filesystem = fs;
mount_point = mount;
Expand All @@ -37,6 +38,7 @@ public class Installer.Mount {
this.menu = menu;
this.parent_disk = parent_disk;
this.sectors = sectors;
this.sector_size = sector_size;
}

public bool is_valid_boot_mount () {
Expand Down
8 changes: 4 additions & 4 deletions src/Views/PartitioningView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
EFI
}

const uint64 REQUIRED_EFI_SECTORS = 524288;
const uint64 REQUIRED_ESP_SIZE = 256 * 1024 * 1024;

construct {
mounts = new Gee.ArrayList<Installer.Mount> ();
Expand Down Expand Up @@ -161,7 +161,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
partitions.add (partition);
}

var disk_bar = new DiskBar (disk.name, path, size, (owned) partitions);
var disk_bar = new DiskBar (disk.name, path, size, sector_size, (owned) partitions);
disk_list.add (disk_bar);
}

Expand Down Expand Up @@ -212,7 +212,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
partitions.add (partition);
}

var disk_bar = new DiskBar (disk.name, path, size, (owned) partitions);
var disk_bar = new DiskBar (disk.name, path, size, sector_size, (owned) partitions);
disk_list.add (disk_bar);
}

Expand Down Expand Up @@ -269,7 +269,7 @@ public class Installer.PartitioningView : AbstractInstallerView {
if (mount.mount_point == "/boot/efi") {
if (!mount.is_valid_boot_mount ()) {
throw new GLib.IOError.FAILED (_("EFI partition has the wrong file system"));
} else if (mount.sectors < REQUIRED_EFI_SECTORS) {
} else if ((mount.sectors * mount.sector_size) < REQUIRED_ESP_SIZE) {
throw new GLib.IOError.FAILED (_("EFI partition is too small"));
}
} else if (mount.mount_point == "/" && !mount.is_valid_root_mount ()) {
Expand Down
10 changes: 6 additions & 4 deletions src/Widgets/DiskBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ public class Installer.DiskBar: Gtk.Grid {
public string disk_name { get; construct; }
public string disk_path { get; construct; }
public uint64 size { get; construct; }
public uint64 sector_size { get; construct; }
public Gee.ArrayList<PartitionBar> partitions { get; construct; }

private static Gtk.SizeGroup label_sizegroup;

private Gtk.Grid legend_container;

public DiskBar (string disk_name, string disk_path, uint64 size, Gee.ArrayList<PartitionBar> partitions) {
public DiskBar (string disk_name, string disk_path, uint64 size, uint64 sector_size, Gee.ArrayList<PartitionBar> partitions) {
Object (
disk_name: disk_name,
disk_path: disk_path,
partitions: partitions,
sector_size: sector_size,
size: size
);
}
Expand Down Expand Up @@ -89,15 +91,15 @@ public class Installer.DiskBar: Gtk.Grid {
legend.add (legend_container);

foreach (PartitionBar p in partitions) {
add_legend (p.path, p.get_size () * 512, Distinst.strfilesys (p.filesystem), p.vg, p.menu);
add_legend (p.path, p.get_size () * sector_size, Distinst.strfilesys (p.filesystem), p.vg, p.menu);
}

uint64 used = 0;
foreach (PartitionBar partition in partitions) {
used += partition.get_size ();
}

var unused = size - (used * 512);
var unused = size - (used * sector_size);
if (size / 100 < unused) {
add_legend ("unused", unused, "unused", null, null);

Expand Down Expand Up @@ -167,7 +169,7 @@ public class Installer.DiskBar: Gtk.Grid {

private void update_sector_lengths (Gee.ArrayList<PartitionBar> partitions, Gtk.Allocation alloc) {
var alloc_width = alloc.width;
var disk_sectors = this.size / 512;
var disk_sectors = this.size / sector_size;

int[] lengths = {};
for (int x = 0; x < partitions.size; x++) {
Expand Down
2 changes: 2 additions & 0 deletions src/Widgets/PartitionBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Installer.PartitionBar : Gtk.EventBox {
public uint64 start;
public uint64 end;
public uint64 used;
public uint64 sector_size;
public new string path;
public string? vg;

Expand All @@ -38,6 +39,7 @@ public class Installer.PartitionBar : Gtk.EventBox {
UnsetMount unset_mount, MountSetFn mount_set) {
start = part.start_sector;
end = part.end_sector;
this.sector_size = sector_size;

var usage = part.sectors_used;
if (usage.tag == 1) {
Expand Down
1 change: 1 addition & 0 deletions src/Widgets/PartitionMenu.vala
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public class Installer.PartitionMenu : Gtk.Popover {
parent_disk,
mount,
partition_bar.end - partition_bar.start,
partition_bar.sector_size,
(format_partition.active ? InstallerDaemon.MountFlags.FORMAT : 0)
+ (is_lvm ? InstallerDaemon.MountFlags.LVM : 0),
filesystem,
Expand Down