Skip to content

Restore macOS immutable file-flag support with a minimal Java 25 FFM handler - #2

Draft
HannesWell with Copilot wants to merge 26 commits into
macos-immutable-ffmfrom
copilot/macos-immutable-ffm
Draft

HannesWell with Copilot wants to merge 26 commits into
macos-immutable-ffmfrom
copilot/macos-immutable-ffm

Conversation

Copilot AI commented Sep 20, 2026

Copy link
Copy Markdown

PR eclipse-platform#2925 moved macOS local-file metadata updates to PosixHandler, which preserved POSIX permissions but dropped BSD st_flags handling. That regressed EFS.ATTRIBUTE_IMMUTABLE on macOS, so ATTRIBUTE_READ_ONLY no longer round-tripped through cache copies as expected by the existing resources tests.

  • What changes on macOS

    • Add a small macOS-only handler that keeps normal metadata work in PosixHandler and restores only the missing BSD file-flag behavior.
    • Advertise EFS.ATTRIBUTE_IMMUTABLE only when the macOS FFM path is available.
    • Keep non-macOS behavior unchanged.
  • FFM-based BSD flag access

    • Add MacFileFlags, a Java 25 FFM helper that calls macOS libc directly.
    • Use lstat to read st_flags without following symlinks.
    • Use chflags to update flags while preserving unrelated bits.
    • Treat both UF_IMMUTABLE and SF_IMMUTABLE as immutable when fetching attributes.
    • Only set/clear the user-settable UF_IMMUTABLE bit on write.
  • Attribute update ordering

    • Preserve the native implementation’s ordering:
      1. clear user immutable when needed,
      2. apply POSIX permission changes through PosixHandler,
      3. restore/set immutable afterward.
    • Avoid overwriting unrelated BSD flags introduced or preserved across the POSIX update.
  • Handler selection

    • Update LocalFileNativesManager to select the macOS immutable-aware handler only for macOS POSIX filesystems where the FFM bindings are usable.
    • Leave Linux fast-path natives and all other handlers untouched.
  • Focused regression coverage

    • Keep TestBug323833’s small-file and large-file cache-path assertions intact.
    • Strengthen macOS coverage with direct fetch-after-put assertions and explicit immutable/read-only round-trip checks in Bug_329836.
  • Why NIO alone is not enough

    • Standard Java NIO exposes POSIX permissions, but not macOS BSD st_flags.
    • This change uses FFM only for the missing BSD-file-flags portion rather than reintroducing a native macOS fragment.
IFileInfo info = fileStore.fetchInfo();
info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true);
fileStore.putInfo(info, EFS.SET_ATTRIBUTES, monitor);

IFileInfo updated = fileStore.fetchInfo();
assertTrue(updated.getAttribute(EFS.ATTRIBUTE_READ_ONLY));
assertTrue(updated.getAttribute(EFS.ATTRIBUTE_IMMUTABLE));

Copilot AI and others added 22 commits September 20, 2026 13:04
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement Java 25 FFM helper for EFS.ATTRIBUTE_IMMUTABLE Restore macOS immutable file-flag support with a minimal Java 25 FFM handler Sep 20, 2026
Copilot AI requested a review from HannesWell September 20, 2026 13:18
Copilot AI and others added 2 commits September 20, 2026 14:27
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
Co-authored-by: HannesWell <44067969+HannesWell@users.noreply.github.com>
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