-
Notifications
You must be signed in to change notification settings - Fork 215
Add single file mount support via hardlink-based isolation for single file mounts #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Sunsvea
wants to merge
32
commits into
apple:main
Choose a base branch
from
Sunsvea:feature/single-file-mount-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+665
−14
Open
Changes from 8 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a20c3f9
Add file mount detection and parent directory sharing
Sunsvea 429a379
Implement bind mount functionality for single files
Sunsvea eb4a1ee
Add tests for single file mount detection
Sunsvea 6a32cdf
Fix mounts property reference in bind mount logic
Sunsvea dedb89f
Fix AttachedFilesystem property access in mount logic
Sunsvea d9f7afe
Fix allocator usage in mount tests
Sunsvea 3f81e5f
Run formatter
Sunsvea dd0b78a
Merge branch 'main' into feature/single-file-mount-support
Sunsvea 2f5c7b2
Address reviewer feedback: rename isFileBind to isFile and revert mou…
Sunsvea b6730f6
Revert rootfs mount to use original .to pattern for consistency
Sunsvea 9252ef5
Revert spec.mounts to use clean .to pattern instead of verbose .init
Sunsvea 0e23a8c
Add integration test coverage for single file mount support and impro…
Sunsvea 75fd986
Implement hardlink-based file isolation for single file mounts
Sunsvea 0b2e6d3
Remove bind mount logic as hardlinked files are directly accessible
Sunsvea ca23072
Update AttachedFilesystem to use deterministic hardlink isolation and…
Sunsvea d117e5a
Add comprehensive unit tests for hardlink isolation and fix Foundatio…
Sunsvea 22aa0d9
Apply code formatting to hardlink isolation implementation
Sunsvea 29f5518
Merge branch 'main' into feature/single-file-mount-support
Sunsvea d6ad5e7
feat: add mount consolidation for multiple single file mounts
Sunsvea eb9decd
Merge branch 'main' into feature/single-file-mount-support
Sunsvea 7d2aba9
feat: add security hardening for file mount isolation with atomic ope…
Sunsvea 9104a3d
fix: add race condition protection to createIsolatedFileShare()
Sunsvea ce04bc1
fix: prevent temp directory collisions in createIsolatedFileShare()
Sunsvea 2e8a5fe
Merge branch 'origin/main' into feature/single-file-mount-support
Sunsvea 0107d82
fix: resolve race condition in Mount tests with UUID-based temp direc…
Sunsvea 648a7ba
chore: run code formatter
Sunsvea b09860c
fix: resolve race conditions in tests when executed in parallel
Sunsvea 55cbcac
chore: run code formatter
Sunsvea 07ee4ff
refactor: remove redundant caching mechanism
Sunsvea 0636693
fix: filename conflicts in tests when run in parallel
Sunsvea 442718a
Merge branch 'main' into feature/single-file-mount-support
Sunsvea c8b5a9d
Merge branch 'main' into feature/single-file-mount-support
Sunsvea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // Copyright © 2025 Apple Inc. and the Containerization project authors. All rights reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| import Foundation | ||
| import Testing | ||
|
|
||
| @testable import Containerization | ||
|
|
||
| final class MountTests { | ||
| @Test func fileDetection() throws { | ||
| let tempDir = FileManager.default.temporaryDirectory | ||
| let testFile = tempDir.appendingPathComponent("testfile.txt") | ||
|
|
||
| try "test content".write(to: testFile, atomically: true, encoding: .utf8) | ||
| defer { try? FileManager.default.removeItem(at: testFile) } | ||
|
|
||
| let mount = Mount.share( | ||
| source: testFile.path, | ||
| destination: "/app/config.txt" | ||
| ) | ||
|
|
||
| #expect(mount.isFile == true) | ||
| #expect(mount.filename == "testfile.txt") | ||
| #expect(mount.parentDirectory == tempDir.path) | ||
| } | ||
|
|
||
| @Test func directoryDetection() throws { | ||
| let tempDir = FileManager.default.temporaryDirectory | ||
|
|
||
| let mount = Mount.share( | ||
| source: tempDir.path, | ||
| destination: "/app/data" | ||
| ) | ||
|
|
||
| #expect(mount.isFile == false) | ||
| } | ||
|
|
||
| #if os(macOS) | ||
| @Test func attachedFilesystemBindFlag() throws { | ||
| let tempDir = FileManager.default.temporaryDirectory | ||
| let testFile = tempDir.appendingPathComponent("bindtest.txt") | ||
|
|
||
| try "bind test".write(to: testFile, atomically: true, encoding: .utf8) | ||
| defer { try? FileManager.default.removeItem(at: testFile) } | ||
|
|
||
| let mount = Mount.share( | ||
| source: testFile.path, | ||
| destination: "/app/config.txt" | ||
| ) | ||
|
|
||
| let allocator = Character.blockDeviceTagAllocator() | ||
| let attached = try AttachedFilesystem(mount: mount, allocator: allocator) | ||
|
|
||
| #expect(attached.isFileBind == true) | ||
| #expect(attached.type == "virtiofs") | ||
| } | ||
| #endif | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.