Skip to content

Improve partition name extraction logic#381

Merged
fredkiefer merged 1 commit into
gnustep:masterfrom
probonopd:patch-4
Jul 14, 2026
Merged

Improve partition name extraction logic#381
fredkiefer merged 1 commit into
gnustep:masterfrom
probonopd:patch-4

Conversation

@probonopd

@probonopd probonopd commented Jan 11, 2026

Copy link
Copy Markdown
Contributor

Without this fix, a ISO9660 image directly written to a USB stick (e.g., GhostBSD, Linux Live system) is not recognized properly. With this fix, it is.

Original comment said // This is a very crude way of removing the partition number.

Copilot AI review requested due to automatic review settings January 11, 2026 10:03
@probonopd probonopd requested a review from fredkiefer as a code owner January 11, 2026 10:03
@probonopd probonopd changed the title Improve partition name extraction logic. Improve partition name extraction logic Jan 11, 2026
probonopd added a commit to gershwin-desktop-legacy/libs-gui that referenced this pull request Jan 11, 2026
This allows us to recognize USB sticks that have an ISO9660 image directly written on it (e.g., GhostBSD).
Upstream PR: gnustep#381

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the partition name extraction logic in NSWorkspace to properly handle modern Linux block device naming schemes. The previous implementation naively truncated device names to 3 characters, which failed for devices like NVMe drives (nvme0n1p1), MMC/SD cards (mmcblk0p1), and ISO9660 images on USB sticks.

Changes:

  • Updated copyright year to 2026
  • Replaced crude 3-character truncation with comprehensive device-type-aware partition stripping logic
  • Added support for nvme, mmcblk, sd, hd, vd, and xvd device naming patterns with proper partition suffix removal

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Source/NSWorkspace.m
Comment thread Source/NSWorkspace.m Outdated
else if ([devName hasPrefix:@"sd"] || [devName hasPrefix:@"hd"] ||
[devName hasPrefix:@"vd"] || [devName hasPrefix:@"xvd"])
{
/* For sd/hd/vd devices, remove trailing digits (sda1 → sda) */

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions only "sd/hd/vd devices" but the code also handles "xvd" devices (Xen virtual disks). The comment should include "xvd" for completeness.

Suggested change
/* For sd/hd/vd devices, remove trailing digits (sda1 → sda) */
/* For sd/hd/vd/xvd devices, remove trailing digits (sda1 → sda) */

Copilot uses AI. Check for mistakes.
Comment thread Source/NSWorkspace.m
Comment thread Source/NSWorkspace.m Outdated

/* Extract block device name by removing partition suffix
* Handle various device naming schemes:
* sd*, hd* → just remove trailing digits (sda1 → sda)

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states that only sd* and hd* devices have trailing digits removed, but the code also handles vd* and xvd* devices (virtual disk devices). The comment should be updated to reflect all device types handled: "sd*, hd*, vd*, xvd* → remove trailing digits".

Copilot uses AI. Check for mistakes.
Comment thread Source/NSWorkspace.m Outdated

@fredkiefer fredkiefer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
The Copilot comments are really very helpful, your should address these. Having a test would be nice, but not strictly required.
I would prefer to have this new code in a helper function/method, but again this is not required. I also prefer to have a space after the colon in a method call, but the code around this change is also lacking that.

@fredkiefer

Copy link
Copy Markdown
Member

It would be great to finish this PR. There are only minor things missing.

Extract partition name stripping into a helper method
_stripPartitionSuffixFromDeviceName: supporting modern Linux
block device naming schemes (nvme, mmcblk, sd, hd, vd, xvd).
Previously only sd/hd were handled with crude 3-char truncation.

Without this fix, ISO9660 images directly written to USB sticks
are not recognized properly.
@fredkiefer fredkiefer merged commit f39fe9f into gnustep:master Jul 14, 2026
3 checks passed
@probonopd

Copy link
Copy Markdown
Contributor Author

Thanks for merging @fredkiefer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants