diff --git a/Sources/Containerization/ContainerManager.swift b/Sources/Containerization/ContainerManager.swift index 1b3a4089b..27e9fbe47 100644 --- a/Sources/Containerization/ContainerManager.swift +++ b/Sources/Containerization/ContainerManager.swift @@ -342,7 +342,7 @@ public struct ContainerManager: Sendable { private func unpack(image: Image, destination: URL, size: UInt64, progress: ProgressHandler? = nil) async throws -> Mount { do { - let unpacker = EXT4Unpacker(blockSizeInBytes: size) + let unpacker = EXT4Unpacker(capacityInBytes: size) return try await unpacker.unpack(image, for: .current, at: destination, progress: progress) } catch let err as ContainerizationError { if err.code == .exists { diff --git a/Sources/Containerization/Image/InitImage.swift b/Sources/Containerization/Image/InitImage.swift index a63f0dce2..5a4ef58ba 100644 --- a/Sources/Containerization/Image/InitImage.swift +++ b/Sources/Containerization/Image/InitImage.swift @@ -34,7 +34,7 @@ public struct InitImage: Sendable { extension InitImage { /// Unpack the initial filesystem for the desired platform at a given path. public func initBlock(at: URL, for platform: SystemPlatform) async throws -> Mount { - let unpacker = EXT4Unpacker(blockSizeInBytes: 512.mib()) + let unpacker = EXT4Unpacker(capacityInBytes: 512.mib()) var fs = try await unpacker.unpack(self.image, for: platform.ociPlatform(), at: at) fs.options = ["ro"] return fs diff --git a/Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift b/Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift index 0e9609b9a..2c96617cf 100644 --- a/Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift +++ b/Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift @@ -23,16 +23,16 @@ import Foundation import SystemPackage public struct EXT4Unpacker: Unpacker { - let blockSizeInBytes: UInt64 + let capacityInBytes: UInt64 let journal: EXT4.JournalConfig? /// Creates an unpacker that extracts images into EXT4 filesystems. /// - Parameters: - /// - blockSizeInBytes: The filesystem block size. + /// - capacityInBytes: The minimum usable capacity of the filesystem image, in bytes. /// - journal: The journal configuration to use, or nil for no journaling. - public init(blockSizeInBytes: UInt64, journal: EXT4.JournalConfig? = nil) { - self.blockSizeInBytes = blockSizeInBytes + public init(capacityInBytes: UInt64, journal: EXT4.JournalConfig? = nil) { + self.capacityInBytes = capacityInBytes self.journal = journal } @@ -49,7 +49,7 @@ public struct EXT4Unpacker: Unpacker { let cleanedPath = try prepareUnpackPath(path: path) let filesystem = try EXT4.Formatter( FilePath(cleanedPath), - minDiskSize: blockSizeInBytes, + minDiskSize: capacityInBytes, journal: journal ) defer { try? filesystem.close() } @@ -79,7 +79,7 @@ public struct EXT4Unpacker: Unpacker { FilePath( cleanedPath ), - minDiskSize: blockSizeInBytes + minDiskSize: capacityInBytes ) defer { try? filesystem.close() } diff --git a/Sources/Integration/Suite.swift b/Sources/Integration/Suite.swift index 440384ea0..a3c11977f 100644 --- a/Sources/Integration/Suite.swift +++ b/Sources/Integration/Suite.swift @@ -236,7 +236,7 @@ struct IntegrationSuite: AsyncParsableCommand { let fsPath = Self.testDir.appending(component: image.digest) let fs = try await Self.unpackCoordinator.unpack(key: fsPath.absolutePath()) { do { - let unpacker = EXT4Unpacker(blockSizeInBytes: 2.gib()) + let unpacker = EXT4Unpacker(capacityInBytes: 2.gib()) return try await unpacker.unpack(image, for: platform, at: fsPath) } catch let err as ContainerizationError { if err.code == .exists { diff --git a/Sources/cctl/ImageCommand.swift b/Sources/cctl/ImageCommand.swift index 6247067b3..6f9eba1a0 100644 --- a/Sources/cctl/ImageCommand.swift +++ b/Sources/cctl/ImageCommand.swift @@ -146,7 +146,7 @@ extension Application { let unpackUrl = URL(filePath: unpackPath) try FileManager.default.createDirectory(at: unpackUrl, withIntermediateDirectories: true) - let unpacker = EXT4Unpacker.init(blockSizeInBytes: 2.gib()) + let unpacker = EXT4Unpacker.init(capacityInBytes: 2.gib()) startTime = ContinuousClock.now if let platform { diff --git a/Sources/cctl/RootfsCommand.swift b/Sources/cctl/RootfsCommand.swift index cd5fd36f8..2145d61dd 100644 --- a/Sources/cctl/RootfsCommand.swift +++ b/Sources/cctl/RootfsCommand.swift @@ -95,7 +95,7 @@ extension Application { } private func outputExt4(archive: URL, to path: URL) async throws { - let unpacker = EXT4Unpacker(blockSizeInBytes: 256.mib()) + let unpacker = EXT4Unpacker(capacityInBytes: 256.mib()) try await unpacker.unpack(archive: archive, compression: .gzip, at: path) } diff --git a/Sources/cctl/RunCommand.swift b/Sources/cctl/RunCommand.swift index cc5a00a42..fceff1724 100644 --- a/Sources/cctl/RunCommand.swift +++ b/Sources/cctl/RunCommand.swift @@ -352,7 +352,7 @@ extension Application { var rootfsMount: Containerization.Mount do { - let unpacker = EXT4Unpacker(blockSizeInBytes: fsSizeInMB.mib()) + let unpacker = EXT4Unpacker(capacityInBytes: fsSizeInMB.mib()) rootfsMount = try await unpacker.unpack(image, for: imagePlatform, at: rootfsPath) } catch let err as ContainerizationError where err.code == .exists { rootfsMount = .block(