@zenfs/core 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backends/backend.js +6 -5
- package/dist/backends/cow.d.ts +2 -2
- package/dist/backends/cow.js +39 -58
- package/dist/backends/fetch.js +27 -29
- package/dist/backends/passthrough.d.ts +2 -3
- package/dist/backends/passthrough.js +84 -199
- package/dist/backends/port.d.ts +16 -3
- package/dist/backends/port.js +61 -30
- package/dist/backends/single_buffer.d.ts +52 -46
- package/dist/backends/single_buffer.js +462 -219
- package/dist/backends/store/fs.d.ts +16 -10
- package/dist/backends/store/fs.js +227 -242
- package/dist/backends/store/store.d.ts +3 -3
- package/dist/backends/store/store.js +11 -10
- package/dist/config.d.ts +2 -2
- package/dist/config.js +10 -11
- package/dist/internal/devices.d.ts +2 -2
- package/dist/internal/devices.js +39 -49
- package/dist/internal/error.d.ts +9 -204
- package/dist/internal/error.js +19 -288
- package/dist/internal/file_index.d.ts +1 -1
- package/dist/internal/file_index.js +9 -9
- package/dist/internal/filesystem.d.ts +23 -8
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index_fs.d.ts +2 -2
- package/dist/internal/index_fs.js +19 -19
- package/dist/internal/inode.d.ts +81 -103
- package/dist/internal/inode.js +336 -195
- package/dist/mixins/async.js +32 -28
- package/dist/mixins/mutexed.d.ts +4 -4
- package/dist/mixins/mutexed.js +39 -39
- package/dist/mixins/readonly.d.ts +2 -2
- package/dist/mixins/readonly.js +20 -20
- package/dist/mixins/sync.js +2 -2
- package/dist/polyfills.js +1 -1
- package/dist/readline.js +1 -1
- package/dist/utils.d.ts +8 -5
- package/dist/utils.js +14 -17
- package/dist/vfs/acl.d.ts +8 -8
- package/dist/vfs/acl.js +66 -47
- package/dist/vfs/async.d.ts +2 -2
- package/dist/vfs/async.js +6 -8
- package/dist/vfs/dir.d.ts +1 -1
- package/dist/vfs/dir.js +3 -4
- package/dist/vfs/file.js +33 -24
- package/dist/vfs/flags.js +3 -3
- package/dist/vfs/ioctl.d.ts +8 -7
- package/dist/vfs/ioctl.js +132 -27
- package/dist/vfs/promises.d.ts +3 -3
- package/dist/vfs/promises.js +200 -235
- package/dist/vfs/shared.d.ts +1 -12
- package/dist/vfs/shared.js +7 -35
- package/dist/vfs/streams.js +9 -9
- package/dist/vfs/sync.d.ts +1 -2
- package/dist/vfs/sync.js +158 -170
- package/dist/vfs/watchers.js +8 -8
- package/dist/vfs/xattr.js +89 -106
- package/package.json +4 -2
- package/scripts/test.js +2 -2
- package/tests/assignment.ts +1 -1
- package/tests/backend/port.test.ts +4 -4
- package/tests/backend/single-buffer.test.ts +39 -10
- package/tests/backend/single-buffer.worker.js +30 -0
- package/tests/common/context.test.ts +2 -2
- package/tests/common/mutex.test.ts +9 -9
- package/tests/fetch/fetch.ts +1 -1
- package/tests/fs/append.test.ts +4 -4
- package/tests/fs/directory.test.ts +25 -25
- package/tests/fs/errors.test.ts +15 -19
- package/tests/fs/links.test.ts +3 -2
- package/tests/fs/open.test.ts +4 -21
- package/tests/fs/permissions.test.ts +8 -13
- package/tests/fs/read.test.ts +10 -9
- package/tests/fs/readFile.test.ts +8 -24
- package/tests/fs/rename.test.ts +4 -9
- package/tests/fs/stat.test.ts +2 -2
- package/tests/fs/times.test.ts +6 -6
- package/tests/fs/truncate.test.ts +8 -36
- package/tests/fs/watch.test.ts +10 -10
- package/tests/fs/write.test.ts +77 -13
- package/tests/fs/xattr.test.ts +7 -7
- package/tests/logs.js +2 -2
- package/tests/setup/port.ts +6 -0
- package/dist/internal/log.d.ts +0 -139
- package/dist/internal/log.js +0 -219
- package/tests/fs/writeFile.test.ts +0 -70
package/dist/vfs/shared.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type * as fs from 'node:fs';
|
|
2
|
-
import type { FileSystem } from '../internal/filesystem.js';
|
|
3
2
|
import type { V_Context } from '../context.js';
|
|
4
|
-
import {
|
|
3
|
+
import type { FileSystem } from '../internal/filesystem.js';
|
|
5
4
|
import type { InodeLike } from '../internal/inode.js';
|
|
6
5
|
import { type AbsolutePath } from '../path.js';
|
|
7
6
|
/**
|
|
@@ -48,16 +47,6 @@ export interface ResolvedPath extends ResolvedMount {
|
|
|
48
47
|
* @internal @hidden
|
|
49
48
|
*/
|
|
50
49
|
export declare function resolveMount(path: string, ctx: V_Context): ResolvedMount;
|
|
51
|
-
/**
|
|
52
|
-
* Reverse maps the paths in text from the mounted FileSystem to the global path
|
|
53
|
-
* @internal @hidden
|
|
54
|
-
*/
|
|
55
|
-
export declare function fixPaths(text: string, paths: Record<string, string>): string;
|
|
56
|
-
/**
|
|
57
|
-
* Fix paths in error stacks
|
|
58
|
-
* @internal @hidden
|
|
59
|
-
*/
|
|
60
|
-
export declare function fixError<E extends ErrnoError>(e: E, paths: Record<string, string>): E;
|
|
61
50
|
/**
|
|
62
51
|
* @internal @hidden
|
|
63
52
|
*/
|
package/dist/vfs/shared.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Utilities and shared data
|
|
2
|
+
import { Errno, Exception, UV, withErrno } from 'kerium';
|
|
3
|
+
import { alert, debug, err, info, notice, warn } from 'kerium/log';
|
|
2
4
|
import { InMemory } from '../backends/memory.js';
|
|
3
5
|
import { defaultContext } from '../internal/contexts.js';
|
|
4
|
-
import { Errno, ErrnoError } from '../internal/error.js';
|
|
5
|
-
import { alert, debug, err, info, notice, warn } from '../internal/log.js';
|
|
6
6
|
import { join, resolve } from '../path.js';
|
|
7
7
|
import { normalizePath } from '../utils.js';
|
|
8
8
|
import { size_max } from './constants.js';
|
|
@@ -24,7 +24,7 @@ export function mount(mountPoint, fs) {
|
|
|
24
24
|
mountPoint = '/' + mountPoint;
|
|
25
25
|
mountPoint = resolve.call(this, mountPoint);
|
|
26
26
|
if (mounts.has(mountPoint))
|
|
27
|
-
throw err(
|
|
27
|
+
throw err(withErrno('EINVAL', 'Mount point is already in use: ' + mountPoint));
|
|
28
28
|
fs._mountPoint = mountPoint;
|
|
29
29
|
mounts.set(mountPoint, fs);
|
|
30
30
|
info(`Mounted ${fs.name} on ${mountPoint}`);
|
|
@@ -62,35 +62,7 @@ export function resolveMount(path, ctx) {
|
|
|
62
62
|
return { fs, path, mountPoint, root };
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
throw alert(new
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Reverse maps the paths in text from the mounted FileSystem to the global path
|
|
69
|
-
* @internal @hidden
|
|
70
|
-
*/
|
|
71
|
-
export function fixPaths(text, paths) {
|
|
72
|
-
for (const [from, to] of Object.entries(paths)) {
|
|
73
|
-
text = text === null || text === void 0 ? void 0 : text.replaceAll(from, to);
|
|
74
|
-
}
|
|
75
|
-
return text;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Fix paths in error stacks
|
|
79
|
-
* @internal @hidden
|
|
80
|
-
*/
|
|
81
|
-
export function fixError(e, paths) {
|
|
82
|
-
if (typeof e.stack == 'string') {
|
|
83
|
-
e.stack = fixPaths(e.stack, paths);
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
e.message = fixPaths(e.message, paths);
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
// `message` is read only
|
|
90
|
-
}
|
|
91
|
-
if (e.path)
|
|
92
|
-
e.path = fixPaths(e.path, paths);
|
|
93
|
-
return e;
|
|
65
|
+
throw alert(new Exception(Errno.EIO, 'No file system for ' + path));
|
|
94
66
|
}
|
|
95
67
|
/**
|
|
96
68
|
* @internal @hidden
|
|
@@ -116,16 +88,16 @@ export function chroot(path) {
|
|
|
116
88
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
117
89
|
const $ = this !== null && this !== void 0 ? this : defaultContext;
|
|
118
90
|
if (((_a = $.credentials) === null || _a === void 0 ? void 0 : _a.uid) !== 0 && ((_b = $.credentials) === null || _b === void 0 ? void 0 : _b.gid) !== 0 && ((_c = $.credentials) === null || _c === void 0 ? void 0 : _c.euid) !== 0 && ((_d = $.credentials) === null || _d === void 0 ? void 0 : _d.egid) !== 0)
|
|
119
|
-
throw
|
|
91
|
+
throw withErrno('EPERM', 'Can not chroot() as non-root user');
|
|
120
92
|
(_e = $.root) !== null && _e !== void 0 ? _e : ($.root = '/');
|
|
121
93
|
const newRoot = join($.root, path);
|
|
122
94
|
for (const handle of (_g = (_f = $.descriptors) === null || _f === void 0 ? void 0 : _f.values()) !== null && _g !== void 0 ? _g : []) {
|
|
123
95
|
if (!handle.path.startsWith($.root))
|
|
124
|
-
throw
|
|
96
|
+
throw UV('EBUSY', 'chroot', handle.path);
|
|
125
97
|
handle.path = handle.path.slice($.root.length);
|
|
126
98
|
}
|
|
127
99
|
if (newRoot.length > $.root.length)
|
|
128
|
-
throw
|
|
100
|
+
throw withErrno('EPERM', 'Can not chroot() outside of current root');
|
|
129
101
|
$.root = newRoot;
|
|
130
102
|
}
|
|
131
103
|
/**
|
package/dist/vfs/streams.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Errno, Exception, UV } from 'kerium';
|
|
2
|
+
import { warn } from 'kerium/log';
|
|
1
3
|
import { Readable, Writable } from 'readable-stream';
|
|
2
|
-
import { Errno, ErrnoError } from '../internal/error.js';
|
|
3
|
-
import { warn } from '../internal/log.js';
|
|
4
4
|
/**
|
|
5
5
|
* A ReadStream implementation that wraps an underlying global ReadableStream.
|
|
6
6
|
*/
|
|
@@ -36,7 +36,7 @@ export class ReadStream extends Readable {
|
|
|
36
36
|
this.push(value);
|
|
37
37
|
}
|
|
38
38
|
catch (err) {
|
|
39
|
-
this.destroy(new
|
|
39
|
+
this.destroy(new Exception(Errno.EIO, err.toString()));
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
close(callback = () => null) {
|
|
@@ -46,7 +46,7 @@ export class ReadStream extends Readable {
|
|
|
46
46
|
callback(null);
|
|
47
47
|
}
|
|
48
48
|
catch (err) {
|
|
49
|
-
callback(new
|
|
49
|
+
callback(new Exception(Errno.EIO, err.toString()));
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
get path() {
|
|
@@ -81,9 +81,9 @@ export class WriteStream extends Writable {
|
|
|
81
81
|
async _write(chunk, encoding, callback) {
|
|
82
82
|
await this.ready;
|
|
83
83
|
if (!this.writer)
|
|
84
|
-
return callback(warn(
|
|
84
|
+
return callback(warn(UV('EAGAIN', 'write', this._path)));
|
|
85
85
|
if (encoding != 'buffer')
|
|
86
|
-
return callback(warn(
|
|
86
|
+
return callback(warn(UV('ENOTSUP', 'write', this._path)));
|
|
87
87
|
const data = new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
88
88
|
try {
|
|
89
89
|
await this.writer.write(data);
|
|
@@ -91,7 +91,7 @@ export class WriteStream extends Writable {
|
|
|
91
91
|
callback();
|
|
92
92
|
}
|
|
93
93
|
catch (error) {
|
|
94
|
-
callback(new
|
|
94
|
+
callback(new Exception(Errno.EIO, error.toString()));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
async _final(callback) {
|
|
@@ -103,7 +103,7 @@ export class WriteStream extends Writable {
|
|
|
103
103
|
callback();
|
|
104
104
|
}
|
|
105
105
|
catch (error) {
|
|
106
|
-
callback(new
|
|
106
|
+
callback(new Exception(Errno.EIO, error.toString()));
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
close(callback = () => null) {
|
|
@@ -113,7 +113,7 @@ export class WriteStream extends Writable {
|
|
|
113
113
|
callback(null);
|
|
114
114
|
}
|
|
115
115
|
catch (error) {
|
|
116
|
-
callback(new
|
|
116
|
+
callback(new Exception(Errno.EIO, error.toString()));
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
get path() {
|
package/dist/vfs/sync.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type * as fs from 'node:fs';
|
|
2
2
|
import type { V_Context } from '../context.js';
|
|
3
|
-
import { Stats } from './stats.js';
|
|
4
3
|
import type { FileContents, NullEnc, ReaddirOptions, ReaddirOptsI, ReaddirOptsU } from './types.js';
|
|
5
4
|
import { Buffer } from 'buffer';
|
|
6
5
|
import { Dir, Dirent } from './dir.js';
|
|
7
|
-
import { BigIntStats } from './stats.js';
|
|
6
|
+
import { BigIntStats, Stats } from './stats.js';
|
|
8
7
|
export declare function renameSync(this: V_Context, oldPath: fs.PathLike, newPath: fs.PathLike): void;
|
|
9
8
|
/**
|
|
10
9
|
* Test whether or not `path` exists by checking with the file system.
|