Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Containerization/ContainerManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Containerization/Image/InitImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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() }
Expand Down Expand Up @@ -79,7 +79,7 @@ public struct EXT4Unpacker: Unpacker {
FilePath(
cleanedPath
),
minDiskSize: blockSizeInBytes
minDiskSize: capacityInBytes
)
defer { try? filesystem.close() }

Expand Down
2 changes: 1 addition & 1 deletion Sources/Integration/Suite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/cctl/ImageCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/cctl/RootfsCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/cctl/RunCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading