Skip to content

Commit

Permalink
Fixed imports in test workers
Browse files Browse the repository at this point in the history
Fixed exact inode size checks
Fixed attributes size
  • Loading branch information
james-pre committed Mar 4, 2025
1 parent 6d193a8 commit 318d313
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/backends/store/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ export class StoreFS<T extends Store = Store> 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;
}
Expand All @@ -621,7 +621,7 @@ export class StoreFS<T extends Store = Store> extends FileSystem {
continue;
}

if (inodeData.length != sizeof(Inode)) {
if (inodeData.length < sizeof(Inode)) {
warn(`Invalid inode size for ino ${ino}: ${inodeData.length}`);
continue;
}
Expand Down
13 changes: 11 additions & 2 deletions src/internal/inode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<Inode ${this.ino}>`;
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/config.worker.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion tests/backend/remote.worker.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down

0 comments on commit 318d313

Please sign in to comment.