Skip to content

Commit

Permalink
added overlayfs
Browse files Browse the repository at this point in the history
  • Loading branch information
coderofsalvation committed Feb 18, 2025
1 parent aa5e684 commit 04275e3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion com/isoterminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
12 changes: 2 additions & 10 deletions com/isoterminal/ISOTerminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 })

}


Expand Down
20 changes: 19 additions & 1 deletion com/isoterminal/worker.js
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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) )
})
})
}
})
}

0 comments on commit 04275e3

Please sign in to comment.