Isolate filesystem qid counting to each v86 instance
This commit is contained in:
parent
8cb6f23248
commit
23080e2731
|
@ -44,14 +44,19 @@ var STATUS_FORWARDING = 0x5;
|
|||
/** @const */ var JSONFS_IDX_TARGET = 6;
|
||||
|
||||
|
||||
/** @constructor */
|
||||
function FS(baseurl) {
|
||||
/**
|
||||
* @constructor
|
||||
* @param {string=} baseurl
|
||||
* @param {{ last_qidnumber: number }=} qidcounter Another fs's qidcounter to synchronise with.
|
||||
*/
|
||||
function FS(baseurl, qidcounter) {
|
||||
/** @type {Array.<!Inode>} */
|
||||
this.inodes = [];
|
||||
this.events = [];
|
||||
|
||||
this.baseurl = baseurl;
|
||||
|
||||
this.qidcounter = qidcounter || { last_qidnumber: 0 };
|
||||
this.filesinloadingqueue = 0;
|
||||
this.OnLoaded = function() {};
|
||||
|
||||
|
@ -82,14 +87,12 @@ function FS(baseurl) {
|
|||
this.CreateDirectory("", -1);
|
||||
}
|
||||
|
||||
FS.last_qidnumber = 0;
|
||||
|
||||
FS.prototype.get_state = function()
|
||||
{
|
||||
const state = [];
|
||||
|
||||
state[0] = this.inodes;
|
||||
state[1] = FS.last_qidnumber;
|
||||
state[1] = this.qidcounter.last_qidnumber;
|
||||
state[2] = [];
|
||||
for(let entry of Object.entries(this.inodedata))
|
||||
{
|
||||
|
@ -106,7 +109,7 @@ FS.prototype.get_state = function()
|
|||
FS.prototype.set_state = function(state)
|
||||
{
|
||||
this.inodes = state[0].map(state => { const inode = new Inode(0); inode.set_state(state); return inode; });
|
||||
FS.last_qidnumber = state[1];
|
||||
this.qidcounter.last_qidnumber = state[1];
|
||||
this.inodedata = {};
|
||||
for(let [key, value] of state[2])
|
||||
{
|
||||
|
@ -126,6 +129,7 @@ FS.prototype.set_state = function(state)
|
|||
{
|
||||
const mount = new FSMountInfo(null);
|
||||
mount.set_state(mount_state);
|
||||
mount.fs.qidcounter = this.qidcounter;
|
||||
this.mounts.push(mount);
|
||||
}
|
||||
};
|
||||
|
@ -543,7 +547,7 @@ FS.prototype.divert = function(old_idx)
|
|||
FS.prototype.CreateInode = function() {
|
||||
//console.log("CreateInode", Error().stack);
|
||||
const now = Math.round(Date.now() / 1000);
|
||||
const inode = new Inode(++FS.last_qidnumber);
|
||||
const inode = new Inode(++this.qidcounter.last_qidnumber);
|
||||
inode.atime = inode.ctime = inode.mtime = now;
|
||||
return inode;
|
||||
};
|
||||
|
@ -1571,6 +1575,9 @@ FS.prototype.follow_fs = function(inode)
|
|||
*/
|
||||
FS.prototype.Mount = function(path, fs)
|
||||
{
|
||||
dbg_assert(fs.qidcounter === this.qidcounter,
|
||||
"Cannot mount filesystem whose qid numbers aren't synchronised with current filesystem.");
|
||||
|
||||
const path_infos = this.SearchPath(path);
|
||||
|
||||
if(path_infos.id === -1)
|
||||
|
|
|
@ -1081,7 +1081,7 @@ V86Starter.prototype.serial0_send = function(data)
|
|||
*/
|
||||
V86Starter.prototype.mount_fs = function(path, baseurl, basefs, callback)
|
||||
{
|
||||
const newfs = new FS(baseurl);
|
||||
const newfs = new FS(baseurl, this.fs9p.qidcounter);
|
||||
const mount = () =>
|
||||
{
|
||||
const idx = this.fs9p.Mount(path, newfs);
|
||||
|
|
Loading…
Reference in a new issue