Port f3probe, f3brew, and f3fix to macOS - #283
Open
sbrunner-atx wants to merge 1 commit into
Open
Conversation
The probing algorithm (libprobe.c) is platform-independent; only the device-access layer in libdevs.c was Linux-specific. This commit adds an __APPLE__ backend: - open() with F_NOCACHE replaces O_DIRECT (with _DARWIN_C_SOURCE so the Darwin extensions stay visible despite _POSIX_C_SOURCE) - DKIOCGETBLOCKCOUNT/DKIOCGETBLOCKSIZE replace BLKGETSIZE64/BLKSSZGET - whole-disk detection by device-name convention (/dev/rdiskN vs /dev/rdiskNsM) replaces the udev devtype check - manual USB reset (used by f3brew only; f3probe uses RT_NONE) is implemented by polling the device node instead of a udev monitor - software USB reset (USBDEVFS_RESET) reports EOPNOTSUPP on macOS - posix_fadvise(DONTNEED) is skipped; F_NOCACHE already bypasses the page cache f3fix on macOS is a new libparted-free backend (f3fix_darwin.c) that writes the MBR directly: fixing a fake drive only ever needs a single MBR partition ending at the last good sector reported by f3probe. MBR only for now; GPT is unnecessary for this use case. The Linux build is unchanged: all __APPLE__ additions are guarded and the Linux path compiles the same objects with no new warnings. Tested on macOS 26.5 (Intel, MacBookPro16,1): make extra builds all three tools with clang and brew argp-standalone, and f3probe --debug-unit-test reports Perfect. Closes AltraMayor#8. Closes AltraMayor#135.
sbrunner-atx
force-pushed
the
macos-port
branch
from
August 19, 2026 07:17
9023d0c to
a8f17ee
Compare
Author
|
For anyone who wants to try this on macOS without building manually, I have published a Homebrew tap pinned to this PR branch: Tap: https://github.com/sbrunner-atx/homebrew-f3 (README includes macOS usage notes: raw whole-disk device, unmount first, sudo). I will retire the tap once this is merged and the official formula picks up Full f3probe hardware-validation transcript (genuine SanDisk Ultra 128 GB, macOS 26.5 Intel) available on request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ports the three extra tools - f3probe, f3brew, and f3fix - to macOS, as invited by #8 and requested in #135.
How
The probing algorithm (libprobe.c) is already platform-independent; only the device-access layer needed work. All changes are behind APPLE guards:
f3fix on macOS is a new libparted-free backend (f3fix_darwin.c) that writes the MBR directly - fixing a fake drive only ever needs a single MBR partition ending at the last good sector from f3probe. MBR only for now; GPT support could follow if there is demand.
Validation
On macOS 26.5 (Intel, MacBookPro16,1), clang + brew argp-standalone:
The Linux build is unchanged: gcc on Ubuntu compiles all targets with no new warnings, and the Linux code path is untouched.
Notes