mirror of
https://github.com/apple/container.git
synced 2026-10-13 09:39:18 +00:00
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.
This commit is contained in:
1 parent
2a591c2aee
commit
585fd8cfd2
7 files changed
+12
-12
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() }
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user