/** * VFSFS — Custom Emscripten filesystem backed by the kernel VFS. * * Implements Emscripten's low-level FS type interface (`mount`, `createNode`, * `node_ops`, `stream_ops`) so it can be registered as a proper FS mount. * * This replaces the old proxy approach (lookupPath patching) which was broken * because Emscripten's internal `lookupNode` (used by `__syscall_getdents64`) * bypassed lookupPath. * * Architecture: * - Backed by a JS object store (`fileData: Map`) for * file content. This store is populated on-demand by the Asyncify hooks * (onPreOpen, onPreStat, onPreAccess) installed on the Module. File data * is fetched from IDB/CDN — no persistent in-memory cache is used. * - Directory structure + stat metadata come from the kernel VFS * (LazyFS manifest + IDBFS write layer). * - Write-through: writes update both the local store and the kernel VFS. * * Asyncify integration: * The Emscripten glue code's ASYNCIFY_IMPORTS list includes the FS * syscalls (___syscall_openat, etc.) which call Module["onPreOpen"](path) / * Module["onPreStat"](path) BEFORE the actual syscall. These async hooks * fetch the file from the kernel VFS (IDB → CDN fallback) and populate * our `fileData` map. Asyncify suspends/resumes the WASM stack while the * fetch is in flight. By the time the real syscall runs, the data is * available synchronously. * * Usage: call `mountVFSFS(FS, vfs, mountPoints)` after WASM instantiation * but before callMain(). */ import type { VFSManager } from './index.js'; export interface VFSFSRuntime { HEAP8?: Int8Array; HEAPU8?: Uint8Array; _malloc?: (size: number) => number; } export interface MountVFSFSOptions { /** Mount points to create and mount VFSFS at (e.g. ['/usr', '/etc', '/home', '/tmp']) */ mountPoints: string[]; /** Path aliases for sysroot cache mapping */ pathAliases?: Map; /** Access to the module's linear memory for mmap/msync support. */ runtime?: VFSFSRuntime; } /** * Mount VFSFS at the given mount points and install Asyncify hooks on the Module. * * Call after WASM instantiation but before callMain(). * * @returns Object with fileData map and protectedPaths set */ export declare function mountVFSFS(FS: any, moduleConfig: Record, vfs: VFSManager, options: MountVFSFSOptions): { fileData: Map; protectedPaths: Set; }; //# sourceMappingURL=emscripten-vfsfs.d.ts.map