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
8 changes: 4 additions & 4 deletions Sources/ContainerizationEXT4/EXT4+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ extension EXT4.XAttrEntry {
nameLength = bytes[0]
nameIndex = bytes[1]
let rawValue = Array(bytes[2...3])
valueOffset = UInt16(littleEndian: rawValue.withUnsafeBytes { $0.load(as: UInt16.self) })
valueOffset = rawValue.withUnsafeBytes { $0.loadLittleEndian(as: UInt16.self) }

let rawValueInum = Array(bytes[4...7])
valueInum = UInt32(littleEndian: rawValueInum.withUnsafeBytes { $0.load(as: UInt32.self) })
valueInum = rawValueInum.withUnsafeBytes { $0.loadLittleEndian(as: UInt32.self) }

let rawSize = Array(bytes[8...11])
valueSize = UInt32(littleEndian: rawSize.withUnsafeBytes { $0.load(as: UInt32.self) })
valueSize = rawSize.withUnsafeBytes { $0.loadLittleEndian(as: UInt32.self) }

let rawHash = Array(bytes[12...])
hash = UInt32(littleEndian: rawHash.withUnsafeBytes { $0.load(as: UInt32.self) })
hash = rawHash.withUnsafeBytes { $0.loadLittleEndian(as: UInt32.self) }
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/ContainerizationEXT4/EXT4+Reader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ extension EXT4 {
// When depth is 0 the extent header is followed by extent leaves
for _ in 0..<header.entries {
let leaf = inodeBlock.subdata(in: offset..<offset + extentLeafSize).withUnsafeBytes {
$0.load(as: ExtentLeaf.self)
$0.loadLittleEndian(as: ExtentLeaf.self)
}
extents.append((leaf.startLow, leaf.startLow + UInt32(leaf.length)))
offset += extentLeafSize
Expand All @@ -224,7 +224,7 @@ extension EXT4 {
// When depth is 1 the extent header is followed by extent indices which point to leaves
for _ in 0..<header.entries {
let indexNode = inodeBlock.subdata(in: offset..<offset + extentIndexSize).withUnsafeBytes {
$0.load(as: ExtentIndex.self)
$0.loadLittleEndian(as: ExtentIndex.self)
}
try self.seek(block: indexNode.leafLow)
guard let block = try self.handle.read(upToCount: Int(self.blockSize)) else {
Expand Down
4 changes: 2 additions & 2 deletions Sources/ContainerizationEXT4/EXT4+Xattrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension EXT4 {
var i = 0
while i + 3 < value.count {
let s = value[i..<i + 4]
let v = UInt32(littleEndian: s.withUnsafeBytes { $0.load(as: UInt32.self) })
let v = s.withUnsafeBytes { $0.loadLittleEndian(as: UInt32.self) }
hash = (hash << 16) ^ (hash >> 16) ^ v
i += 4
}
Expand All @@ -72,7 +72,7 @@ extension EXT4 {
for (i, byte) in value[last...].enumerated() {
buff[i] = byte
}
let v = UInt32(littleEndian: buff.withUnsafeBytes { $0.load(as: UInt32.self) })
let v = buff.withUnsafeBytes { $0.loadLittleEndian(as: UInt32.self) }
hash = (hash << 16) ^ (hash >> 16) ^ v
}
return hash
Expand Down
4 changes: 2 additions & 2 deletions Sources/ContainerizationEXT4/EXT4Reader+Export.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ extension EXT4.EXT4Reader {
}

public static func readInlineExtendedAttributes(from buffer: [UInt8]) throws -> [EXT4.ExtendedAttribute] {
let header = UInt32(littleEndian: buffer[0..<4].withUnsafeBytes { $0.load(as: UInt32.self) })
let header = buffer[0..<4].withUnsafeBytes { $0.loadLittleEndian(as: UInt32.self) }
if header != EXT4.XAttrHeaderMagic {
throw EXT4.FileXattrsState.Error.missingXAttrHeader
}
Expand All @@ -182,7 +182,7 @@ extension EXT4.EXT4Reader {
}

public static func readBlockExtendedAttributes(from buffer: [UInt8]) throws -> [EXT4.ExtendedAttribute] {
let header = UInt32(littleEndian: buffer[0..<4].withUnsafeBytes { $0.load(as: UInt32.self) })
let header = buffer[0..<4].withUnsafeBytes { $0.loadLittleEndian(as: UInt32.self) }
if header != EXT4.XAttrHeaderMagic {
throw EXT4.FileXattrsState.Error.missingXAttrHeader
}
Expand Down
Loading