@zenfs/core 2.7.4 → 2.7.6
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 +0 -2
- package/dist/backends/cow.d.ts +2 -2
- package/dist/backends/cow.js +6 -14
- package/dist/backends/passthrough.d.ts +0 -54
- package/dist/backends/passthrough.js +0 -54
- package/dist/backends/port.d.ts +2 -6
- package/dist/backends/port.js +3 -11
- package/dist/backends/store/fs.d.ts +0 -9
- package/dist/backends/store/fs.js +1 -21
- package/dist/backends/store/store.d.ts +1 -1
- package/dist/backends/store/store.js +1 -5
- package/dist/internal/contexts.d.ts +1 -2
- package/dist/internal/credentials.d.ts +0 -3
- package/dist/internal/file_index.js +0 -1
- package/dist/internal/filesystem.js +2 -2
- package/dist/internal/index_fs.d.ts +2 -2
- package/dist/internal/index_fs.js +2 -2
- package/dist/internal/inode.d.ts +33 -45
- package/dist/internal/inode.js +12 -2
- package/dist/internal/ioctl.d.ts +83 -25
- package/dist/internal/ioctl.js +50 -185
- package/dist/internal/rpc.d.ts +16 -7
- package/dist/internal/rpc.js +2 -11
- package/dist/mixins/mutexed.d.ts +6 -41
- package/dist/mixins/mutexed.js +36 -109
- package/dist/mixins/sync.js +0 -2
- package/dist/node/async.js +2 -12
- package/dist/node/index.d.ts +1 -1
- package/dist/node/promises.d.ts +1 -6
- package/dist/node/promises.js +1 -1
- package/dist/node/stats.d.ts +25 -99
- package/dist/node/stats.js +18 -55
- package/dist/node/streams.d.ts +1 -37
- package/dist/node/sync.d.ts +1 -6
- package/dist/node/sync.js +2 -2
- package/dist/polyfills.js +9 -0
- package/dist/utils.d.ts +0 -4
- package/dist/vfs/acl.d.ts +1 -3
- package/dist/vfs/acl.js +1 -3
- package/dist/vfs/async.js +0 -5
- package/dist/vfs/dir.d.ts +3 -0
- package/dist/vfs/dir.js +4 -1
- package/dist/vfs/file.d.ts +1 -8
- package/dist/vfs/file.js +1 -3
- package/dist/vfs/sync.js +0 -1
- package/dist/vfs/vcache.js +0 -1
- package/dist/vfs/xattr.d.ts +2 -0
- package/dist/vfs/xattr.js +5 -4
- package/package.json +2 -3
- package/tests/common/context.test.ts +1 -1
- package/tests/common/mutex.test.ts +0 -61
package/dist/internal/inode.js
CHANGED
|
@@ -326,9 +326,19 @@ export var InodeFlags;
|
|
|
326
326
|
/** File is in use by the kernel (eg. fs/cachefiles) */
|
|
327
327
|
InodeFlags[InodeFlags["KernelFile"] = 131072] = "KernelFile";
|
|
328
328
|
})(InodeFlags || (InodeFlags = {}));
|
|
329
|
-
/**
|
|
329
|
+
/**
|
|
330
|
+
* User visible flags
|
|
331
|
+
* These are actually masks for userspace `FileFlag`s, not `InodeFlags`.
|
|
332
|
+
* @deprecated Use the export from `/internal/ioctl`
|
|
333
|
+
* @todo [breaking] remove
|
|
334
|
+
*/
|
|
330
335
|
export const userVisibleFlags = 0x0003dfff;
|
|
331
|
-
/**
|
|
336
|
+
/**
|
|
337
|
+
* User modifiable flags
|
|
338
|
+
* These are actually masks for userspace `FileFlag`s, not `InodeFlags`.
|
|
339
|
+
* @deprecated Use the export from `/internal/ioctl`
|
|
340
|
+
* @todo [breaking] remove these re-exports
|
|
341
|
+
*/
|
|
332
342
|
export const userModifiableFlags = 0x000380ff;
|
|
333
343
|
/**
|
|
334
344
|
* Generic inode definition that can easily be serialized.
|
package/dist/internal/ioctl.d.ts
CHANGED
|
@@ -1,38 +1,96 @@
|
|
|
1
|
-
import { BufferView } from 'utilium/buffer';
|
|
2
1
|
import type { FileSystem } from './filesystem.js';
|
|
3
2
|
import type { InodeLike } from './inode.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
|
|
5
|
+
* @see `FS_*_FL` in `include/uapi/linux/fs.h` (around L250)
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export declare enum FileFlag {
|
|
9
|
+
/** Secure deletion */
|
|
10
|
+
SecureRm = 1,
|
|
11
|
+
/** Undelete */
|
|
12
|
+
Undelete = 2,
|
|
13
|
+
/** Compress file */
|
|
14
|
+
Compress = 4,
|
|
15
|
+
/** Synchronous updates */
|
|
16
|
+
Sync = 8,
|
|
17
|
+
/** Immutable file */
|
|
18
|
+
Immutable = 16,
|
|
19
|
+
/** Writes to file may only append */
|
|
20
|
+
Append = 32,
|
|
21
|
+
/** do not dump file */
|
|
22
|
+
NoDump = 64,
|
|
23
|
+
/** do not update atime */
|
|
24
|
+
NoAtime = 128,
|
|
25
|
+
Dirty = 256,
|
|
26
|
+
/** One or more compressed clusters */
|
|
27
|
+
CompressBlk = 512,
|
|
28
|
+
/** Don't compress */
|
|
29
|
+
NoCompress = 1024,
|
|
30
|
+
/** Encrypted file */
|
|
31
|
+
Encrypt = 2048,
|
|
32
|
+
/** btree format dir */
|
|
33
|
+
Btree = 4096,
|
|
34
|
+
/** hash-indexed directory */
|
|
35
|
+
Index = 4096,
|
|
36
|
+
/** AFS directory */
|
|
37
|
+
IMagic = 8192,
|
|
38
|
+
/** Reserved for ext3 */
|
|
39
|
+
JournalData = 16384,
|
|
40
|
+
/** file tail should not be merged */
|
|
41
|
+
NoTail = 32768,
|
|
42
|
+
/** dirsync behaviour (directories only) */
|
|
43
|
+
DirSync = 65536,
|
|
44
|
+
/** Top of directory hierarchies*/
|
|
45
|
+
TopDir = 131072,
|
|
46
|
+
/** Reserved for ext4 */
|
|
47
|
+
HugeFile = 262144,
|
|
48
|
+
/** Extents */
|
|
49
|
+
Extent = 524288,
|
|
50
|
+
/** Verity protected inode */
|
|
51
|
+
Verity = 1048576,
|
|
52
|
+
/** Inode used for large EA */
|
|
53
|
+
EaInode = 2097152,
|
|
54
|
+
/** Reserved for ext4 */
|
|
55
|
+
EofBlocks = 4194304,
|
|
56
|
+
/** Do not cow file */
|
|
57
|
+
NoCow = 8388608,
|
|
58
|
+
/** Inode is DAX */
|
|
59
|
+
Dax = 33554432,
|
|
60
|
+
/** Reserved for ext4 */
|
|
61
|
+
InlineData = 268435456,
|
|
62
|
+
/** Create with parents projid */
|
|
63
|
+
ProjInherit = 536870912,
|
|
64
|
+
/** Folder is case insensitive */
|
|
65
|
+
CaseFold = 1073741824,
|
|
66
|
+
/** reserved for ext2 lib */
|
|
67
|
+
Reserved = 2147483648
|
|
19
68
|
}
|
|
69
|
+
/** User visible flags */
|
|
70
|
+
export declare const userVisibleFlags = 253951;
|
|
71
|
+
/** User modifiable flags */
|
|
72
|
+
export declare const userModifiableFlags = 229631;
|
|
20
73
|
/**
|
|
21
74
|
* `FS_IOC_*` commands for {@link ioctl | `ioctl`}
|
|
22
75
|
* @remarks
|
|
23
76
|
* These are computed from a script since constant values are needed for enum member types
|
|
77
|
+
* @todo [breaking] remove deprecated flags and handlers
|
|
24
78
|
*/
|
|
25
79
|
export declare enum IOC {
|
|
26
80
|
GetFlags = 2148034049,
|
|
27
81
|
SetFlags = 1074292226,
|
|
28
82
|
GetVersion = 2148038145,
|
|
29
83
|
SetVersion = 1074296322,
|
|
84
|
+
/** @deprecated */
|
|
30
85
|
Fiemap = 3223348747,
|
|
86
|
+
/** @deprecated */
|
|
31
87
|
GetXattr = 2149341215,
|
|
88
|
+
/** @deprecated */
|
|
32
89
|
SetXattr = 1075599392,
|
|
33
90
|
GetLabel = 2164298801,
|
|
34
91
|
SetLabel = 1090556978,
|
|
35
92
|
GetUUID = 2148603136,
|
|
93
|
+
/** @deprecated */
|
|
36
94
|
GetSysfsPath = 2155943169
|
|
37
95
|
}
|
|
38
96
|
/**
|
|
@@ -82,12 +140,12 @@ export declare const ioctl_default_ops: {
|
|
|
82
140
|
2148038145($: IoctlContext): number;
|
|
83
141
|
2147776001($: IoctlContext): number;
|
|
84
142
|
3223348747(): never;
|
|
85
|
-
2149341215(
|
|
86
|
-
1075599392(
|
|
143
|
+
2149341215(): never;
|
|
144
|
+
1075599392(): never;
|
|
87
145
|
2164298801($: IoctlContext): string | undefined;
|
|
88
146
|
1090556978($: IoctlContext, label: string): void;
|
|
89
147
|
2148603136($: IoctlContext): string;
|
|
90
|
-
2155943169(
|
|
148
|
+
2155943169(): never;
|
|
91
149
|
};
|
|
92
150
|
/**
|
|
93
151
|
* @internal
|
|
@@ -103,12 +161,12 @@ export declare const ioctl_default_ops_async: {
|
|
|
103
161
|
2148038145($: IoctlContext): number;
|
|
104
162
|
2147776001($: IoctlContext): number;
|
|
105
163
|
3223348747(): never;
|
|
106
|
-
2149341215(
|
|
107
|
-
1075599392(
|
|
164
|
+
2149341215(): never;
|
|
165
|
+
1075599392(): never;
|
|
108
166
|
2164298801($: IoctlContext): string | undefined;
|
|
109
167
|
1090556978($: IoctlContext, label: string): void;
|
|
110
168
|
2148603136($: IoctlContext): string;
|
|
111
|
-
2155943169(
|
|
169
|
+
2155943169(): never;
|
|
112
170
|
};
|
|
113
171
|
type _IoctlOpsAsync = typeof ioctl_default_ops_async;
|
|
114
172
|
/**
|
|
@@ -131,12 +189,12 @@ export declare const ioctl_default_ops_sync: {
|
|
|
131
189
|
2148038145($: IoctlContext): number;
|
|
132
190
|
2147776001($: IoctlContext): number;
|
|
133
191
|
3223348747(): never;
|
|
134
|
-
2149341215(
|
|
135
|
-
1075599392(
|
|
192
|
+
2149341215(): never;
|
|
193
|
+
1075599392(): never;
|
|
136
194
|
2164298801($: IoctlContext): string | undefined;
|
|
137
195
|
1090556978($: IoctlContext, label: string): void;
|
|
138
196
|
2148603136($: IoctlContext): string;
|
|
139
|
-
2155943169(
|
|
197
|
+
2155943169(): never;
|
|
140
198
|
};
|
|
141
199
|
type _IoctlOpsSync = typeof ioctl_default_ops_sync;
|
|
142
200
|
/**
|
package/dist/internal/ioctl.js
CHANGED
|
@@ -1,178 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
-
var _, done = false;
|
|
7
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
-
var context = {};
|
|
9
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
-
if (kind === "accessor") {
|
|
14
|
-
if (result === void 0) continue;
|
|
15
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
-
}
|
|
20
|
-
else if (_ = accept(result)) {
|
|
21
|
-
if (kind === "field") initializers.unshift(_);
|
|
22
|
-
else descriptor[key] = _;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
-
done = true;
|
|
27
|
-
};
|
|
28
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
-
var useValue = arguments.length > 2;
|
|
30
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
-
}
|
|
33
|
-
return useValue ? value : void 0;
|
|
34
|
-
};
|
|
35
|
-
import { Errno, Exception, withErrno } from 'kerium';
|
|
36
|
-
import { sizeof } from 'memium';
|
|
37
|
-
import { $from, struct, types as t } from 'memium/decorators';
|
|
38
|
-
import { _throw } from 'utilium';
|
|
39
|
-
import { BufferView } from 'utilium/buffer';
|
|
1
|
+
import { withErrno } from 'kerium';
|
|
40
2
|
import { InodeFlags } from './inode.js';
|
|
41
|
-
/*
|
|
42
|
-
* Flags for the fsxattr.xflags field
|
|
43
|
-
*/
|
|
44
|
-
var XFlag;
|
|
45
|
-
(function (XFlag) {
|
|
46
|
-
/** data in realtime volume */
|
|
47
|
-
XFlag[XFlag["RealTime"] = 1] = "RealTime";
|
|
48
|
-
/** preallocated file extents */
|
|
49
|
-
XFlag[XFlag["PreAlloc"] = 2] = "PreAlloc";
|
|
50
|
-
/** file cannot be modified */
|
|
51
|
-
XFlag[XFlag["Immutable"] = 8] = "Immutable";
|
|
52
|
-
/** all writes append */
|
|
53
|
-
XFlag[XFlag["Append"] = 16] = "Append";
|
|
54
|
-
/** all writes synchronous */
|
|
55
|
-
XFlag[XFlag["Sync"] = 32] = "Sync";
|
|
56
|
-
/** do not update access time */
|
|
57
|
-
XFlag[XFlag["NoAtime"] = 64] = "NoAtime";
|
|
58
|
-
/** do not include in backups */
|
|
59
|
-
XFlag[XFlag["NoDump"] = 128] = "NoDump";
|
|
60
|
-
/** create with rt bit set */
|
|
61
|
-
XFlag[XFlag["RtInherit"] = 256] = "RtInherit";
|
|
62
|
-
/** create with parents projid */
|
|
63
|
-
XFlag[XFlag["ProjInherit"] = 512] = "ProjInherit";
|
|
64
|
-
/** disallow symlink creation */
|
|
65
|
-
XFlag[XFlag["NoSymlinks"] = 1024] = "NoSymlinks";
|
|
66
|
-
/** extent size allocator hint */
|
|
67
|
-
XFlag[XFlag["ExtSize"] = 2048] = "ExtSize";
|
|
68
|
-
/** inherit inode extent size */
|
|
69
|
-
XFlag[XFlag["ExtSzInherit"] = 4096] = "ExtSzInherit";
|
|
70
|
-
/** do not defragment */
|
|
71
|
-
XFlag[XFlag["NoDefrag"] = 8192] = "NoDefrag";
|
|
72
|
-
/** use filestream allocator */
|
|
73
|
-
XFlag[XFlag["FileStream"] = 16384] = "FileStream";
|
|
74
|
-
/** use DAX for IO */
|
|
75
|
-
XFlag[XFlag["Dax"] = 32768] = "Dax";
|
|
76
|
-
/** CoW extent size allocator hint */
|
|
77
|
-
XFlag[XFlag["CowExtSize"] = 65536] = "CowExtSize";
|
|
78
|
-
/** no DIFLAG for this */
|
|
79
|
-
XFlag[XFlag["HasAttr"] = 2147483648] = "HasAttr";
|
|
80
|
-
})(XFlag || (XFlag = {}));
|
|
81
|
-
let fsxattr = (() => {
|
|
82
|
-
var _a, _b, _c, _d, _e;
|
|
83
|
-
let _classDecorators = [struct()];
|
|
84
|
-
let _classDescriptor;
|
|
85
|
-
let _classExtraInitializers = [];
|
|
86
|
-
let _classThis;
|
|
87
|
-
let _classSuper = $from(BufferView);
|
|
88
|
-
let _xflags_decorators;
|
|
89
|
-
let _xflags_initializers = [];
|
|
90
|
-
let _xflags_extraInitializers = [];
|
|
91
|
-
let _extsize_decorators;
|
|
92
|
-
let _extsize_initializers = [];
|
|
93
|
-
let _extsize_extraInitializers = [];
|
|
94
|
-
let _nextents_decorators;
|
|
95
|
-
let _nextents_initializers = [];
|
|
96
|
-
let _nextents_extraInitializers = [];
|
|
97
|
-
let _projid_decorators;
|
|
98
|
-
let _projid_initializers = [];
|
|
99
|
-
let _projid_extraInitializers = [];
|
|
100
|
-
let _cowextsize_decorators;
|
|
101
|
-
let _cowextsize_initializers = [];
|
|
102
|
-
let _cowextsize_extraInitializers = [];
|
|
103
|
-
let _pad_decorators;
|
|
104
|
-
let _pad_initializers = [];
|
|
105
|
-
let _pad_extraInitializers = [];
|
|
106
|
-
var fsxattr = class extends _classSuper {
|
|
107
|
-
static { _classThis = this; }
|
|
108
|
-
static {
|
|
109
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
110
|
-
_xflags_decorators = [(_a = t).uint32.bind(_a)];
|
|
111
|
-
_extsize_decorators = [(_b = t).uint32.bind(_b)];
|
|
112
|
-
_nextents_decorators = [(_c = t).uint32.bind(_c)];
|
|
113
|
-
_projid_decorators = [(_d = t).uint32.bind(_d)];
|
|
114
|
-
_cowextsize_decorators = [(_e = t).uint32.bind(_e)];
|
|
115
|
-
_pad_decorators = [t.char(8)];
|
|
116
|
-
__esDecorate(this, null, _xflags_decorators, { kind: "accessor", name: "xflags", static: false, private: false, access: { has: obj => "xflags" in obj, get: obj => obj.xflags, set: (obj, value) => { obj.xflags = value; } }, metadata: _metadata }, _xflags_initializers, _xflags_extraInitializers);
|
|
117
|
-
__esDecorate(this, null, _extsize_decorators, { kind: "accessor", name: "extsize", static: false, private: false, access: { has: obj => "extsize" in obj, get: obj => obj.extsize, set: (obj, value) => { obj.extsize = value; } }, metadata: _metadata }, _extsize_initializers, _extsize_extraInitializers);
|
|
118
|
-
__esDecorate(this, null, _nextents_decorators, { kind: "accessor", name: "nextents", static: false, private: false, access: { has: obj => "nextents" in obj, get: obj => obj.nextents, set: (obj, value) => { obj.nextents = value; } }, metadata: _metadata }, _nextents_initializers, _nextents_extraInitializers);
|
|
119
|
-
__esDecorate(this, null, _projid_decorators, { kind: "accessor", name: "projid", static: false, private: false, access: { has: obj => "projid" in obj, get: obj => obj.projid, set: (obj, value) => { obj.projid = value; } }, metadata: _metadata }, _projid_initializers, _projid_extraInitializers);
|
|
120
|
-
__esDecorate(this, null, _cowextsize_decorators, { kind: "accessor", name: "cowextsize", static: false, private: false, access: { has: obj => "cowextsize" in obj, get: obj => obj.cowextsize, set: (obj, value) => { obj.cowextsize = value; } }, metadata: _metadata }, _cowextsize_initializers, _cowextsize_extraInitializers);
|
|
121
|
-
__esDecorate(this, null, _pad_decorators, { kind: "accessor", name: "pad", static: false, private: false, access: { has: obj => "pad" in obj, get: obj => obj.pad, set: (obj, value) => { obj.pad = value; } }, metadata: _metadata }, _pad_initializers, _pad_extraInitializers);
|
|
122
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
123
|
-
fsxattr = _classThis = _classDescriptor.value;
|
|
124
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
125
|
-
}
|
|
126
|
-
static name = 'fsxattr';
|
|
127
|
-
#xflags_accessor_storage = __runInitializers(this, _xflags_initializers, void 0);
|
|
128
|
-
/** xflags field value */
|
|
129
|
-
get xflags() { return this.#xflags_accessor_storage; }
|
|
130
|
-
set xflags(value) { this.#xflags_accessor_storage = value; }
|
|
131
|
-
#extsize_accessor_storage = (__runInitializers(this, _xflags_extraInitializers), __runInitializers(this, _extsize_initializers, void 0));
|
|
132
|
-
/** extsize field value */
|
|
133
|
-
get extsize() { return this.#extsize_accessor_storage; }
|
|
134
|
-
set extsize(value) { this.#extsize_accessor_storage = value; }
|
|
135
|
-
#nextents_accessor_storage = (__runInitializers(this, _extsize_extraInitializers), __runInitializers(this, _nextents_initializers, void 0));
|
|
136
|
-
/** nextents field value */
|
|
137
|
-
get nextents() { return this.#nextents_accessor_storage; }
|
|
138
|
-
set nextents(value) { this.#nextents_accessor_storage = value; }
|
|
139
|
-
#projid_accessor_storage = (__runInitializers(this, _nextents_extraInitializers), __runInitializers(this, _projid_initializers, void 0));
|
|
140
|
-
/** project identifier */
|
|
141
|
-
get projid() { return this.#projid_accessor_storage; }
|
|
142
|
-
set projid(value) { this.#projid_accessor_storage = value; }
|
|
143
|
-
#cowextsize_accessor_storage = (__runInitializers(this, _projid_extraInitializers), __runInitializers(this, _cowextsize_initializers, void 0));
|
|
144
|
-
/** CoW extsize field value */
|
|
145
|
-
get cowextsize() { return this.#cowextsize_accessor_storage; }
|
|
146
|
-
set cowextsize(value) { this.#cowextsize_accessor_storage = value; }
|
|
147
|
-
#pad_accessor_storage = (__runInitializers(this, _cowextsize_extraInitializers), __runInitializers(this, _pad_initializers, []));
|
|
148
|
-
get pad() { return this.#pad_accessor_storage; }
|
|
149
|
-
set pad(value) { this.#pad_accessor_storage = value; }
|
|
150
|
-
constructor(inode = _throw(new Exception(Errno.EINVAL, 'fsxattr must be initialized with an inode'))) {
|
|
151
|
-
super(new ArrayBuffer(sizeof(fsxattr)));
|
|
152
|
-
__runInitializers(this, _pad_extraInitializers);
|
|
153
|
-
this.extsize = inode.size;
|
|
154
|
-
this.nextents = 1;
|
|
155
|
-
this.projid = inode.uid;
|
|
156
|
-
this.cowextsize = inode.size;
|
|
157
|
-
for (const name of Object.keys(InodeFlags)) {
|
|
158
|
-
if (!((inode.flags || 0) & InodeFlags[name]))
|
|
159
|
-
continue;
|
|
160
|
-
if (name in XFlag)
|
|
161
|
-
this.xflags |= XFlag[name];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
static {
|
|
165
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
return fsxattr = _classThis;
|
|
169
|
-
})();
|
|
170
3
|
/**
|
|
171
4
|
* Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
|
|
172
5
|
* @see `FS_*_FL` in `include/uapi/linux/fs.h` (around L250)
|
|
173
6
|
* @experimental
|
|
174
7
|
*/
|
|
175
|
-
var FileFlag;
|
|
8
|
+
export var FileFlag;
|
|
176
9
|
(function (FileFlag) {
|
|
177
10
|
/** Secure deletion */
|
|
178
11
|
FileFlag[FileFlag["SecureRm"] = 1] = "SecureRm";
|
|
@@ -237,10 +70,43 @@ var FileFlag;
|
|
|
237
70
|
/** reserved for ext2 lib */
|
|
238
71
|
FileFlag[FileFlag["Reserved"] = 2147483648] = "Reserved";
|
|
239
72
|
})(FileFlag || (FileFlag = {}));
|
|
73
|
+
/** User visible flags */
|
|
74
|
+
export const userVisibleFlags = 0x0003dfff;
|
|
75
|
+
/** User modifiable flags */
|
|
76
|
+
export const userModifiableFlags = 0x000380ff;
|
|
77
|
+
const flagPairs = [
|
|
78
|
+
[FileFlag.Sync, InodeFlags.Sync],
|
|
79
|
+
[FileFlag.Immutable, InodeFlags.Immutable],
|
|
80
|
+
[FileFlag.Append, InodeFlags.Append],
|
|
81
|
+
[FileFlag.NoAtime, InodeFlags.NoAtime],
|
|
82
|
+
[FileFlag.Encrypt, InodeFlags.Encrypted],
|
|
83
|
+
[FileFlag.DirSync, InodeFlags.Dirsync],
|
|
84
|
+
[FileFlag.Verity, InodeFlags.Verity],
|
|
85
|
+
[FileFlag.Dax, InodeFlags.DAX],
|
|
86
|
+
[FileFlag.CaseFold, InodeFlags.CaseFold],
|
|
87
|
+
];
|
|
88
|
+
const supportedFlags = flagPairs.reduce((all, [flag]) => all | flag, 0), settableFlags = flagPairs.reduce((all, [, flag]) => all | flag, 0);
|
|
89
|
+
function toFileFlags(flags) {
|
|
90
|
+
let value = 0;
|
|
91
|
+
for (const [file, inode] of flagPairs)
|
|
92
|
+
if (flags & inode)
|
|
93
|
+
value |= file;
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
function setFlags($, flags) {
|
|
97
|
+
if (flags & ~supportedFlags)
|
|
98
|
+
throw withErrno('ENOTSUP', 'Unsupported file flags');
|
|
99
|
+
let value = 0;
|
|
100
|
+
for (const [file, inode] of flagPairs)
|
|
101
|
+
if (flags & file)
|
|
102
|
+
value |= inode;
|
|
103
|
+
$.inode.flags = (($.inode.flags || 0) & ~settableFlags) | value;
|
|
104
|
+
}
|
|
240
105
|
/**
|
|
241
106
|
* `FS_IOC_*` commands for {@link ioctl | `ioctl`}
|
|
242
107
|
* @remarks
|
|
243
108
|
* These are computed from a script since constant values are needed for enum member types
|
|
109
|
+
* @todo [breaking] remove deprecated flags and handlers
|
|
244
110
|
*/
|
|
245
111
|
export var IOC;
|
|
246
112
|
(function (IOC) {
|
|
@@ -248,12 +114,16 @@ export var IOC;
|
|
|
248
114
|
IOC[IOC["SetFlags"] = 1074292226] = "SetFlags";
|
|
249
115
|
IOC[IOC["GetVersion"] = 2148038145] = "GetVersion";
|
|
250
116
|
IOC[IOC["SetVersion"] = 1074296322] = "SetVersion";
|
|
117
|
+
/** @deprecated */
|
|
251
118
|
IOC[IOC["Fiemap"] = 3223348747] = "Fiemap";
|
|
119
|
+
/** @deprecated */
|
|
252
120
|
IOC[IOC["GetXattr"] = 2149341215] = "GetXattr";
|
|
121
|
+
/** @deprecated */
|
|
253
122
|
IOC[IOC["SetXattr"] = 1075599392] = "SetXattr";
|
|
254
123
|
IOC[IOC["GetLabel"] = 2164298801] = "GetLabel";
|
|
255
124
|
IOC[IOC["SetLabel"] = 1090556978] = "SetLabel";
|
|
256
125
|
IOC[IOC["GetUUID"] = 2148603136] = "GetUUID";
|
|
126
|
+
/** @deprecated */
|
|
257
127
|
IOC[IOC["GetSysfsPath"] = 2155943169] = "GetSysfsPath";
|
|
258
128
|
})(IOC || (IOC = {}));
|
|
259
129
|
/**
|
|
@@ -276,12 +146,12 @@ export const ioctl_default_ops = {
|
|
|
276
146
|
[IOC.GetFlags]($) {
|
|
277
147
|
if (typeof $.inode.flags !== 'number')
|
|
278
148
|
throw withErrno('ENOTTY');
|
|
279
|
-
return $.inode.flags;
|
|
149
|
+
return toFileFlags($.inode.flags);
|
|
280
150
|
},
|
|
281
151
|
[IOC32.GetFlags]($) {
|
|
282
152
|
if (typeof $.inode.flags !== 'number')
|
|
283
153
|
throw withErrno('ENOTTY');
|
|
284
|
-
return $.inode.flags;
|
|
154
|
+
return toFileFlags($.inode.flags);
|
|
285
155
|
},
|
|
286
156
|
[IOC.GetVersion]($) {
|
|
287
157
|
if (typeof $.inode.version !== 'number')
|
|
@@ -296,10 +166,10 @@ export const ioctl_default_ops = {
|
|
|
296
166
|
[IOC.Fiemap]() {
|
|
297
167
|
throw withErrno('ENOTSUP');
|
|
298
168
|
},
|
|
299
|
-
[IOC.GetXattr](
|
|
300
|
-
|
|
169
|
+
[IOC.GetXattr]() {
|
|
170
|
+
throw withErrno('ENOTSUP');
|
|
301
171
|
},
|
|
302
|
-
[IOC.SetXattr](
|
|
172
|
+
[IOC.SetXattr]() {
|
|
303
173
|
throw withErrno('ENOTSUP');
|
|
304
174
|
},
|
|
305
175
|
[IOC.GetLabel]($) {
|
|
@@ -311,13 +181,8 @@ export const ioctl_default_ops = {
|
|
|
311
181
|
[IOC.GetUUID]($) {
|
|
312
182
|
return $.fs.uuid;
|
|
313
183
|
},
|
|
314
|
-
[IOC.GetSysfsPath](
|
|
315
|
-
|
|
316
|
-
* Returns the path component under /sys/fs/ that refers to this filesystem;
|
|
317
|
-
* also /sys/kernel/debug/ for filesystems with debugfs exports
|
|
318
|
-
* @todo Implement sysfs and have each FS implement the /sys/fs/<name> tree
|
|
319
|
-
*/
|
|
320
|
-
return `/sys/fs/${$.fs.name}/${$.fs.uuid}`;
|
|
184
|
+
[IOC.GetSysfsPath]() {
|
|
185
|
+
throw withErrno('ENOTSUP');
|
|
321
186
|
},
|
|
322
187
|
};
|
|
323
188
|
/**
|
|
@@ -327,11 +192,11 @@ export const ioctl_default_ops = {
|
|
|
327
192
|
export const ioctl_default_ops_async = {
|
|
328
193
|
...ioctl_default_ops,
|
|
329
194
|
async [IOC.SetFlags]($, flags) {
|
|
330
|
-
|
|
195
|
+
setFlags($, flags);
|
|
331
196
|
await $.fs.touch($.path, $.inode);
|
|
332
197
|
},
|
|
333
198
|
async [IOC32.SetFlags]($, flags) {
|
|
334
|
-
|
|
199
|
+
setFlags($, flags);
|
|
335
200
|
await $.fs.touch($.path, $.inode);
|
|
336
201
|
},
|
|
337
202
|
async [IOC.SetVersion]($, version) {
|
|
@@ -350,11 +215,11 @@ export const ioctl_default_ops_async = {
|
|
|
350
215
|
export const ioctl_default_ops_sync = {
|
|
351
216
|
...ioctl_default_ops,
|
|
352
217
|
[IOC.SetFlags]($, flags) {
|
|
353
|
-
|
|
218
|
+
setFlags($, flags);
|
|
354
219
|
$.fs.touchSync($.path, $.inode);
|
|
355
220
|
},
|
|
356
221
|
[IOC32.SetFlags]($, flags) {
|
|
357
|
-
|
|
222
|
+
setFlags($, flags);
|
|
358
223
|
$.fs.touchSync($.path, $.inode);
|
|
359
224
|
},
|
|
360
225
|
[IOC.SetVersion]($, version) {
|
package/dist/internal/rpc.d.ts
CHANGED
|
@@ -100,15 +100,24 @@ export interface Message {
|
|
|
100
100
|
method: Method;
|
|
101
101
|
stack: string;
|
|
102
102
|
}
|
|
103
|
-
export interface
|
|
103
|
+
export interface RequestInit<TMethod extends Method = Method> {
|
|
104
104
|
method: TMethod;
|
|
105
105
|
args: Parameters<Methods[TMethod]>;
|
|
106
106
|
}
|
|
107
|
-
export
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
export type Request<TMethod extends Method = Method> = {
|
|
108
|
+
[K in Method]: Message & RequestInit<K>;
|
|
109
|
+
}[TMethod];
|
|
110
|
+
export type Response<TMethod extends Method = Method> = {
|
|
111
|
+
[K in Method]: Message & {
|
|
112
|
+
error?: WithOptional<ExceptionJSON, 'code' | 'errno'>;
|
|
113
|
+
method: K;
|
|
114
|
+
/**
|
|
115
|
+
* This is undefined if an error occurs, and we check it at runtime.
|
|
116
|
+
* We don't do the type stuff because Typescript gets confused
|
|
117
|
+
*/
|
|
118
|
+
value: ReturnType<Methods[K]>;
|
|
119
|
+
};
|
|
120
|
+
}[TMethod];
|
|
112
121
|
/**
|
|
113
122
|
* Encode a RPC message as a string using JSON.
|
|
114
123
|
* This is only done when structured cloning is not available.
|
|
@@ -130,7 +139,7 @@ export interface Executor extends PromiseWithResolvers<any> {
|
|
|
130
139
|
fs: PortFS;
|
|
131
140
|
timeout: ReturnType<typeof setTimeout>;
|
|
132
141
|
}
|
|
133
|
-
export declare function request<const
|
|
142
|
+
export declare function request<const Init extends RequestInit, TValue>(request: Init, { port, timeout: ms, fs }: Partial<Options> & {
|
|
134
143
|
fs: PortFS;
|
|
135
144
|
}): Promise<TValue>;
|
|
136
145
|
export declare function handleResponse<const TMethod extends Method>(response: Response<TMethod>): void;
|
package/dist/internal/rpc.js
CHANGED
|
@@ -160,11 +160,6 @@ export function request(request, { port, timeout: ms = 1000, fs }) {
|
|
|
160
160
|
port.send({ ...request, _zenfs: true, id, stack });
|
|
161
161
|
return promise;
|
|
162
162
|
}
|
|
163
|
-
// Why Typescript, WHY does the type need to be asserted even when the method is explicitly checked?
|
|
164
|
-
function __requestMethod(req) { }
|
|
165
|
-
function __responseMethod(res, ...t) {
|
|
166
|
-
return t.includes(res.method);
|
|
167
|
-
}
|
|
168
163
|
export function handleResponse(response) {
|
|
169
164
|
if (!isMessage(response))
|
|
170
165
|
return;
|
|
@@ -182,7 +177,7 @@ export function handleResponse(response) {
|
|
|
182
177
|
return;
|
|
183
178
|
}
|
|
184
179
|
disposeExecutors(response.id);
|
|
185
|
-
resolve(
|
|
180
|
+
resolve(['stat', 'createFile', 'mkdir'].includes(response.method) ? new Inode(response.value) : response.value);
|
|
186
181
|
return;
|
|
187
182
|
}
|
|
188
183
|
export function attach(port, handler) {
|
|
@@ -214,11 +209,9 @@ export async function handleRequest(port, fs, request) {
|
|
|
214
209
|
if (!isMessage(request))
|
|
215
210
|
return;
|
|
216
211
|
let value, error;
|
|
217
|
-
const transferList = [];
|
|
218
212
|
try {
|
|
219
213
|
switch (request.method) {
|
|
220
214
|
case 'read': {
|
|
221
|
-
__requestMethod(request);
|
|
222
215
|
const [path, buffer, start, end] = request.args;
|
|
223
216
|
await fs.read(path, buffer, start, end);
|
|
224
217
|
value = buffer;
|
|
@@ -227,7 +220,6 @@ export async function handleRequest(port, fs, request) {
|
|
|
227
220
|
case 'stat':
|
|
228
221
|
case 'createFile':
|
|
229
222
|
case 'mkdir': {
|
|
230
|
-
__requestMethod(request);
|
|
231
223
|
// @ts-expect-error 2556
|
|
232
224
|
const md = await fs[request.method](...request.args);
|
|
233
225
|
const inode = md instanceof Inode ? md : new Inode(md);
|
|
@@ -235,7 +227,6 @@ export async function handleRequest(port, fs, request) {
|
|
|
235
227
|
break;
|
|
236
228
|
}
|
|
237
229
|
case 'touch': {
|
|
238
|
-
__requestMethod(request);
|
|
239
230
|
const [path, metadata] = request.args;
|
|
240
231
|
await fs.touch(path, new Inode(metadata));
|
|
241
232
|
value = undefined;
|
|
@@ -249,5 +240,5 @@ export async function handleRequest(port, fs, request) {
|
|
|
249
240
|
catch (e) {
|
|
250
241
|
error = e instanceof Exception ? e.toJSON() : pick(e, 'message', 'stack');
|
|
251
242
|
}
|
|
252
|
-
port.send({ _zenfs: true, ...pick(request, 'id', 'method', 'stack'), error, value }
|
|
243
|
+
port.send({ _zenfs: true, ...pick(request, 'id', 'method', 'stack'), error, value });
|
|
253
244
|
}
|
package/dist/mixins/mutexed.d.ts
CHANGED
|
@@ -1,28 +1,17 @@
|
|
|
1
|
+
import { RwLockable } from 'kerium/locks';
|
|
1
2
|
import type { UUID } from 'node:crypto';
|
|
2
3
|
import type { Concrete } from 'utilium';
|
|
3
4
|
import type { CreationOptions, FileSystem, StreamOptions, UsageInfo } from '../internal/filesystem.js';
|
|
4
5
|
import type { InodeLike } from '../internal/inode.js';
|
|
5
6
|
import type { IoctlContext } from '../internal/ioctl.js';
|
|
6
7
|
import '../polyfills.js';
|
|
7
|
-
/**
|
|
8
|
-
* @category Internals
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare class MutexLock {
|
|
12
|
-
protected readonly previous?: MutexLock | undefined;
|
|
13
|
-
protected current: PromiseWithResolvers<void>;
|
|
14
|
-
protected _isLocked: boolean;
|
|
15
|
-
get isLocked(): boolean;
|
|
16
|
-
constructor(previous?: MutexLock | undefined);
|
|
17
|
-
done(): Promise<void>;
|
|
18
|
-
unlock(): void;
|
|
19
|
-
[Symbol.dispose](): void;
|
|
20
|
-
}
|
|
21
8
|
/**
|
|
22
9
|
* @hidden
|
|
23
10
|
* @category Internals
|
|
11
|
+
* @deprecated This is no longer needed and will be removed
|
|
12
|
+
* @todo [breaking] Remove
|
|
24
13
|
*/
|
|
25
|
-
export declare class _MutexedFS<T extends FileSystem> implements FileSystem {
|
|
14
|
+
export declare class _MutexedFS<T extends FileSystem> extends RwLockable implements FileSystem {
|
|
26
15
|
/**
|
|
27
16
|
* @internal
|
|
28
17
|
*/
|
|
@@ -38,31 +27,6 @@ export declare class _MutexedFS<T extends FileSystem> implements FileSystem {
|
|
|
38
27
|
ready(): Promise<void>;
|
|
39
28
|
readySync(): void;
|
|
40
29
|
usage(): UsageInfo;
|
|
41
|
-
/**
|
|
42
|
-
* The current locks
|
|
43
|
-
*/
|
|
44
|
-
private currentLock?;
|
|
45
|
-
/**
|
|
46
|
-
* Adds a lock for a path
|
|
47
|
-
*/
|
|
48
|
-
protected addLock(): MutexLock;
|
|
49
|
-
/**
|
|
50
|
-
* Locks `path` asynchronously.
|
|
51
|
-
* If the path is currently locked, waits for it to be unlocked.
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
lock(timeout?: number): Promise<MutexLock>;
|
|
55
|
-
/**
|
|
56
|
-
* Locks `path` asynchronously.
|
|
57
|
-
* If the path is currently locked, an error will be thrown
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
lockSync(): MutexLock;
|
|
61
|
-
/**
|
|
62
|
-
* Whether `path` is locked
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
get isLocked(): boolean;
|
|
66
30
|
rename(oldPath: string, newPath: string): Promise<void>;
|
|
67
31
|
renameSync(oldPath: string, newPath: string): void;
|
|
68
32
|
stat(path: string): Promise<InodeLike>;
|
|
@@ -110,9 +74,10 @@ export declare class _MutexedFS<T extends FileSystem> implements FileSystem {
|
|
|
110
74
|
* Instead of extending `FileSystem`,
|
|
111
75
|
* `MutexedFS` implements it in order to make sure all of the methods are passed through
|
|
112
76
|
*
|
|
113
|
-
* @todo Change `using _` to `using void` pending https://github.com/tc39/proposal-discard-binding
|
|
114
77
|
* @category Internals
|
|
115
78
|
* @internal
|
|
79
|
+
* @deprecated This is no longer needed and will be removed
|
|
80
|
+
* @todo [breaking] Remove
|
|
116
81
|
*/
|
|
117
82
|
export declare function Mutexed<const T extends Concrete<typeof FileSystem>>(FS: T): typeof _MutexedFS<InstanceType<T>> & {
|
|
118
83
|
new (...args: ConstructorParameters<T>): _MutexedFS<InstanceType<T>>;
|