New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

balena-image-fs

Package Overview
Dependencies
Maintainers
0
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balena-image-fs - npm Package Compare versions

Comparing version 7.4.0-build-get-filesystem-label-7529f28d616619575443d6336a68be0a8fa9558c-1 to 7.4.0-build-get-filesystem-label-ad151fb7cb9fe5d4cb2aee572d6de21d3e854f71-1

45

build/fsLabel.js

@@ -67,5 +67,5 @@ "use strict";

// read until select filesystem.
let buf = Buffer.alloc(FS_METADATA_MAXLEN);
let labelOffset = 0;
let maxLength = 0;
const buf = Buffer.alloc(FS_METADATA_MAXLEN);
let labelOffset;
let maxLength;
// A filesystem places the label in a certain position in its metadata. So

@@ -78,7 +78,4 @@ // we must determine the type of filesystem. We first narrow the possibilities

const gptFatTypes = [GUID_EFI_SYSTEM, GUID_MS_BASIC_DATA];
let foundPartType = false;
let foundLabel = false;
if (isMbr && mbrFatTypes.some(ptype => partition.type === ptype)
|| isGpt && gptFatTypes.some(ptype => partition.type === ptype)) {
foundPartType = true;
if (isMbr && mbrFatTypes.includes(partition.type)
|| isGpt && gptFatTypes.includes(partition.type)) {
maxLength = FAT_LABEL_MAXLEN;

@@ -89,3 +86,2 @@ await disk.read(buf, 0, buf.length, partition.offset);

labelOffset = FAT16_LABEL_OFFSET;
foundLabel = true;
// FAT32

@@ -95,3 +91,2 @@ }

labelOffset = FAT32_LABEL_OFFSET;
foundLabel = true;
}

@@ -101,6 +96,4 @@ }

const gptLinuxTypes = [GUID_LINUX_NATIVE, GUID_MS_BASIC_DATA];
if (!foundLabel
&& ((isMbr && partition.type === PARTID_LINUX_NATIVE)
|| (isGpt && gptLinuxTypes.some(ptype => partition.type === ptype)))) {
foundPartType = true;
if (labelOffset == null && ((isMbr && partition.type === PARTID_LINUX_NATIVE)
|| (isGpt && gptLinuxTypes.includes(partition.type)))) {
maxLength = EXT4_LABEL_MAXLEN;

@@ -111,27 +104,25 @@ // ext2+; reload buffer within superblock

labelOffset = EXT4_LABEL_OFFSET;
foundLabel = true;
}
}
// Fail on unexpected partition/filesystem
if (!foundPartType) {
if (maxLength == null) {
throw new LabelNotFound(partition.index, 'unexpected partition type');
}
else if (!foundLabel) {
if (labelOffset == null) {
throw new LabelNotFound(partition.index, 'can\'t read filesystem');
}
// Exclude trailing /0 bytes to stringify.
let i = 0;
for (; i <= maxLength; i++) {
// If label fills available space, no need to test. We just need i
// to have the expected value for Buffer.toString() call below.
if (i == maxLength) {
let zeroBytePosition;
for (let i = 0; i < maxLength; i++) {
// Exclude trailing /0 bytes to stringify.
if (buf.readUInt8(labelOffset + i) === 0) {
zeroBytePosition = i;
break;
}
if (buf.readUInt8(labelOffset + i) == 0) {
break;
}
}
return buf.toString('utf8', labelOffset, labelOffset + i).trim();
// If label fills available space, no need to test. We just need zeroBytePosition
// to have the expected value for Buffer.toString() call below.
zeroBytePosition !== null && zeroBytePosition !== void 0 ? zeroBytePosition : (zeroBytePosition = maxLength);
return buf.toString('utf8', labelOffset, labelOffset + zeroBytePosition).trim();
}
exports.getFsLabel = getFsLabel;
//# sourceMappingURL=fsLabel.js.map

2

CHANGELOG.md

@@ -7,3 +7,3 @@ # Change Log

## 7.4.0 - 2025-01-18
## 7.4.0 - 2025-01-21

@@ -10,0 +10,0 @@ * Add getLabel() to retrieve filesystem label [Ken Bannister]

{
"name": "balena-image-fs",
"version": "7.4.0-build-get-filesystem-label-7529f28d616619575443d6336a68be0a8fa9558c-1",
"version": "7.4.0-build-get-filesystem-label-ad151fb7cb9fe5d4cb2aee572d6de21d3e854f71-1",
"description": "Image filesystem manipulation utilities",

@@ -62,4 +62,4 @@ "main": "build/index.js",

"versionist": {
"publishedAt": "2025-01-18T18:31:06.794Z"
"publishedAt": "2025-01-21T18:34:22.218Z"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc