File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ public struct WriteFileFlags {
2525 public var create = false
2626}
2727
28+ public enum FilesystemOperation {
29+ case freeze
30+ case thaw
31+ }
32+
2833/// A protocol for the agent running inside a virtual machine. If an operation isn't
2934/// supported the implementation MUST return a ContainerizationError with a code of
3035/// `.unsupported`.
@@ -34,6 +39,8 @@ public protocol VirtualMachineAgent: Sendable {
3439 func standardSetup( ) async throws
3540 /// Close any resources held by the agent.
3641 func close( ) async throws
42+ // Perform a filesystem operation on the given path.
43+ func filesystemOperation( operation: FilesystemOperation , path: String ) async throws
3744
3845 // POSIX-y
3946 func getenv( key: String ) async throws -> String
Original file line number Diff line number Diff line change @@ -202,6 +202,15 @@ extension Vminitd: VirtualMachineAgent {
202202 } )
203203 }
204204
205+ /// Perform a filesystem operation on a path inside the sandbox's environment.
206+ public func filesystemOperation( operation: FilesystemOperation , path: String ) async throws {
207+ _ = try await client. filesystemOperation (
208+ . with {
209+ $0. operation = operation. toProtoOperation ( )
210+ $0. path = path
211+ } )
212+ }
213+
205214 public func createProcess(
206215 id: String ,
207216 containerID: String ? ,
@@ -586,3 +595,15 @@ extension StatCategory {
586595 return categories
587596 }
588597}
598+
599+ extension FilesystemOperation {
600+ /// Convert FilesystemOperation to proto oneof value.
601+ func toProtoOperation( ) -> Com_Apple_Containerization_Sandbox_V3_FilesystemOperationRequest . OneOf_Operation {
602+ switch self {
603+ case . freeze:
604+ return . freeze( . init( ) )
605+ case . thaw:
606+ return . thaw( . init( ) )
607+ }
608+ }
609+ }
You can’t perform that action at this time.
0 commit comments