9p: Simplify read - OpenInode is not asynchronous
This commit is contained in:
parent
62c880b415
commit
04d2b72248
1 changed files with 27 additions and 31 deletions
48
lib/9p.js
48
lib/9p.js
|
|
@ -591,37 +591,33 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) { // jshint ignore
|
|||
this.SendReply(bufchain);
|
||||
} else {
|
||||
this.fs.OpenInode(this.fids[fid].inodeid, undefined);
|
||||
this.fs.AddEvent(this.fids[fid].inodeid,
|
||||
async function() { // jshint ignore:line
|
||||
const inodeid = this.fids[fid].inodeid;
|
||||
const inodeid = this.fids[fid].inodeid;
|
||||
|
||||
if (inode.size < offset+count) count = inode.size - offset;
|
||||
else if(id == 40)
|
||||
{
|
||||
// for directories, return whole number of dir-entries.
|
||||
count = this.fs.RoundToDirentry(inodeid, offset + count) - offset;
|
||||
}
|
||||
if(offset > inode.size)
|
||||
{
|
||||
// offset can be greater than available - should return count of zero.
|
||||
// See http://ericvh.github.io/9p-rfc/rfc9p2000.html#anchor30
|
||||
count = 0;
|
||||
}
|
||||
if (inode.size < offset+count) count = inode.size - offset;
|
||||
else if(id == 40)
|
||||
{
|
||||
// for directories, return whole number of dir-entries.
|
||||
count = this.fs.RoundToDirentry(inodeid, offset + count) - offset;
|
||||
}
|
||||
if(offset > inode.size)
|
||||
{
|
||||
// offset can be greater than available - should return count of zero.
|
||||
// See http://ericvh.github.io/9p-rfc/rfc9p2000.html#anchor30
|
||||
count = 0;
|
||||
}
|
||||
|
||||
this.bus.send("9p-read-start", [this.fids[fid].dbg_name]);
|
||||
this.bus.send("9p-read-start", [this.fids[fid].dbg_name]);
|
||||
|
||||
const data = await this.fs.Read(inodeid, offset, count); // jshint ignore:line
|
||||
const data = await this.fs.Read(inodeid, offset, count); // jshint ignore:line
|
||||
|
||||
this.bus.send("9p-read-end", [this.fids[fid].dbg_name, count]);
|
||||
this.bus.send("9p-read-end", [this.fids[fid].dbg_name, count]);
|
||||
|
||||
if(data) {
|
||||
this.replybuffer.set(data, 7 + 4);
|
||||
}
|
||||
marshall.Marshall(["w"], [count], this.replybuffer, 7);
|
||||
this.BuildReply(id, tag, 4 + count);
|
||||
this.SendReply(bufchain);
|
||||
}.bind(this) // jshint ignore:line
|
||||
); // jshint ignore:line
|
||||
if(data) {
|
||||
this.replybuffer.set(data, 7 + 4);
|
||||
}
|
||||
marshall.Marshall(["w"], [count], this.replybuffer, 7);
|
||||
this.BuildReply(id, tag, 4 + count);
|
||||
this.SendReply(bufchain);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue