Skip to content

mmap: use private mappings for read-only files - #7315

Merged
ethomson merged 1 commit into
libgit2:mainfrom
0xferrous:fix/read-only-mmap-private
Jul 24, 2026
Merged

ethomson merged 1 commit into
libgit2:mainfrom
0xferrous:fix/read-only-mmap-private

Conversation

@0xferrous

@0xferrous 0xferrous commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Read-only mappings do not require shared semantics. Some filesystems, including virtiofs and GPFS, reject MAP_SHARED mappings with ENODEV while allowing MAP_PRIVATE mappings.

Use GIT_MAP_PRIVATE for the read-only mapping helper and when reading pack headers. This also matches the behavior of native Git.

Keep the writable Windows indexer mapping shared, since writes made through that mapping must reach the underlying file.

Add a test that verifies the read-only mapping helper creates a private
mapping.

Refs #7136

@0xferrous
0xferrous force-pushed the fix/read-only-mmap-private branch from c24e080 to 438cb8c Compare July 18, 2026 08:04
@ethomson

Copy link
Copy Markdown
Member

Thanks!

@ethomson

Copy link
Copy Markdown
Member

Add a test that verifies the read-only mapping helper creates a private
mapping.

One point; I don't see a new test. Were you intending to add one? Not sure that it's necessary, but if you wanted one then I don't want to merge until it's in place.

Read-only mappings do not require shared semantics. Some filesystems,
including virtiofs and GPFS, reject MAP_SHARED mappings with ENODEV while
allowing MAP_PRIVATE mappings.

Use GIT_MAP_PRIVATE for the read-only mapping helper and when reading pack
headers. This also matches the behavior of native Git.

Keep the writable Windows indexer mapping shared, since writes made through
that mapping must reach the underlying file.

Add a test that verifies the read-only mapping helper creates a private
mapping.

Refs libgit2#7136
@0xferrous
0xferrous force-pushed the fix/read-only-mmap-private branch from 438cb8c to c6ba959 Compare July 18, 2026 08:37
@0xferrous

Copy link
Copy Markdown
Contributor Author

yeah, sorry i forgot to push

@ethomson
ethomson merged commit 58701d7 into libgit2:main Jul 24, 2026
22 checks passed
@ethomson

Copy link
Copy Markdown
Member

Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants