Skip to content

Commit

Permalink
[cleanup] Use mainstream memfs.
Browse files Browse the repository at this point in the history
Now contains O_DIRECTORY fix.
(streamich/memfs#494)
  • Loading branch information
corwin-of-amber committed Jan 15, 2020
1 parent a392403 commit 426cd5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions package.json
Expand Up @@ -15,7 +15,7 @@
"@wasmer/wasmfs": "^0.4.5",
"assert": "^2.0.0",
"buffer": "^5.4.3",
"memfs": "git+https://github.com/torch2424/memfs.git#wasmfs-fixes"
"memfs": "^3.0.4"
},
"devDependencies": {
"@types/node": "^13.1.1",
Expand All @@ -24,10 +24,6 @@
"ts-node": "^8.4.1",
"typescript": "^3.6.4"
},
"alias": {
"@wasmer/wasmfs": "./node_modules/@wasmer/wasmfs/lib/index.cjs",
"@wasmer/wasm-transformer": "./node_modules/@wasmer/wasm-transformer/lib/unoptimized/wasm-transformer.esm"
},
"author": "",
"license": "ISC",
"browserslist": [
Expand Down
9 changes: 5 additions & 4 deletions src/kernel/services/shared-fs.ts
@@ -1,6 +1,5 @@
import { Volume } from 'memfs/lib/volume';
import { fs as memfs, Volume } from 'memfs';
import { Node, Link } from 'memfs/lib/node';
import { constants } from 'memfs/lib/constants';
import assert from 'assert';


Expand Down Expand Up @@ -44,7 +43,7 @@ class SharedVolume extends Volume {
}

writeBlob(path: string, buf: Uint8Array) {
var fd = this.openSync(path, constants.O_CREAT),
var fd = this.openSync(path, memfs.constants.O_CREAT),
node = <NodeSharedVolume>this.fds[fd].node,
blob = this.dev.allocBlob(buf.length);
blob.set(buf, 0);
Expand Down Expand Up @@ -141,6 +140,8 @@ class BlockDevice {
}

allocBlob(size: number) {
if (size > this.blobCursor) throw new Error("no space left on device");
// @todo check that blocks in this range are free
this.blobCursor -= size;
return this.getBlob(this.blobCursor, size);
}
Expand Down Expand Up @@ -256,7 +257,7 @@ class NodeSharedVolume extends Node {
var blk = this.vol.dev.get(this.ino);
if (blk[0] != 0) {
var {header, rdc} = this._read();
this.vol.debug('- pull node', this.ino, header, buf);
this.vol.debug('- pull node', this.ino, header);
this.perm = header.p;
this.mode = header.m;
if (this.ver != header.v) {
Expand Down

0 comments on commit 426cd5d

Please sign in to comment.