From 318d3137e33564bea1b116d55f58eea6da4f3473 Mon Sep 17 00:00:00 2001 From: James Prevett Date: Tue, 4 Mar 2025 11:48:47 -0600 Subject: [PATCH] Fixed imports in test workers Fixed exact inode size checks Fixed attributes size --- src/backends/store/fs.ts | 4 ++-- src/internal/inode.ts | 13 +++++++++++-- tests/backend/config.worker.js | 2 +- tests/backend/remote.worker.js | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/backends/store/fs.ts b/src/backends/store/fs.ts index 4311d662..5b427a0e 100644 --- a/src/backends/store/fs.ts +++ b/src/backends/store/fs.ts @@ -595,7 +595,7 @@ export class StoreFS extends FileSystem { return; } - if (rootData.length != sizeof(Inode)) { + if (rootData.length < sizeof(Inode)) { crit('Store contains an invalid root inode. Refusing to populate tables'); return; } @@ -621,7 +621,7 @@ export class StoreFS extends FileSystem { continue; } - if (inodeData.length != sizeof(Inode)) { + if (inodeData.length < sizeof(Inode)) { warn(`Invalid inode size for ino ${ino}: ${inodeData.length}`); continue; } diff --git a/src/internal/inode.ts b/src/internal/inode.ts index a6db7a44..97a741cb 100644 --- a/src/internal/inode.ts +++ b/src/internal/inode.ts @@ -99,12 +99,21 @@ export class Inode implements InodeLike { /** For future use */ @t.uint16 protected __after_flags: number = 0; - @t.uint32 public attributes_size: number = 0; + @t.uint32 public attributes_size: number = 2; /** Pad to 128 bytes */ @t.uint8(52) protected __padding = []; - public attributes: Attributes = {}; + protected _attributes: Attributes = {}; + + public get attributes(): Attributes { + return this._attributes; + } + + public set attributes(value: Attributes) { + this._attributes = value; + this.attributes_size = encodeUTF8(JSON.stringify(this.attributes)).byteLength; + } public toString(): string { return ``; diff --git a/tests/backend/config.worker.js b/tests/backend/config.worker.js index a87b407c..943f4451 100644 --- a/tests/backend/config.worker.js +++ b/tests/backend/config.worker.js @@ -1,5 +1,5 @@ import { parentPort } from 'node:worker_threads'; -import { resolveRemoteMount } from '../../dist/backends/port/fs.js'; +import { resolveRemoteMount } from '../../dist/backends/port.js'; import { InMemory } from '../../dist/backends/memory.js'; import { setupLogs } from '../logs.js'; diff --git a/tests/backend/remote.worker.js b/tests/backend/remote.worker.js index b776e739..be63d0f6 100644 --- a/tests/backend/remote.worker.js +++ b/tests/backend/remote.worker.js @@ -1,5 +1,5 @@ import { parentPort } from 'node:worker_threads'; -import { attachFS } from '../../dist/backends/port/fs.js'; +import { attachFS } from '../../dist/backends/port.js'; import { mounts } from '../../dist/index.js'; import { setupLogs } from '../logs.js';