wasm-posix-host
    Preparing search index...

    Class MemoryFileSystem

    Implements

    Index

    Accessors

    • get sharedBuffer(): SharedArrayBuffer

      Return the underlying SharedArrayBuffer (for sharing with workers).

      Returns SharedArrayBuffer

    Methods

    • Parameters

      • path: string
      • mode: number
      • uid: number
      • gid: number
      • content: Uint8Array

      Returns void

    • Materialize a full lazy archive group: fetch the zip once, parse its central directory, and write every non-deleted entry into its stub. Subsequent calls are no-ops.

      Parameters

      • group: LazyArchiveGroup
      • Optionalrequested: { generation: number; ino: number; path: string }

      Returns Promise<void>

    • Backward-compatible explicit preparation entrypoint.

      Parameters

      • path: string

      Returns Promise<boolean>

    • Export all pending lazy archive groups for transfer to another instance.

      Returns SerializedLazyArchiveEntry[]

    • Import lazy archive groups from another instance. Assumes stubs already exist.

      Parameters

      • serialized: SerializedLazyArchiveEntry[]

      Returns void

    • Import lazy file entries from another instance (e.g., main thread → worker). Does not create files — assumes the files already exist in the SharedArrayBuffer.

      Parameters

      Returns void

    • Authenticate sealed archive metadata before publishing it into this live filesystem. The caller must keep the underlying namespace quiescent while this asynchronous trust check runs.

      Parameters

      • serialized: SerializedLazyArchiveEntry[]

      Returns Promise<void>

    • Report whether path currently resolves to any deferred backing without starting I/O. This follows symlinks and covers both legacy lazy files and typed archive/tree registrations.

      Parameters

      • path: string

      Returns boolean

    • Materialize one exact typed tree authorized by this filesystem's opaque registration wrapper. Build-time composers use this to embed a reviewed package subset without re-pouring a smaller closure and thereby changing global path/conflict ownership.

      Parameters

      • handle: DeferredTreeMaterializationHandle
      • exactBytes: Uint8Array

      Returns Promise<boolean>

    • Parameters

      • path: string
      • mode: number
      • uid: number
      • gid: number

      Returns void

    • Resolve every tree whose capability policy requires bytes before boot. Registration/stat remain inert; callers choose the boot boundary and any failure aborts that boundary instead of exposing zero-byte stubs.

      Returns Promise<number>

    • Async-materialize a lazy file or archive-backed file if the given path resolves to one. Call this before any synchronous read (e.g. in handleExec) to avoid sync XHR which deadlocks with COOP/COEP. Returns true if something was materialized, false if already concrete.

      Parameters

      • path: string

      Returns Promise<boolean>

    • Parameters

      • handle: number
      • buffer: Uint8Array
      • offset: number | null
      • length: number

      Returns number

    • Copy this filesystem into a freshly formatted SharedFS whose superblock records maxByteLength as its growth ceiling. Lazy file/archive metadata is rebuilt from paths so the destination carries the new inode numbers.

      Parameters

      • maxByteLength: number

      Returns MemoryFileSystem

    • Register a lazy archive group: creates stubs in SharedFS for every file entry and records metadata so that accessing any one of them triggers a single archive fetch that materializes all files in the group.

      Parse the zip's central directory (via host/src/vfs/zip.ts) and pass the resulting ZipEntry[] in zipEntries. mountPrefix maps the zip's internal paths into the VFS (e.g. prefix "/usr/" turns "bin/vim" into "/usr/bin/vim").

      Parameters

      • url: string
      • zipEntries: ZipEntry[]
      • mountPrefix: string
      • OptionalsymlinkTargets: Map<string, string>
      • Optionalintegrity: LazyArchiveIntegrity

      Returns LazyArchiveGroup

    • Register a lazy file: creates an empty stub in SharedFS and records metadata for ensureMaterialized() to fetch asynchronously before a synchronous read or exec path consumes the file. Returns the inode number (useful for forwarding to other instances).

      Parameters

      • path: string
      • url: string
      • size: number
      • mode: number = 0o755

      Returns number

    • Register a format-neutral immutable filesystem tree. The complete inventory is validated before namespace mutation. One stub is created per inode group and hard-link names are attached to that same SharedFS inode.

      Parameters

      Returns LazyArchiveGroup

    • Register one typed tree and return only an opaque direct-materialization authority. The mutable internal group is deliberately not exposed.

      Parameters

      Returns DeferredTreeMaterializationHandle

    • Rewrite the URL of every registered lazy archive group. Useful when the VFS image was built with relative URLs (e.g. "vim.zip") and the runtime needs to resolve them against a deployment base URL.

      Parameters

      • transform: (url: string) => string

      Returns void

    • Rewrite the URL of every registered lazy file. Useful when a VFS image was built with placeholder URLs and the browser runtime needs to replace them with bundler-produced asset URLs.

      Parameters

      • transform: (url: string, path: string) => string

      Returns void

    • Save the current filesystem state as a portable binary image.

      With materializeAll: true, all lazy files are fetched and written into the filesystem before saving, producing a self-contained image. Otherwise, lazy file metadata (path/URL/size) is preserved in the image and restored on load.

      Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Finalize one exact multi-tree activation cohort.

      The caller supplies the producer-known member names so forgetting a tree cannot silently redefine the transaction. The resulting per-member and cohort digests are retained in every serialized tree record.

      Parameters

      • id: string
      • expectedMembersValue: readonly string[]

      Returns Promise<void>

    • Install the host-specific transport used for lazy file and archive URLs. Register a signal here rather than closing over one invisibly: Fetch rejects with AbortSignal.reason unchanged, which may otherwise look like a retryable TypeError or an ordinary mirror failure.

      Parameters

      Returns void

    • Parameters

      • target: string
      • path: string
      • uid: number
      • gid: number

      Returns void

    • Parameters

      • path: string
      • atimeSec: number
      • atimeNsec: number
      • mtimeSec: number
      • mtimeNsec: number

      Returns void

    • Cryptographically authenticate every pending sealed atomic cohort.

      Image restore validates the closed v3 structure synchronously, but its SHA-256 claims remain untrusted until an asynchronous host digest pass. Await this before a caller needs synchronous metadata inspection or filesystem rebasing. This check does not fetch or materialize deferred trees, snapshot the filesystem, export metadata, or rebase storage.

      Locally sealed cohorts are already authenticated; explicitly verifying them again is safe and idempotent.

      Returns Promise<void>

    • Parameters

      • handle: number
      • buffer: Uint8Array
      • offset: number | null
      • length: number

      Returns number

    • Validate an image's optional kernel ABI declaration. Images without a kernelAbi declaration are accepted so legacy/data-only images keep loading; callers that require an explicit declaration should check readImageMetadata(image)?.kernelAbi first.

      Parameters

      • image: Uint8Array
      • kernelAbi: number
      • label: string = "VFS image"

      Returns void

    • Restore a MemoryFileSystem from a previously saved VFS image. Allocates a new SharedArrayBuffer and populates it from the image.

      This low-level synchronous parser cannot authenticate imported v3 atomic seals. Normal imported-image consumers should await restoreVerifiedVfsImage() instead; private format code must explicitly await verifyImportedLazyAtomicGroupSeals() before it inspects, mutates, or boots the restored filesystem.

      When maxByteLength is specified, creates a growable SharedArrayBuffer so the filesystem can expand beyond the image's original size, up to the maximum already recorded in the image superblock.

      Parameters

      Returns MemoryFileSystem

    • Restore an image with the growth ceiling recorded in its SharedFS superblock. This is the low-level synchronous parser; imported v3 atomic seals remain unverified. Before inspecting, mutating, or booting imported state, use restoreVerifiedVfsImagePreservingCapacity() or explicitly await verifyImportedLazyAtomicGroupSeals().

      Use fromImage() when a caller intentionally supplies a different runtime ceiling.

      Parameters

      • image: Uint8Array

      Returns MemoryFileSystem