mirror of
https://github.com/copy/v86.git
synced 2025-12-31 04:23:15 +00:00
replace jor1k's message.Debug with dbg_log
This commit is contained in:
parent
c11805a70a
commit
47f0bf533c
5 changed files with 54 additions and 143 deletions
2
Makefile
2
Makefile
|
|
@ -84,7 +84,7 @@ CORE_FILES=cjs.js const.js config.js io.js main.js lib.js buffer.js ide.js pci.j
|
|||
state.js ne2k.js sb16.js virtio.js virtio_console.js virtio_net.js virtio_balloon.js \
|
||||
bus.js log.js cpu.js debug.js \
|
||||
elf.js kernel.js
|
||||
LIB_FILES=9p.js filesystem.js jor1k.js marshall.js
|
||||
LIB_FILES=9p.js filesystem.js marshall.js
|
||||
BROWSER_FILES=screen.js keyboard.js mouse.js speaker.js serial.js \
|
||||
network.js starter.js worker_bus.js dummy_screen.js \
|
||||
inbrowser_network.js fake_network.js wisp_network.js fetch_network.js \
|
||||
|
|
|
|||
74
lib/9p.js
74
lib/9p.js
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
import { LOG_9P } from "./../src/const.js";
|
||||
import { VirtIO, VIRTIO_F_VERSION_1, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_RING_INDIRECT_DESC } from "../src/virtio.js";
|
||||
import { S_IFREG, S_IFDIR, STATUS_UNLINKED } from "./filesystem.js";
|
||||
import { hex8, message } from "./jor1k.js";
|
||||
import * as marshall from "../lib/marshall.js";
|
||||
import { range } from "../src/lib.js";
|
||||
import { dbg_assert } from "../src/log.js";
|
||||
|
||||
import { dbg_log, dbg_assert } from "../src/log.js";
|
||||
import { h } from "../src/lib.js";
|
||||
|
||||
// For Types Only
|
||||
import { CPU } from "../src/cpu.js";
|
||||
|
|
@ -251,7 +251,7 @@ Virtio9p.prototype.BuildReply = function(id, tag, payloadsize) {
|
|||
dbg_assert(payloadsize >= 0, "9P: Negative payload size");
|
||||
marshall.Marshall(["w", "b", "h"], [payloadsize+7, id+1, tag], this.replybuffer, 0);
|
||||
if((payloadsize+7) >= this.replybuffer.length) {
|
||||
message.Debug("Error in 9p: payloadsize exceeds maximum length");
|
||||
dbg_log("Error in 9p: payloadsize exceeds maximum length", LOG_9P);
|
||||
}
|
||||
//for(var i=0; i<payload.length; i++)
|
||||
// this.replybuffer[7+i] = payload[i];
|
||||
|
|
@ -281,7 +281,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var size = header[0];
|
||||
var id = header[1];
|
||||
var tag = header[2];
|
||||
//message.Debug("size:" + size + " id:" + id + " tag:" + tag);
|
||||
//dbg_log("size:" + size + " id:" + id + " tag:" + tag, LOG_9P);
|
||||
|
||||
switch(id)
|
||||
{
|
||||
|
|
@ -309,16 +309,16 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var req = marshall.Unmarshall(["w", "w"], buffer, state);
|
||||
var fid = req[0];
|
||||
var mode = req[1];
|
||||
message.Debug("[open] fid=" + fid + ", mode=" + mode);
|
||||
dbg_log("[open] fid=" + fid + ", mode=" + mode, LOG_9P);
|
||||
var idx = this.fids[fid].inodeid;
|
||||
var inode = this.fs.GetInode(idx);
|
||||
message.Debug("file open " + this.fids[fid].dbg_name);
|
||||
dbg_log("file open " + this.fids[fid].dbg_name, LOG_9P);
|
||||
//if (inode.status === STATUS_LOADING) return;
|
||||
var ret = this.fs.OpenInode(idx, mode);
|
||||
|
||||
this.fs.AddEvent(this.fids[fid].inodeid,
|
||||
function() {
|
||||
message.Debug("file opened " + this.fids[fid].dbg_name + " tag:"+tag);
|
||||
dbg_log("file opened " + this.fids[fid].dbg_name + " tag:"+tag, LOG_9P);
|
||||
var req = [];
|
||||
req[0] = inode.qid;
|
||||
req[1] = this.msize - 24;
|
||||
|
|
@ -334,7 +334,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var dfid = req[0];
|
||||
var fid = req[1];
|
||||
var name = req[2];
|
||||
message.Debug("[link] dfid=" + dfid + ", name=" + name);
|
||||
dbg_log("[link] dfid=" + dfid + ", name=" + name, LOG_9P);
|
||||
|
||||
var ret = this.fs.Link(this.fids[dfid].inodeid, this.fids[fid].inodeid, name);
|
||||
|
||||
|
|
@ -362,7 +362,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var name = req[1];
|
||||
var symgt = req[2];
|
||||
var gid = req[3];
|
||||
message.Debug("[symlink] fid=" + fid + ", name=" + name + ", symgt=" + symgt + ", gid=" + gid);
|
||||
dbg_log("[symlink] fid=" + fid + ", name=" + name + ", symgt=" + symgt + ", gid=" + gid, LOG_9P);
|
||||
var idx = this.fs.CreateSymlink(name, this.fids[fid].inodeid, symgt);
|
||||
var inode = this.fs.GetInode(idx);
|
||||
inode.uid = this.fids[fid].uid;
|
||||
|
|
@ -380,7 +380,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var major = req[3];
|
||||
var minor = req[4];
|
||||
var gid = req[5];
|
||||
message.Debug("[mknod] fid=" + fid + ", name=" + name + ", major=" + major + ", minor=" + minor+ "");
|
||||
dbg_log("[mknod] fid=" + fid + ", name=" + name + ", major=" + major + ", minor=" + minor+ "", LOG_9P);
|
||||
var idx = this.fs.CreateNode(name, this.fids[fid].inodeid, major, minor);
|
||||
var inode = this.fs.GetInode(idx);
|
||||
inode.mode = mode;
|
||||
|
|
@ -397,7 +397,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var req = marshall.Unmarshall(["w"], buffer, state);
|
||||
var fid = req[0];
|
||||
var inode = this.fs.GetInode(this.fids[fid].inodeid);
|
||||
message.Debug("[readlink] fid=" + fid + " name=" + this.fids[fid].dbg_name + " target=" + inode.symlink);
|
||||
dbg_log("[readlink] fid=" + fid + " name=" + this.fids[fid].dbg_name + " target=" + inode.symlink, LOG_9P);
|
||||
size = marshall.Marshall(["s"], [inode.symlink], this.replybuffer, 7);
|
||||
this.BuildReply(id, tag, size);
|
||||
this.SendReply(bufchain);
|
||||
|
|
@ -410,7 +410,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var name = req[1];
|
||||
var mode = req[2];
|
||||
var gid = req[3];
|
||||
message.Debug("[mkdir] fid=" + fid + ", name=" + name + ", mode=" + mode + ", gid=" + gid);
|
||||
dbg_log("[mkdir] fid=" + fid + ", name=" + name + ", mode=" + mode + ", gid=" + gid, LOG_9P);
|
||||
var idx = this.fs.CreateDirectory(name, this.fids[fid].inodeid);
|
||||
var inode = this.fs.GetInode(idx);
|
||||
inode.mode = mode | S_IFDIR;
|
||||
|
|
@ -429,7 +429,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var mode = req[3];
|
||||
var gid = req[4];
|
||||
this.bus.send("9p-create", [name, this.fids[fid].inodeid]);
|
||||
message.Debug("[create] fid=" + fid + ", name=" + name + ", flags=" + flags + ", mode=" + mode + ", gid=" + gid);
|
||||
dbg_log("[create] fid=" + fid + ", name=" + name + ", flags=" + flags + ", mode=" + mode + ", gid=" + gid, LOG_9P);
|
||||
var idx = this.fs.CreateFile(name, this.fids[fid].inodeid);
|
||||
this.fids[fid].inodeid = idx;
|
||||
this.fids[fid].type = FID_INODE;
|
||||
|
|
@ -449,7 +449,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var flags = req[2];
|
||||
var lock_length = req[4] === 0 ? Infinity : req[4];
|
||||
var lock_request = this.fs.DescribeLock(req[1], req[3], lock_length, req[5], req[6]);
|
||||
message.Debug("[lock] fid=" + fid +
|
||||
dbg_log("[lock] fid=" + fid +
|
||||
", type=" + P9_LOCK_TYPES[lock_request.type] + ", start=" + lock_request.start +
|
||||
", length=" + lock_request.length + ", proc_id=" + lock_request.proc_id);
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var fid = req[0];
|
||||
var lock_length = req[3] === 0 ? Infinity : req[3];
|
||||
var lock_request = this.fs.DescribeLock(req[1], req[2], lock_length, req[4], req[5]);
|
||||
message.Debug("[getlock] fid=" + fid +
|
||||
dbg_log("[getlock] fid=" + fid +
|
||||
", type=" + P9_LOCK_TYPES[lock_request.type] + ", start=" + lock_request.start +
|
||||
", length=" + lock_request.length + ", proc_id=" + lock_request.proc_id);
|
||||
|
||||
|
|
@ -491,10 +491,10 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var req = marshall.Unmarshall(["w", "d"], buffer, state);
|
||||
var fid = req[0];
|
||||
var inode = this.fs.GetInode(this.fids[fid].inodeid);
|
||||
message.Debug("[getattr]: fid=" + fid + " name=" + this.fids[fid].dbg_name + " request mask=" + req[1]);
|
||||
dbg_log("[getattr]: fid=" + fid + " name=" + this.fids[fid].dbg_name + " request mask=" + req[1], LOG_9P);
|
||||
if(!inode || inode.status === STATUS_UNLINKED)
|
||||
{
|
||||
message.Debug("getattr: unlinked");
|
||||
dbg_log("getattr: unlinked", LOG_9P);
|
||||
this.SendError(tag, "No such file or directory", ENOENT);
|
||||
this.SendReply(bufchain);
|
||||
break;
|
||||
|
|
@ -547,7 +547,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
], buffer, state);
|
||||
var fid = req[0];
|
||||
var inode = this.fs.GetInode(this.fids[fid].inodeid);
|
||||
message.Debug("[setattr]: fid=" + fid + " request mask=" + req[1] + " name=" + this.fids[fid].dbg_name);
|
||||
dbg_log("[setattr]: fid=" + fid + " request mask=" + req[1] + " name=" + this.fids[fid].dbg_name, LOG_9P);
|
||||
if(req[1] & P9_SETATTR_MODE) {
|
||||
// XXX: check mode (S_IFREG or S_IFDIR or similar should be set)
|
||||
inode.mode = req[2];
|
||||
|
|
@ -594,11 +594,11 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var offset = req[1];
|
||||
var count = req[2];
|
||||
var inode = this.fs.GetInode(this.fids[fid].inodeid);
|
||||
if(id === 40) message.Debug("[treaddir]: fid=" + fid + " offset=" + offset + " count=" + count);
|
||||
if(id === 116) message.Debug("[read]: fid=" + fid + " (" + this.fids[fid].dbg_name + ") offset=" + offset + " count=" + count + " fidtype=" + this.fids[fid].type);
|
||||
if(id === 40) dbg_log("[treaddir]: fid=" + fid + " offset=" + offset + " count=" + count, LOG_9P);
|
||||
if(id === 116) dbg_log("[read]: fid=" + fid + " (" + this.fids[fid].dbg_name + ") offset=" + offset + " count=" + count + " fidtype=" + this.fids[fid].type, LOG_9P);
|
||||
if(!inode || inode.status === STATUS_UNLINKED)
|
||||
{
|
||||
message.Debug("read/treaddir: unlinked");
|
||||
dbg_log("read/treaddir: unlinked", LOG_9P);
|
||||
this.SendError(tag, "No such file or directory", ENOENT);
|
||||
this.SendReply(bufchain);
|
||||
break;
|
||||
|
|
@ -652,7 +652,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
|
||||
const filename = this.fids[fid].dbg_name;
|
||||
|
||||
message.Debug("[write]: fid=" + fid + " (" + filename + ") offset=" + offset + " count=" + count + " fidtype=" + this.fids[fid].type);
|
||||
dbg_log("[write]: fid=" + fid + " (" + filename + ") offset=" + offset + " count=" + count + " fidtype=" + this.fids[fid].type, LOG_9P);
|
||||
if(this.fids[fid].type === FID_XATTR)
|
||||
{
|
||||
// XXX: xattr not supported yet. Ignore write.
|
||||
|
|
@ -679,7 +679,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var oldname = req[1];
|
||||
var newdirfid = req[2];
|
||||
var newname = req[3];
|
||||
message.Debug("[renameat]: oldname=" + oldname + " newname=" + newname);
|
||||
dbg_log("[renameat]: oldname=" + oldname + " newname=" + newname, LOG_9P);
|
||||
var ret = await this.fs.Rename(this.fids[olddirfid].inodeid, oldname, this.fids[newdirfid].inodeid, newname);
|
||||
if(ret < 0) {
|
||||
let error_message = "";
|
||||
|
|
@ -709,7 +709,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var dirfd = req[0];
|
||||
var name = req[1];
|
||||
var flags = req[2];
|
||||
message.Debug("[unlink]: dirfd=" + dirfd + " name=" + name + " flags=" + flags);
|
||||
dbg_log("[unlink]: dirfd=" + dirfd + " name=" + name + " flags=" + flags, LOG_9P);
|
||||
var fid = this.fs.Search(this.fids[dirfd].inodeid, name);
|
||||
if(fid === -1) {
|
||||
this.SendError(tag, "No such file or directory", ENOENT);
|
||||
|
|
@ -736,7 +736,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
|
||||
case 100: // version
|
||||
var version = marshall.Unmarshall(["w", "s"], buffer, state);
|
||||
message.Debug("[version]: msize=" + version[0] + " version=" + version[1]);
|
||||
dbg_log("[version]: msize=" + version[0] + " version=" + version[1], LOG_9P);
|
||||
if(this.msize !== version[0])
|
||||
{
|
||||
this.msize = version[0];
|
||||
|
|
@ -752,7 +752,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var req = marshall.Unmarshall(["w", "w", "s", "s", "w"], buffer, state);
|
||||
var fid = req[0];
|
||||
var uid = req[4];
|
||||
message.Debug("[attach]: fid=" + fid + " afid=" + hex8(req[1]) + " uname=" + req[2] + " aname=" + req[3]);
|
||||
dbg_log("[attach]: fid=" + fid + " afid=" + h(req[1]) + " uname=" + req[2] + " aname=" + req[3], LOG_9P);
|
||||
this.fids[fid] = this.Createfid(0, FID_INODE, uid, "");
|
||||
var inode = this.fs.GetInode(this.fids[fid].inodeid);
|
||||
marshall.Marshall(["Q"], [inode.qid], this.replybuffer, 7);
|
||||
|
|
@ -764,7 +764,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
case 108: // tflush
|
||||
var req = marshall.Unmarshall(["h"], buffer, state);
|
||||
var oldtag = req[0];
|
||||
message.Debug("[flush] " + tag);
|
||||
dbg_log("[flush] " + tag, LOG_9P);
|
||||
//marshall.Marshall(["Q"], [inode.qid], this.replybuffer, 7);
|
||||
this.BuildReply(id, tag, 0);
|
||||
this.SendReply(bufchain);
|
||||
|
|
@ -776,7 +776,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var fid = req[0];
|
||||
var nwfid = req[1];
|
||||
var nwname = req[2];
|
||||
message.Debug("[walk]: fid=" + req[0] + " nwfid=" + req[1] + " nwname=" + nwname);
|
||||
dbg_log("[walk]: fid=" + req[0] + " nwfid=" + req[1] + " nwname=" + nwname, LOG_9P);
|
||||
if(nwname === 0) {
|
||||
this.fids[nwfid] = this.Createfid(this.fids[fid].inodeid, FID_INODE, this.fids[fid].uid, this.fids[fid].dbg_name);
|
||||
//this.fids[nwfid].inodeid = this.fids[fid].inodeid;
|
||||
|
|
@ -794,17 +794,17 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var offset = 7+2;
|
||||
var nwidx = 0;
|
||||
//console.log(idx, this.fs.GetInode(idx));
|
||||
message.Debug("walk in dir " + this.fids[fid].dbg_name + " to: " + walk.toString());
|
||||
dbg_log("walk in dir " + this.fids[fid].dbg_name + " to: " + walk.toString(), LOG_9P);
|
||||
for(var i=0; i<nwname; i++) {
|
||||
idx = this.fs.Search(idx, walk[i]);
|
||||
|
||||
if(idx === -1) {
|
||||
message.Debug("Could not find: " + walk[i]);
|
||||
dbg_log("Could not find: " + walk[i], LOG_9P);
|
||||
break;
|
||||
}
|
||||
offset += marshall.Marshall(["Q"], [this.fs.GetInode(idx).qid], this.replybuffer, offset);
|
||||
nwidx++;
|
||||
//message.Debug(this.fids[nwfid].inodeid);
|
||||
//dbg_log(this.fids[nwfid].inodeid, LOG_9P);
|
||||
//this.fids[nwfid].inodeid = idx;
|
||||
//this.fids[nwfid].type = FID_INODE;
|
||||
this.fids[nwfid] = this.Createfid(idx, FID_INODE, this.fids[fid].uid, walk[i]);
|
||||
|
|
@ -816,7 +816,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
|
||||
case 120: // clunk
|
||||
var req = marshall.Unmarshall(["w"], buffer, state);
|
||||
message.Debug("[clunk]: fid=" + req[0]);
|
||||
dbg_log("[clunk]: fid=" + req[0], LOG_9P);
|
||||
if(this.fids[req[0]] && this.fids[req[0]].inodeid >= 0) {
|
||||
await this.fs.CloseInode(this.fids[req[0]].inodeid);
|
||||
this.fids[req[0]].inodeid = -1;
|
||||
|
|
@ -832,7 +832,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var name = req[1];
|
||||
var attr_size = req[2];
|
||||
var flags = req[3];
|
||||
message.Debug("[txattrcreate]: fid=" + fid + " name=" + name + " attr_size=" + attr_size + " flags=" + flags);
|
||||
dbg_log("[txattrcreate]: fid=" + fid + " name=" + name + " attr_size=" + attr_size + " flags=" + flags, LOG_9P);
|
||||
|
||||
// XXX: xattr not supported yet. E.g. checks corresponding to the flags needed.
|
||||
this.fids[fid].type = FID_XATTR;
|
||||
|
|
@ -848,7 +848,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
var fid = req[0];
|
||||
var newfid = req[1];
|
||||
var name = req[2];
|
||||
message.Debug("[xattrwalk]: fid=" + req[0] + " newfid=" + req[1] + " name=" + req[2]);
|
||||
dbg_log("[xattrwalk]: fid=" + req[0] + " newfid=" + req[1] + " name=" + req[2], LOG_9P);
|
||||
|
||||
// Workaround for Linux restarts writes until full blocksize
|
||||
this.SendError(tag, "Setxattr not supported", EOPNOTSUPP);
|
||||
|
|
@ -869,8 +869,8 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
|
|||
break;
|
||||
|
||||
default:
|
||||
message.Debug("Error in Virtio9p: Unknown id " + id + " received");
|
||||
message.Abort();
|
||||
dbg_log("Error in Virtio9p: Unknown id " + id + " received", LOG_9P);
|
||||
dbg_assert(false);
|
||||
//this.SendError(tag, "Operation i not supported", EOPNOTSUPP);
|
||||
//this.SendReply(bufchain);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import { LOG_9P } from "../src/const.js";
|
|||
import { h } from "../src/lib.js";
|
||||
import { dbg_assert, dbg_log } from "../src/log.js";
|
||||
import * as marshall from "../lib/marshall.js";
|
||||
import { message } from "./jor1k.js";
|
||||
import { EEXIST, ENOTEMPTY, ENOENT, EPERM } from "./9p.js";
|
||||
import { P9_LOCK_SUCCESS, P9_LOCK_BLOCKED, P9_LOCK_TYPE_UNLCK, P9_LOCK_TYPE_WRLCK, P9_LOCK_TYPE_RDLCK } from "./9p.js";
|
||||
|
||||
|
|
@ -162,7 +161,7 @@ FS.prototype.HandleEvent = function(id) {
|
|||
{
|
||||
this.follow_fs(inode).HandleEvent(inode.foreign_id);
|
||||
}
|
||||
//message.Debug("number of events: " + this.events.length);
|
||||
//dbg_log("number of events: " + this.events.length, LOG_9P);
|
||||
var newevents = [];
|
||||
for(var i=0; i<this.events.length; i++) {
|
||||
if(this.events[i].id === id) {
|
||||
|
|
@ -235,7 +234,7 @@ FS.prototype.LoadRecursive = function(data, parentid)
|
|||
}
|
||||
else
|
||||
{
|
||||
dbg_log("Unexpected ifmt: " + h(ifmt) + " (" + name + ")");
|
||||
dbg_log("Unexpected ifmt: " + h(ifmt) + " (" + name + ")", LOG_9P);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -351,9 +350,7 @@ FS.prototype.PushInode = function(inode, parentid, name) {
|
|||
}
|
||||
}
|
||||
|
||||
message.Debug("Error in Filesystem: Pushed inode with name = "+ name + " has no parent");
|
||||
message.Abort();
|
||||
|
||||
dbg_assert(false, "Error in Filesystem: Pushed inode with name = "+ name + " has no parent");
|
||||
};
|
||||
|
||||
/** @constructor */
|
||||
|
|
@ -718,12 +715,12 @@ FS.prototype.OpenInode = function(id, mode) {
|
|||
case S_IFCHR: type = "Character Device"; break;
|
||||
}
|
||||
*/
|
||||
//message.Debug("open:" + this.GetFullPath(id) + " type: " + inode.mode + " status:" + inode.status);
|
||||
//dbg_log("open:" + this.GetFullPath(id) + " type: " + inode.mode + " status:" + inode.status, LOG_9P);
|
||||
return true;
|
||||
};
|
||||
|
||||
FS.prototype.CloseInode = async function(id) {
|
||||
//message.Debug("close: " + this.GetFullPath(id));
|
||||
//dbg_log("close: " + this.GetFullPath(id), LOG_9P);
|
||||
var inode = this.inodes[id];
|
||||
if(this.is_forwarder(inode))
|
||||
{
|
||||
|
|
@ -734,7 +731,7 @@ FS.prototype.CloseInode = async function(id) {
|
|||
this.storage.uncache(inode.sha256sum);
|
||||
}
|
||||
if(inode.status === STATUS_UNLINKED) {
|
||||
//message.Debug("Filesystem: Delete unlinked file");
|
||||
//dbg_log("Filesystem: Delete unlinked file", LOG_9P);
|
||||
inode.status = STATUS_INVALID;
|
||||
await this.DeleteData(id);
|
||||
}
|
||||
|
|
@ -744,7 +741,7 @@ FS.prototype.CloseInode = async function(id) {
|
|||
* @return {!Promise<number>} 0 if success, or -errno if failured.
|
||||
*/
|
||||
FS.prototype.Rename = async function(olddirid, oldname, newdirid, newname) {
|
||||
// message.Debug("Rename " + oldname + " to " + newname);
|
||||
// dbg_log("Rename " + oldname + " to " + newname, LOG_9P);
|
||||
if((olddirid === newdirid) && (oldname === newname)) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1048,7 +1045,7 @@ FS.prototype.Unlink = function(parentid, name) {
|
|||
const idx = this.Search(parentid, name);
|
||||
const inode = this.inodes[idx];
|
||||
const parent_inode = this.inodes[parentid];
|
||||
//message.Debug("Unlink " + inode.name);
|
||||
//dbg_log("Unlink " + inode.name, LOG_9P);
|
||||
|
||||
// forward if necessary
|
||||
if(this.is_forwarder(parent_inode))
|
||||
|
|
@ -1181,7 +1178,7 @@ FS.prototype.ChangeSize = async function(idx, newsize)
|
|||
{
|
||||
var inode = this.GetInode(idx);
|
||||
var temp = await this.get_data(idx, 0, inode.size);
|
||||
//message.Debug("change size to: " + newsize);
|
||||
//dbg_log("change size to: " + newsize, LOG_9P);
|
||||
if(newsize === inode.size) return;
|
||||
var data = new Uint8Array(newsize);
|
||||
inode.size = newsize;
|
||||
|
|
@ -1308,24 +1305,24 @@ FS.prototype.Check = function() {
|
|||
|
||||
var inode = this.GetInode(i);
|
||||
if(inode.nlinks < 0) {
|
||||
message.Debug("Error in filesystem: negative nlinks=" + inode.nlinks + " at id =" + i);
|
||||
dbg_log("Error in filesystem: negative nlinks=" + inode.nlinks + " at id =" + i, LOG_9P);
|
||||
}
|
||||
|
||||
if(this.IsDirectory(i))
|
||||
{
|
||||
const inode = this.GetInode(i);
|
||||
if(this.IsDirectory(i) && this.GetParent(i) < 0) {
|
||||
message.Debug("Error in filesystem: negative parent id " + i);
|
||||
dbg_log("Error in filesystem: negative parent id " + i, LOG_9P);
|
||||
}
|
||||
for(const [name, id] of inode.direntries)
|
||||
{
|
||||
if(name.length === 0) {
|
||||
message.Debug("Error in filesystem: inode with no name and id " + id);
|
||||
dbg_log("Error in filesystem: inode with no name and id " + id, LOG_9P);
|
||||
}
|
||||
|
||||
for(const c of name) {
|
||||
if(c < 32) {
|
||||
message.Debug("Error in filesystem: Unallowed char in filename");
|
||||
dbg_log("Error in filesystem: Unallowed char in filename", LOG_9P);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
85
lib/jor1k.js
85
lib/jor1k.js
|
|
@ -1,85 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
import { LOG_9P } from "../src/const.js";
|
||||
import { h } from "../src/lib.js";
|
||||
import { dbg_log } from "../src/log.js";
|
||||
|
||||
|
||||
// jor1k compatibility
|
||||
|
||||
export function hex8(n)
|
||||
{
|
||||
return h(n);
|
||||
}
|
||||
|
||||
export var message = {};
|
||||
|
||||
/** @param {...string} log */
|
||||
message.Debug = function(log)
|
||||
{
|
||||
dbg_log([].slice.apply(arguments).join(" "), LOG_9P);
|
||||
};
|
||||
|
||||
message.Abort = function()
|
||||
{
|
||||
if(DEBUG)
|
||||
{
|
||||
throw new Error("message.Abort()");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// XXX: Should go through emulator interface
|
||||
var LoadBinaryResource;
|
||||
|
||||
if(typeof XMLHttpRequest !== "undefined")
|
||||
{
|
||||
LoadBinaryResource = function(url, OnSuccess, OnError) {
|
||||
var req = new XMLHttpRequest();
|
||||
req.open("GET", url, true);
|
||||
req.responseType = "arraybuffer";
|
||||
req.onreadystatechange = function () {
|
||||
if(req.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
if((req.status !== 200) && (req.status !== 0)) {
|
||||
OnError("Error: Could not load file " + url);
|
||||
return;
|
||||
}
|
||||
var arrayBuffer = req.response;
|
||||
if(arrayBuffer) {
|
||||
OnSuccess(arrayBuffer);
|
||||
} else {
|
||||
OnError("Error: No data received from: " + url);
|
||||
}
|
||||
};
|
||||
/*
|
||||
req.onload = function(e)
|
||||
{
|
||||
var arrayBuffer = req.response;
|
||||
if (arrayBuffer) {
|
||||
OnLoadFunction(arrayBuffer);
|
||||
}
|
||||
};
|
||||
*/
|
||||
req.send(null);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadBinaryResource = function(url, OnSuccess, OnError)
|
||||
{
|
||||
//console.log(url);
|
||||
import("node:" + "fs").then(fs => fs["readFile"](url, function(err, data)
|
||||
{
|
||||
if(err)
|
||||
{
|
||||
OnError(err);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnSuccess(data.buffer);
|
||||
}
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
|
@ -2,10 +2,9 @@
|
|||
// ------------------ Marshall ---------------------
|
||||
// -------------------------------------------------
|
||||
// helper functions for virtio and 9p.
|
||||
|
||||
"use strict";
|
||||
|
||||
import { message } from "./jor1k.js";
|
||||
import { dbg_log } from "./../src/log.js";
|
||||
|
||||
const textde = new TextDecoder();
|
||||
const texten = new TextEncoder();
|
||||
|
|
@ -66,7 +65,7 @@ export function Marshall(typelist, input, struct, offset) {
|
|||
size += 13;
|
||||
break;
|
||||
default:
|
||||
message.Debug("Marshall: Unknown type=" + typelist[i]);
|
||||
dbg_log("Marshall: Unknown type=" + typelist[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -121,7 +120,7 @@ export function Unmarshall(typelist, struct, state) {
|
|||
});
|
||||
break;
|
||||
default:
|
||||
message.Debug("Error in Unmarshall: Unknown type=" + typelist[i]);
|
||||
dbg_log("Error in Unmarshall: Unknown type=" + typelist[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue