Skip to content

Commit 585fd8c

Browse files
Rename misleading blockSizeInBytes parameter to capacityInBytes in EXT4Unpacker (#789)
- Closes #787. - The `blockSizeInBytes` parameter on `EXT4Unpacker` was misleading — it does not represent an ext4 filesystem block size. - This change renames `blockSizeInBytes` to `capacityInBytes`, updates the doc comment to accurately describe the parameter and updates the name in the call sites.
1 parent 2a591c2 commit 585fd8c

7 files changed

Lines changed: 12 additions & 12 deletions

File tree

Sources/Containerization/ContainerManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public struct ContainerManager: Sendable {
342342

343343
private func unpack(image: Image, destination: URL, size: UInt64, progress: ProgressHandler? = nil) async throws -> Mount {
344344
do {
345-
let unpacker = EXT4Unpacker(blockSizeInBytes: size)
345+
let unpacker = EXT4Unpacker(capacityInBytes: size)
346346
return try await unpacker.unpack(image, for: .current, at: destination, progress: progress)
347347
} catch let err as ContainerizationError {
348348
if err.code == .exists {

Sources/Containerization/Image/InitImage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public struct InitImage: Sendable {
3434
extension InitImage {
3535
/// Unpack the initial filesystem for the desired platform at a given path.
3636
public func initBlock(at: URL, for platform: SystemPlatform) async throws -> Mount {
37-
let unpacker = EXT4Unpacker(blockSizeInBytes: 512.mib())
37+
let unpacker = EXT4Unpacker(capacityInBytes: 512.mib())
3838
var fs = try await unpacker.unpack(self.image, for: platform.ociPlatform(), at: at)
3939
fs.options = ["ro"]
4040
return fs

Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ import Foundation
2323
import SystemPackage
2424

2525
public struct EXT4Unpacker: Unpacker {
26-
let blockSizeInBytes: UInt64
26+
let capacityInBytes: UInt64
2727

2828
let journal: EXT4.JournalConfig?
2929

3030
/// Creates an unpacker that extracts images into EXT4 filesystems.
3131
/// - Parameters:
32-
/// - blockSizeInBytes: The filesystem block size.
32+
/// - capacityInBytes: The minimum usable capacity of the filesystem image, in bytes.
3333
/// - journal: The journal configuration to use, or nil for no journaling.
34-
public init(blockSizeInBytes: UInt64, journal: EXT4.JournalConfig? = nil) {
35-
self.blockSizeInBytes = blockSizeInBytes
34+
public init(capacityInBytes: UInt64, journal: EXT4.JournalConfig? = nil) {
35+
self.capacityInBytes = capacityInBytes
3636
self.journal = journal
3737
}
3838

@@ -49,7 +49,7 @@ public struct EXT4Unpacker: Unpacker {
4949
let cleanedPath = try prepareUnpackPath(path: path)
5050
let filesystem = try EXT4.Formatter(
5151
FilePath(cleanedPath),
52-
minDiskSize: blockSizeInBytes,
52+
minDiskSize: capacityInBytes,
5353
journal: journal
5454
)
5555
defer { try? filesystem.close() }
@@ -79,7 +79,7 @@ public struct EXT4Unpacker: Unpacker {
7979
FilePath(
8080
cleanedPath
8181
),
82-
minDiskSize: blockSizeInBytes
82+
minDiskSize: capacityInBytes
8383
)
8484
defer { try? filesystem.close() }
8585

Sources/Integration/Suite.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ struct IntegrationSuite: AsyncParsableCommand {
236236
let fsPath = Self.testDir.appending(component: image.digest)
237237
let fs = try await Self.unpackCoordinator.unpack(key: fsPath.absolutePath()) {
238238
do {
239-
let unpacker = EXT4Unpacker(blockSizeInBytes: 2.gib())
239+
let unpacker = EXT4Unpacker(capacityInBytes: 2.gib())
240240
return try await unpacker.unpack(image, for: platform, at: fsPath)
241241
} catch let err as ContainerizationError {
242242
if err.code == .exists {

Sources/cctl/ImageCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ extension Application {
146146
let unpackUrl = URL(filePath: unpackPath)
147147
try FileManager.default.createDirectory(at: unpackUrl, withIntermediateDirectories: true)
148148

149-
let unpacker = EXT4Unpacker.init(blockSizeInBytes: 2.gib())
149+
let unpacker = EXT4Unpacker.init(capacityInBytes: 2.gib())
150150

151151
startTime = ContinuousClock.now
152152
if let platform {

Sources/cctl/RootfsCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extension Application {
9595
}
9696

9797
private func outputExt4(archive: URL, to path: URL) async throws {
98-
let unpacker = EXT4Unpacker(blockSizeInBytes: 256.mib())
98+
let unpacker = EXT4Unpacker(capacityInBytes: 256.mib())
9999
try await unpacker.unpack(archive: archive, compression: .gzip, at: path)
100100
}
101101

Sources/cctl/RunCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ extension Application {
352352

353353
var rootfsMount: Containerization.Mount
354354
do {
355-
let unpacker = EXT4Unpacker(blockSizeInBytes: fsSizeInMB.mib())
355+
let unpacker = EXT4Unpacker(capacityInBytes: fsSizeInMB.mib())
356356
rootfsMount = try await unpacker.unpack(image, for: imagePlatform, at: rootfsPath)
357357
} catch let err as ContainerizationError where err.code == .exists {
358358
rootfsMount = .block(

0 commit comments

Comments
 (0)