Skip to content

fix(detection): use POSIX-compliant free disk space check on macOS and BSD - #5952

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/detection-disk-space-posix
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/detection-disk-space-posix

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/installers/macos/lib/detection.sh, test_disk_space() uses df -g "$path" to read available gigabytes, with a fallback df -BG "$path". The -B flag is a GNU coreutils extension that is completely unsupported by BSD/macOS df (which terminates with exit 64: df: illegal option -- B). Furthermore, the fallback was conditioned on [[ -z "$free_gb" || "$free_gb" == "0" ]], meaning that when a filesystem legitimately had zero gigabytes remaining (e.g. less than 1GB free), the script invoked the failing GNU command, clearing the variable instead of accurately reporting 0.

This change conditions fallback execution on non-numeric or missing results ([[ -z "$free_gb" || ! "$free_gb" =~ ^[0-9]+$ ]]) and replaces the GNU -BG call with POSIX-standard df -Pk "$path" (-P for portable 1-line format, -k for 1024-byte blocks), computing gigabytes via int($4 / 1048576). This guarantees reliable, portable disk space discovery across macOS, BSD, and containerized detection environments.

Validation

  • Baseline reproduction: In environments where df -g is unsupported or fails, df -BG exits with code 64, leaving free_gb unpopulated. Additionally, legitimate 0GB free space erroneously triggered GNU fallback failure.
  • Post-fix verification: Non-GNU platforms cleanly fall back to df -Pk, properly computing available gigabytes without shell warnings or empty values. Legitimate 0GB values are preserved as integer 0.
  • Telemetry: Installer detection test suite passes: test_detection_disk_space_posix.py passes cleanly (exit code 0). Wired into Linux CI workflow under Manifest Compatibility Checks.

Overlap check

Risk / AI disclosure

AI-assisted investigation, implementation, and test regressions. This aligns macOS disk space detection with the POSIX standard df -Pk used across the rest of the installer codebase. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.

Follow-up integration evidence

Composed with #5871, #5901, and #5951 at HEAD without conflicts. Production and test diffs passed together; compatibility and installer suites remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants