From 04275e3f2fb9a4c7bc232e81be016c8ff44e0292 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Tue, 18 Feb 2025 15:24:38 +0100 Subject: [PATCH] added overlayfs --- com/isoterminal.js | 2 +- com/isoterminal/ISOTerminal.js | 12 ++---------- com/isoterminal/worker.js | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/com/isoterminal.js b/com/isoterminal.js index ff88f76..4ce8e95 100644 --- a/com/isoterminal.js +++ b/com/isoterminal.js @@ -14,7 +14,7 @@ * | property | type | default | info | * |------------------|-----------|------------------------|------| * | `iso` | `string` | https`//forgejo.isvery.ninja/assets/xrsh-buildroot/main/xrsh.iso" | | - * | `overlayfs` | `string` | *WORK-IN-PROGRESS* | | + * | `overlayfs` | `string` | '' | zip URL/file to autoextract on top of filesystem | * | `width` | `number` | 800 || * | `height` | `number` | 600 || * | `depth` | `number` | 0.03 || diff --git a/com/isoterminal/ISOTerminal.js b/com/isoterminal/ISOTerminal.js index ef2c83c..cd74ccf 100644 --- a/com/isoterminal/ISOTerminal.js +++ b/com/isoterminal/ISOTerminal.js @@ -141,6 +141,7 @@ ISOTerminal.prototype.start = function(opts){ // }, //screen_dummy: true, //disable_jit: false, + overlayfs: this.opts.overlayfs, filesystem: {}, autostart: true, prompt: this.opts.prompt, @@ -249,16 +250,6 @@ ISOTerminal.prototype.startVM = function(opts){ this.addEventListener('emulator-started', async (e) => { - // OVERLAY FS *FIXME* - //if( me.opts.overlayfs ){ - // fetch(me.opts.overlayfs) - // .then( (f) => { - // f.arrayBuffer().then( (buf) => { - // emulator.create_file('overlayfs.zip', new Uint8Array(buf) ) - // }) - // }) - //} - let line = '' this.ready = false @@ -287,6 +278,7 @@ ISOTerminal.prototype.bootISO = function(){ let msg = "\n\r" + msglib.empowermsg + msglib.text_color + msglib.loadmsg + msglib.text_reset this.emit('serial-output-string', msg) this.emit('runISO',{...this.v86opts, bufferLatency: this.opts.bufferLatency }) + } diff --git a/com/isoterminal/worker.js b/com/isoterminal/worker.js index 5c4c3c0..48494a0 100644 --- a/com/isoterminal/worker.js +++ b/com/isoterminal/worker.js @@ -1,7 +1,7 @@ importScripts("libv86.js"); importScripts("ISOTerminal.js") // we don't instance it again here (just use its functions) -this.runISO = function(opts){ +this.runISO = async function(opts){ this.opts = opts if( opts.debug ) console.dir(opts) @@ -66,9 +66,13 @@ this.runISO = function(opts){ }) } + + importScripts("feat/javascript.js") importScripts("feat/index.html.js") importScripts("feat/autorestore.js") + + if( opts.overlayfs ) await this.addOverlayFS(opts) } /* * forward events/functions so non-worker world can reach them @@ -94,3 +98,17 @@ this.onmessage = async function(e){ } } } + +this.addOverlayFS = async function(opts){ + return new Promise( (resolve,reject) => { + // OVERLAY FS *FIXME* + if( opts.overlayfs ){ + fetch(opts.overlayfs) + .then( (f) => { + f.arrayBuffer().then( (buf) => { + this.emulator.create_file('overlayfs.zip', new Uint8Array(buf) ) + }) + }) + } + }) +}