@zenfs/core 1.11.4 → 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.d.ts +19 -15
- package/dist/backends/backend.js +36 -19
- package/dist/backends/cow.d.ts +20 -30
- package/dist/backends/cow.js +83 -192
- package/dist/backends/fetch.d.ts +1 -0
- package/dist/backends/fetch.js +30 -30
- package/dist/backends/index.d.ts +1 -1
- package/dist/backends/index.js +1 -1
- package/dist/backends/memory.d.ts +5 -7
- package/dist/backends/memory.js +2 -3
- package/dist/backends/passthrough.d.ts +19 -23
- package/dist/backends/passthrough.js +98 -288
- package/dist/backends/port.d.ts +220 -0
- package/dist/backends/port.js +328 -0
- package/dist/backends/single_buffer.d.ts +59 -47
- package/dist/backends/single_buffer.js +468 -219
- package/dist/backends/store/fs.d.ts +25 -35
- package/dist/backends/store/fs.js +276 -315
- package/dist/backends/store/store.d.ts +10 -15
- package/dist/backends/store/store.js +11 -10
- package/dist/config.d.ts +3 -12
- package/dist/config.js +17 -19
- package/dist/context.d.ts +8 -21
- package/dist/context.js +33 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/contexts.d.ts +63 -0
- package/dist/internal/contexts.js +15 -0
- package/dist/internal/credentials.d.ts +2 -11
- package/dist/internal/credentials.js +0 -19
- package/dist/internal/devices.d.ts +18 -80
- package/dist/internal/devices.js +103 -316
- 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 +11 -11
- package/dist/internal/filesystem.d.ts +51 -94
- package/dist/internal/filesystem.js +21 -20
- package/dist/internal/index.d.ts +1 -2
- package/dist/internal/index.js +1 -2
- package/dist/internal/index_fs.d.ts +12 -30
- package/dist/internal/index_fs.js +37 -69
- package/dist/internal/inode.d.ts +140 -24
- package/dist/internal/inode.js +515 -66
- package/dist/mixins/async.js +52 -112
- package/dist/mixins/mutexed.d.ts +19 -18
- package/dist/mixins/mutexed.js +62 -64
- package/dist/mixins/readonly.d.ts +7 -6
- package/dist/mixins/readonly.js +24 -18
- package/dist/mixins/sync.js +8 -8
- package/dist/{vfs/path.d.ts → path.d.ts} +3 -4
- package/dist/{vfs/path.js → path.js} +6 -9
- package/dist/polyfills.js +1 -1
- package/dist/readline.d.ts +134 -0
- package/dist/readline.js +623 -0
- package/dist/utils.d.ts +9 -37
- package/dist/utils.js +17 -85
- package/dist/vfs/acl.d.ts +42 -0
- package/dist/vfs/acl.js +268 -0
- package/dist/vfs/async.d.ts +9 -23
- package/dist/vfs/async.js +25 -27
- package/dist/vfs/config.d.ts +6 -18
- package/dist/vfs/config.js +8 -18
- package/dist/vfs/dir.d.ts +3 -3
- package/dist/vfs/dir.js +12 -12
- package/dist/vfs/file.d.ts +106 -0
- package/dist/vfs/file.js +244 -0
- package/dist/vfs/flags.d.ts +19 -0
- package/dist/vfs/flags.js +62 -0
- package/dist/vfs/index.d.ts +4 -10
- package/dist/vfs/index.js +4 -13
- package/dist/vfs/ioctl.d.ts +88 -0
- package/dist/vfs/ioctl.js +409 -0
- package/dist/vfs/promises.d.ts +81 -19
- package/dist/vfs/promises.js +404 -288
- package/dist/vfs/shared.d.ts +7 -37
- package/dist/vfs/shared.js +29 -85
- package/dist/{stats.d.ts → vfs/stats.d.ts} +14 -28
- package/dist/{stats.js → vfs/stats.js} +11 -66
- package/dist/vfs/streams.d.ts +1 -0
- package/dist/vfs/streams.js +32 -27
- package/dist/vfs/sync.d.ts +3 -3
- package/dist/vfs/sync.js +263 -260
- package/dist/vfs/watchers.d.ts +2 -2
- package/dist/vfs/watchers.js +12 -12
- package/dist/vfs/xattr.d.ts +116 -0
- package/dist/vfs/xattr.js +201 -0
- package/package.json +5 -3
- package/readme.md +1 -1
- package/scripts/test.js +2 -2
- package/tests/assignment.ts +1 -1
- package/tests/backend/config.worker.js +4 -1
- package/tests/backend/fetch.test.ts +3 -0
- package/tests/backend/port.test.ts +19 -33
- package/tests/backend/remote.worker.js +4 -1
- package/tests/backend/single-buffer.test.ts +53 -0
- package/tests/backend/single-buffer.worker.js +30 -0
- package/tests/common/context.test.ts +3 -3
- package/tests/common/handle.test.ts +17 -12
- package/tests/common/mutex.test.ts +9 -9
- package/tests/common/path.test.ts +1 -1
- package/tests/common/readline.test.ts +104 -0
- package/tests/common.ts +4 -19
- package/tests/fetch/fetch.ts +2 -2
- 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 +4 -3
- package/tests/fs/open.test.ts +4 -21
- package/tests/fs/permissions.test.ts +14 -18
- package/tests/fs/read.test.ts +10 -9
- package/tests/fs/readFile.test.ts +10 -26
- package/tests/fs/rename.test.ts +4 -9
- package/tests/fs/stat.test.ts +8 -8
- package/tests/fs/streams.test.ts +2 -11
- package/tests/fs/times.test.ts +7 -7
- 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 +85 -0
- package/tests/logs.js +22 -0
- package/tests/setup/context.ts +1 -1
- package/tests/setup/index.ts +3 -3
- package/tests/setup/port.ts +7 -1
- package/dist/backends/port/fs.d.ts +0 -84
- package/dist/backends/port/fs.js +0 -151
- package/dist/backends/port/rpc.d.ts +0 -77
- package/dist/backends/port/rpc.js +0 -100
- package/dist/backends/store/simple.d.ts +0 -20
- package/dist/backends/store/simple.js +0 -13
- package/dist/internal/file.d.ts +0 -359
- package/dist/internal/file.js +0 -751
- package/dist/internal/log.d.ts +0 -133
- package/dist/internal/log.js +0 -218
- package/tests/fs/writeFile.test.ts +0 -70
package/dist/internal/inode.js
CHANGED
|
@@ -36,39 +36,326 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
36
36
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
37
37
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
40
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
41
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
42
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
43
|
+
};
|
|
44
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
45
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
46
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
47
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
48
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
49
|
+
};
|
|
50
|
+
import { withErrno } from 'kerium';
|
|
51
|
+
import { crit, warn } from 'kerium/log';
|
|
52
|
+
import { field, packed, sizeof, struct, types as t } from 'memium';
|
|
53
|
+
import { decodeUTF8, encodeUTF8, pick } from 'utilium';
|
|
54
|
+
import { BufferView } from 'utilium/buffer.js';
|
|
55
|
+
import * as c from '../vfs/constants.js';
|
|
56
|
+
import { Stats } from '../vfs/stats.js';
|
|
57
|
+
import { defaultContext } from './contexts.js';
|
|
43
58
|
/**
|
|
44
59
|
* Root inode
|
|
45
60
|
* @hidden
|
|
46
61
|
*/
|
|
47
62
|
export const rootIno = 0;
|
|
63
|
+
/** 4 KiB minus static inode data */
|
|
64
|
+
const maxDynamicData = 3968;
|
|
65
|
+
let Attribute = (() => {
|
|
66
|
+
var _Attribute_keySize_accessor_storage, _Attribute_valueSize_accessor_storage;
|
|
67
|
+
var _a, _b;
|
|
68
|
+
let _classDecorators = [struct(packed)];
|
|
69
|
+
let _classDescriptor;
|
|
70
|
+
let _classExtraInitializers = [];
|
|
71
|
+
let _classThis;
|
|
72
|
+
let _classSuper = Uint8Array;
|
|
73
|
+
let _keySize_decorators;
|
|
74
|
+
let _keySize_initializers = [];
|
|
75
|
+
let _keySize_extraInitializers = [];
|
|
76
|
+
let _valueSize_decorators;
|
|
77
|
+
let _valueSize_initializers = [];
|
|
78
|
+
let _valueSize_extraInitializers = [];
|
|
79
|
+
var Attribute = _classThis = class extends _classSuper {
|
|
80
|
+
get keySize() { return __classPrivateFieldGet(this, _Attribute_keySize_accessor_storage, "f"); }
|
|
81
|
+
set keySize(value) { __classPrivateFieldSet(this, _Attribute_keySize_accessor_storage, value, "f"); }
|
|
82
|
+
get valueSize() { return __classPrivateFieldGet(this, _Attribute_valueSize_accessor_storage, "f"); }
|
|
83
|
+
set valueSize(value) { __classPrivateFieldSet(this, _Attribute_valueSize_accessor_storage, value, "f"); }
|
|
84
|
+
get name() {
|
|
85
|
+
return decodeUTF8(this.subarray(8, 8 + this.keySize));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Note that this does not handle moving the data.
|
|
89
|
+
* Changing the name after setting the value is undefined behavior and will lead to corruption.
|
|
90
|
+
* This should only be used when creating a new attribute.
|
|
91
|
+
*/
|
|
92
|
+
set name(value) {
|
|
93
|
+
const buf = encodeUTF8(value);
|
|
94
|
+
if (8 + buf.length + this.valueSize > maxDynamicData)
|
|
95
|
+
throw withErrno('EOVERFLOW');
|
|
96
|
+
this.set(buf, 8);
|
|
97
|
+
this.keySize = buf.length;
|
|
98
|
+
}
|
|
99
|
+
get value() {
|
|
100
|
+
return this.subarray(8 + this.keySize, this.size);
|
|
101
|
+
}
|
|
102
|
+
set value(value) {
|
|
103
|
+
if (8 + this.keySize + value.length > maxDynamicData)
|
|
104
|
+
throw withErrno('EOVERFLOW');
|
|
105
|
+
this.valueSize = value.length;
|
|
106
|
+
this.set(value, 8 + this.keySize);
|
|
107
|
+
}
|
|
108
|
+
get size() {
|
|
109
|
+
return 8 + this.keySize + this.valueSize;
|
|
110
|
+
}
|
|
111
|
+
constructor() {
|
|
112
|
+
super(...arguments);
|
|
113
|
+
_Attribute_keySize_accessor_storage.set(this, __runInitializers(this, _keySize_initializers, void 0));
|
|
114
|
+
_Attribute_valueSize_accessor_storage.set(this, (__runInitializers(this, _keySize_extraInitializers), __runInitializers(this, _valueSize_initializers, void 0)));
|
|
115
|
+
__runInitializers(this, _valueSize_extraInitializers);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
_Attribute_keySize_accessor_storage = new WeakMap();
|
|
119
|
+
_Attribute_valueSize_accessor_storage = new WeakMap();
|
|
120
|
+
__setFunctionName(_classThis, "Attribute");
|
|
121
|
+
(() => {
|
|
122
|
+
var _a;
|
|
123
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
124
|
+
_keySize_decorators = [(_a = t).uint32.bind(_a)];
|
|
125
|
+
_valueSize_decorators = [(_b = t).uint32.bind(_b)];
|
|
126
|
+
__esDecorate(_classThis, null, _keySize_decorators, { kind: "accessor", name: "keySize", static: false, private: false, access: { has: obj => "keySize" in obj, get: obj => obj.keySize, set: (obj, value) => { obj.keySize = value; } }, metadata: _metadata }, _keySize_initializers, _keySize_extraInitializers);
|
|
127
|
+
__esDecorate(_classThis, null, _valueSize_decorators, { kind: "accessor", name: "valueSize", static: false, private: false, access: { has: obj => "valueSize" in obj, get: obj => obj.valueSize, set: (obj, value) => { obj.valueSize = value; } }, metadata: _metadata }, _valueSize_initializers, _valueSize_extraInitializers);
|
|
128
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
129
|
+
Attribute = _classThis = _classDescriptor.value;
|
|
130
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
131
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
132
|
+
})();
|
|
133
|
+
return Attribute = _classThis;
|
|
134
|
+
})();
|
|
135
|
+
/**
|
|
136
|
+
* Extended attributes
|
|
137
|
+
* @category Internals
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
let Attributes = (() => {
|
|
141
|
+
var _Attributes_size_accessor_storage;
|
|
142
|
+
var _a;
|
|
143
|
+
let _classDecorators = [struct(packed)];
|
|
144
|
+
let _classDescriptor;
|
|
145
|
+
let _classExtraInitializers = [];
|
|
146
|
+
let _classThis;
|
|
147
|
+
let _classSuper = BufferView;
|
|
148
|
+
let _size_decorators;
|
|
149
|
+
let _size_initializers = [];
|
|
150
|
+
let _size_extraInitializers = [];
|
|
151
|
+
var Attributes = _classThis = class extends _classSuper {
|
|
152
|
+
get size() { return __classPrivateFieldGet(this, _Attributes_size_accessor_storage, "f"); }
|
|
153
|
+
set size(value) { __classPrivateFieldSet(this, _Attributes_size_accessor_storage, value, "f"); }
|
|
154
|
+
get byteSize() {
|
|
155
|
+
let offset = this.byteOffset + sizeof(this);
|
|
156
|
+
for (let i = 0; i < this.size; i++) {
|
|
157
|
+
const entry = new Attribute(this.buffer, offset);
|
|
158
|
+
offset += entry.size;
|
|
159
|
+
}
|
|
160
|
+
return offset;
|
|
161
|
+
}
|
|
162
|
+
has(name) {
|
|
163
|
+
let offset = this.byteOffset + sizeof(this);
|
|
164
|
+
for (let i = 0; i < this.size; i++) {
|
|
165
|
+
const entry = new Attribute(this.buffer, offset);
|
|
166
|
+
if (entry.name == name)
|
|
167
|
+
return true;
|
|
168
|
+
offset += entry.size;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
get(name) {
|
|
173
|
+
let offset = this.byteOffset + sizeof(this);
|
|
174
|
+
for (let i = 0; i < this.size; i++) {
|
|
175
|
+
const entry = new Attribute(this.buffer, offset);
|
|
176
|
+
if (entry.name == name)
|
|
177
|
+
return entry.value;
|
|
178
|
+
offset += entry.size;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
set(name, value) {
|
|
182
|
+
let offset = this.byteOffset + sizeof(this);
|
|
183
|
+
let remove;
|
|
184
|
+
for (let i = 0; i < this.size; i++) {
|
|
185
|
+
const entry = new Attribute(this.buffer, offset);
|
|
186
|
+
if (entry.name == name)
|
|
187
|
+
remove = [offset, entry.size];
|
|
188
|
+
offset += entry.size;
|
|
189
|
+
}
|
|
190
|
+
const buf = new Uint8Array(this.buffer);
|
|
191
|
+
if (remove) {
|
|
192
|
+
const [start, size] = remove;
|
|
193
|
+
offset -= size;
|
|
194
|
+
buf.copyWithin(start, start + size, offset + size);
|
|
195
|
+
buf.fill(0, offset, offset + size);
|
|
196
|
+
this.size--;
|
|
197
|
+
}
|
|
198
|
+
const attr = new Attribute(this.buffer, offset);
|
|
199
|
+
attr.name = name;
|
|
200
|
+
attr.value = value;
|
|
201
|
+
this.size++;
|
|
202
|
+
}
|
|
203
|
+
remove(name) {
|
|
204
|
+
let offset = this.byteOffset + sizeof(this);
|
|
205
|
+
let remove;
|
|
206
|
+
for (let i = 0; i < this.size; i++) {
|
|
207
|
+
const entry = new Attribute(this.buffer, offset);
|
|
208
|
+
if (entry.name == name)
|
|
209
|
+
remove = [offset, entry.size];
|
|
210
|
+
offset += entry.size;
|
|
211
|
+
}
|
|
212
|
+
if (!remove)
|
|
213
|
+
return false;
|
|
214
|
+
const [start, size] = remove;
|
|
215
|
+
const buf = new Uint8Array(this.buffer);
|
|
216
|
+
buf.copyWithin(start, start + size, offset);
|
|
217
|
+
buf.fill(0, offset - size, offset);
|
|
218
|
+
this.size--;
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
copyFrom(other) {
|
|
222
|
+
const { byteSize } = other;
|
|
223
|
+
new Uint8Array(this.buffer, this.byteOffset, byteSize).set(new Uint8Array(other.buffer, other.byteOffset, byteSize));
|
|
224
|
+
}
|
|
225
|
+
*keys() {
|
|
226
|
+
let offset = this.byteOffset + sizeof(this);
|
|
227
|
+
for (let i = 0; i < this.size; i++) {
|
|
228
|
+
const entry = new Attribute(this.buffer, offset);
|
|
229
|
+
yield entry.name;
|
|
230
|
+
offset += entry.size;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
*values() {
|
|
234
|
+
let offset = this.byteOffset + sizeof(this);
|
|
235
|
+
for (let i = 0; i < this.size; i++) {
|
|
236
|
+
const entry = new Attribute(this.buffer, offset);
|
|
237
|
+
yield entry.value;
|
|
238
|
+
offset += entry.size;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
*entries() {
|
|
242
|
+
let offset = this.byteOffset + sizeof(this);
|
|
243
|
+
for (let i = 0; i < this.size; i++) {
|
|
244
|
+
const entry = new Attribute(this.buffer, offset);
|
|
245
|
+
yield [entry.name, entry.value];
|
|
246
|
+
offset += entry.size;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
constructor() {
|
|
250
|
+
super(...arguments);
|
|
251
|
+
_Attributes_size_accessor_storage.set(this, __runInitializers(this, _size_initializers, void 0));
|
|
252
|
+
__runInitializers(this, _size_extraInitializers);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
_Attributes_size_accessor_storage = new WeakMap();
|
|
256
|
+
__setFunctionName(_classThis, "Attributes");
|
|
257
|
+
(() => {
|
|
258
|
+
var _a;
|
|
259
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
260
|
+
_size_decorators = [(_a = t).uint32.bind(_a)];
|
|
261
|
+
__esDecorate(_classThis, null, _size_decorators, { kind: "accessor", name: "size", static: false, private: false, access: { has: obj => "size" in obj, get: obj => obj.size, set: (obj, value) => { obj.size = value; } }, metadata: _metadata }, _size_initializers, _size_extraInitializers);
|
|
262
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
263
|
+
Attributes = _classThis = _classDescriptor.value;
|
|
264
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
265
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
266
|
+
})();
|
|
267
|
+
return Attributes = _classThis;
|
|
268
|
+
})();
|
|
269
|
+
export { Attributes };
|
|
48
270
|
/**
|
|
49
271
|
* @internal @hidden
|
|
50
272
|
*/
|
|
51
|
-
export const _inode_fields = [
|
|
273
|
+
export const _inode_fields = [
|
|
274
|
+
'ino',
|
|
275
|
+
'data',
|
|
276
|
+
'size',
|
|
277
|
+
'mode',
|
|
278
|
+
'flags',
|
|
279
|
+
'nlink',
|
|
280
|
+
'uid',
|
|
281
|
+
'gid',
|
|
282
|
+
'atimeMs',
|
|
283
|
+
'birthtimeMs',
|
|
284
|
+
'mtimeMs',
|
|
285
|
+
'ctimeMs',
|
|
286
|
+
'version',
|
|
287
|
+
];
|
|
52
288
|
/**
|
|
53
289
|
* Represents which version of the `Inode` format we are on.
|
|
54
290
|
* 1. 58 bytes. The first member was called `ino` but used as the ID for data.
|
|
55
291
|
* 2. 66 bytes. Renamed the first member from `ino` to `data` and added a separate `ino` field
|
|
56
|
-
* 3.
|
|
292
|
+
* 3. 72 bytes. Changed the ID fields from 64 to 32 bits and added `flags`.
|
|
293
|
+
* 4. >= 128 bytes. Added extended attributes.
|
|
294
|
+
* 5. (current) 4 KiB. Changed flags
|
|
57
295
|
* @internal @hidden
|
|
58
296
|
*/
|
|
59
|
-
export const _inode_version =
|
|
297
|
+
export const _inode_version = 5;
|
|
298
|
+
/**
|
|
299
|
+
* Inode flags
|
|
300
|
+
* @see `S_*` in `include/linux/fs.h` (around L2325)
|
|
301
|
+
* @experimental
|
|
302
|
+
*/
|
|
303
|
+
export var InodeFlags;
|
|
304
|
+
(function (InodeFlags) {
|
|
305
|
+
/** Writes are synced at once */
|
|
306
|
+
InodeFlags[InodeFlags["Sync"] = 1] = "Sync";
|
|
307
|
+
/** Do not update access times */
|
|
308
|
+
InodeFlags[InodeFlags["NoAtime"] = 2] = "NoAtime";
|
|
309
|
+
/** Append-only file */
|
|
310
|
+
InodeFlags[InodeFlags["Append"] = 4] = "Append";
|
|
311
|
+
/** Immutable file */
|
|
312
|
+
InodeFlags[InodeFlags["Immutable"] = 8] = "Immutable";
|
|
313
|
+
/** removed, but still open directory */
|
|
314
|
+
InodeFlags[InodeFlags["Dead"] = 16] = "Dead";
|
|
315
|
+
/** Inode is not counted to quota */
|
|
316
|
+
InodeFlags[InodeFlags["NoQuota"] = 32] = "NoQuota";
|
|
317
|
+
/** Directory modifications are synchronous */
|
|
318
|
+
InodeFlags[InodeFlags["Dirsync"] = 64] = "Dirsync";
|
|
319
|
+
/** Do not update file c/mtime */
|
|
320
|
+
InodeFlags[InodeFlags["NoCMtime"] = 128] = "NoCMtime";
|
|
321
|
+
/** Do not truncate: swapon got its bmaps */
|
|
322
|
+
InodeFlags[InodeFlags["SwapFile"] = 256] = "SwapFile";
|
|
323
|
+
/** Inode is fs-internal */
|
|
324
|
+
InodeFlags[InodeFlags["Private"] = 512] = "Private";
|
|
325
|
+
/** Inode has an associated IMA struct */
|
|
326
|
+
InodeFlags[InodeFlags["IMA"] = 1024] = "IMA";
|
|
327
|
+
/** Automount/referral quasi-directory */
|
|
328
|
+
InodeFlags[InodeFlags["AutoMount"] = 2048] = "AutoMount";
|
|
329
|
+
/** no suid or xattr security attributes */
|
|
330
|
+
InodeFlags[InodeFlags["NoSec"] = 4096] = "NoSec";
|
|
331
|
+
/** Direct Access, avoiding the page cache */
|
|
332
|
+
InodeFlags[InodeFlags["DAX"] = 8192] = "DAX";
|
|
333
|
+
/** Encrypted file (using fs/crypto/) */
|
|
334
|
+
InodeFlags[InodeFlags["Encrypted"] = 16384] = "Encrypted";
|
|
335
|
+
/** Casefolded file */
|
|
336
|
+
InodeFlags[InodeFlags["CaseFold"] = 32768] = "CaseFold";
|
|
337
|
+
/** Verity file (using fs/verity/) */
|
|
338
|
+
InodeFlags[InodeFlags["Verity"] = 65536] = "Verity";
|
|
339
|
+
/** File is in use by the kernel (eg. fs/cachefiles) */
|
|
340
|
+
InodeFlags[InodeFlags["KernelFile"] = 131072] = "KernelFile";
|
|
341
|
+
})(InodeFlags || (InodeFlags = {}));
|
|
342
|
+
/** User visible flags */
|
|
343
|
+
export const userVisibleFlags = 0x0003dfff;
|
|
344
|
+
/** User modifiable flags */
|
|
345
|
+
export const userModifiableFlags = 0x000380ff;
|
|
60
346
|
/**
|
|
61
347
|
* Generic inode definition that can easily be serialized.
|
|
62
348
|
* @category Internals
|
|
63
349
|
* @internal
|
|
64
|
-
* @todo [BREAKING] Remove 58 byte Inode upgrade path
|
|
65
350
|
*/
|
|
66
351
|
let Inode = (() => {
|
|
67
|
-
var
|
|
68
|
-
|
|
352
|
+
var _Inode_data_accessor_storage, _Inode___data_old_accessor_storage, _Inode_size_accessor_storage, _Inode_mode_accessor_storage, _Inode_nlink_accessor_storage, _Inode_uid_accessor_storage, _Inode_gid_accessor_storage, _Inode_atimeMs_accessor_storage, _Inode_birthtimeMs_accessor_storage, _Inode_mtimeMs_accessor_storage, _Inode_ctimeMs_accessor_storage, _Inode_ino_accessor_storage, _Inode___ino_old_accessor_storage, _Inode_flags_accessor_storage, _Inode___after_flags_accessor_storage, _Inode_version_accessor_storage, _Inode___padding_accessor_storage, _Inode_attributes_accessor_storage, _Inode___data_accessor_storage;
|
|
353
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
354
|
+
let _classDecorators = [struct(packed)];
|
|
69
355
|
let _classDescriptor;
|
|
70
356
|
let _classExtraInitializers = [];
|
|
71
357
|
let _classThis;
|
|
358
|
+
let _classSuper = BufferView;
|
|
72
359
|
let _data_decorators;
|
|
73
360
|
let _data_initializers = [];
|
|
74
361
|
let _data_extraInitializers = [];
|
|
@@ -111,54 +398,129 @@ let Inode = (() => {
|
|
|
111
398
|
let _flags_decorators;
|
|
112
399
|
let _flags_initializers = [];
|
|
113
400
|
let _flags_extraInitializers = [];
|
|
401
|
+
let ___after_flags_decorators;
|
|
402
|
+
let ___after_flags_initializers = [];
|
|
403
|
+
let ___after_flags_extraInitializers = [];
|
|
404
|
+
let _version_decorators;
|
|
405
|
+
let _version_initializers = [];
|
|
406
|
+
let _version_extraInitializers = [];
|
|
114
407
|
let ___padding_decorators;
|
|
115
408
|
let ___padding_initializers = [];
|
|
116
409
|
let ___padding_extraInitializers = [];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.mtimeMs = (__runInitializers(this, _birthtimeMs_extraInitializers), __runInitializers(this, _mtimeMs_initializers, Date.now()));
|
|
130
|
-
this.ctimeMs = (__runInitializers(this, _mtimeMs_extraInitializers), __runInitializers(this, _ctimeMs_initializers, Date.now()));
|
|
131
|
-
this.ino = (__runInitializers(this, _ctimeMs_extraInitializers), __runInitializers(this, _ino_initializers, randomInt(0, size_max)));
|
|
132
|
-
/** For future use */
|
|
133
|
-
this.__ino_old = (__runInitializers(this, _ino_extraInitializers), __runInitializers(this, ___ino_old_initializers, 0));
|
|
134
|
-
this.flags = (__runInitializers(this, ___ino_old_extraInitializers), __runInitializers(this, _flags_initializers, 0));
|
|
135
|
-
/** For future use */
|
|
136
|
-
this.__padding = (__runInitializers(this, _flags_extraInitializers), __runInitializers(this, ___padding_initializers, 0));
|
|
137
|
-
__runInitializers(this, ___padding_extraInitializers);
|
|
138
|
-
if (!data)
|
|
139
|
-
return;
|
|
140
|
-
if (!('byteLength' in data)) {
|
|
141
|
-
Object.assign(this, data);
|
|
142
|
-
return;
|
|
410
|
+
let _attributes_decorators;
|
|
411
|
+
let _attributes_initializers = [];
|
|
412
|
+
let _attributes_extraInitializers = [];
|
|
413
|
+
let ___data_decorators;
|
|
414
|
+
let ___data_initializers = [];
|
|
415
|
+
let ___data_extraInitializers = [];
|
|
416
|
+
var Inode = _classThis = class extends _classSuper {
|
|
417
|
+
constructor(...args) {
|
|
418
|
+
let data = {};
|
|
419
|
+
if (typeof args[0] === 'object' && args[0] !== null && !ArrayBuffer.isView(args[0])) {
|
|
420
|
+
data = args[0];
|
|
421
|
+
args = [sizeof(Inode)];
|
|
143
422
|
}
|
|
144
|
-
|
|
145
|
-
|
|
423
|
+
super(...args);
|
|
424
|
+
_Inode_data_accessor_storage.set(this, __runInitializers(this, _data_initializers, void 0));
|
|
425
|
+
_Inode___data_old_accessor_storage.set(this, (__runInitializers(this, _data_extraInitializers), __runInitializers(this, ___data_old_initializers, void 0)));
|
|
426
|
+
_Inode_size_accessor_storage.set(this, (__runInitializers(this, ___data_old_extraInitializers), __runInitializers(this, _size_initializers, void 0)));
|
|
427
|
+
_Inode_mode_accessor_storage.set(this, (__runInitializers(this, _size_extraInitializers), __runInitializers(this, _mode_initializers, void 0)));
|
|
428
|
+
_Inode_nlink_accessor_storage.set(this, (__runInitializers(this, _mode_extraInitializers), __runInitializers(this, _nlink_initializers, void 0)));
|
|
429
|
+
_Inode_uid_accessor_storage.set(this, (__runInitializers(this, _nlink_extraInitializers), __runInitializers(this, _uid_initializers, void 0)));
|
|
430
|
+
_Inode_gid_accessor_storage.set(this, (__runInitializers(this, _uid_extraInitializers), __runInitializers(this, _gid_initializers, void 0)));
|
|
431
|
+
_Inode_atimeMs_accessor_storage.set(this, (__runInitializers(this, _gid_extraInitializers), __runInitializers(this, _atimeMs_initializers, void 0)));
|
|
432
|
+
_Inode_birthtimeMs_accessor_storage.set(this, (__runInitializers(this, _atimeMs_extraInitializers), __runInitializers(this, _birthtimeMs_initializers, void 0)));
|
|
433
|
+
_Inode_mtimeMs_accessor_storage.set(this, (__runInitializers(this, _birthtimeMs_extraInitializers), __runInitializers(this, _mtimeMs_initializers, void 0)));
|
|
434
|
+
_Inode_ctimeMs_accessor_storage.set(this, (__runInitializers(this, _mtimeMs_extraInitializers), __runInitializers(this, _ctimeMs_initializers, void 0)));
|
|
435
|
+
_Inode_ino_accessor_storage.set(this, (__runInitializers(this, _ctimeMs_extraInitializers), __runInitializers(this, _ino_initializers, void 0)));
|
|
436
|
+
_Inode___ino_old_accessor_storage.set(this, (__runInitializers(this, _ino_extraInitializers), __runInitializers(this, ___ino_old_initializers, void 0)));
|
|
437
|
+
_Inode_flags_accessor_storage.set(this, (__runInitializers(this, ___ino_old_extraInitializers), __runInitializers(this, _flags_initializers, void 0)));
|
|
438
|
+
_Inode___after_flags_accessor_storage.set(this, (__runInitializers(this, _flags_extraInitializers), __runInitializers(this, ___after_flags_initializers, void 0)));
|
|
439
|
+
_Inode_version_accessor_storage.set(this, (__runInitializers(this, ___after_flags_extraInitializers), __runInitializers(this, _version_initializers, void 0)));
|
|
440
|
+
_Inode___padding_accessor_storage.set(this, (__runInitializers(this, _version_extraInitializers), __runInitializers(this, ___padding_initializers, void 0)));
|
|
441
|
+
_Inode_attributes_accessor_storage.set(this, (__runInitializers(this, ___padding_extraInitializers), __runInitializers(this, _attributes_initializers, void 0)));
|
|
442
|
+
_Inode___data_accessor_storage.set(this, (__runInitializers(this, _attributes_extraInitializers), __runInitializers(this, ___data_initializers, void 0)));
|
|
443
|
+
__runInitializers(this, ___data_extraInitializers);
|
|
444
|
+
if (this.byteLength < sizeof(Inode)) {
|
|
445
|
+
throw crit(withErrno('EIO', `Buffer is too small to create an inode (${this.byteLength} bytes)`));
|
|
146
446
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
447
|
+
Object.assign(this, data);
|
|
448
|
+
this.atimeMs || (this.atimeMs = Date.now());
|
|
449
|
+
this.mtimeMs || (this.mtimeMs = Date.now());
|
|
450
|
+
this.ctimeMs || (this.ctimeMs = Date.now());
|
|
451
|
+
this.birthtimeMs || (this.birthtimeMs = Date.now());
|
|
452
|
+
if (this.ino && !this.nlink) {
|
|
453
|
+
warn(`Inode ${this.ino} has an nlink of 0`);
|
|
154
454
|
}
|
|
155
|
-
deserialize(this, data);
|
|
156
455
|
}
|
|
456
|
+
get data() { return __classPrivateFieldGet(this, _Inode_data_accessor_storage, "f"); }
|
|
457
|
+
set data(value) { __classPrivateFieldSet(this, _Inode_data_accessor_storage, value, "f"); }
|
|
458
|
+
/** For future use */
|
|
459
|
+
get __data_old() { return __classPrivateFieldGet(this, _Inode___data_old_accessor_storage, "f"); }
|
|
460
|
+
set __data_old(value) { __classPrivateFieldSet(this, _Inode___data_old_accessor_storage, value, "f"); }
|
|
461
|
+
get size() { return __classPrivateFieldGet(this, _Inode_size_accessor_storage, "f"); }
|
|
462
|
+
set size(value) { __classPrivateFieldSet(this, _Inode_size_accessor_storage, value, "f"); }
|
|
463
|
+
get mode() { return __classPrivateFieldGet(this, _Inode_mode_accessor_storage, "f"); }
|
|
464
|
+
set mode(value) { __classPrivateFieldSet(this, _Inode_mode_accessor_storage, value, "f"); }
|
|
465
|
+
get nlink() { return __classPrivateFieldGet(this, _Inode_nlink_accessor_storage, "f"); }
|
|
466
|
+
set nlink(value) { __classPrivateFieldSet(this, _Inode_nlink_accessor_storage, value, "f"); }
|
|
467
|
+
get uid() { return __classPrivateFieldGet(this, _Inode_uid_accessor_storage, "f"); }
|
|
468
|
+
set uid(value) { __classPrivateFieldSet(this, _Inode_uid_accessor_storage, value, "f"); }
|
|
469
|
+
get gid() { return __classPrivateFieldGet(this, _Inode_gid_accessor_storage, "f"); }
|
|
470
|
+
set gid(value) { __classPrivateFieldSet(this, _Inode_gid_accessor_storage, value, "f"); }
|
|
471
|
+
get atimeMs() { return __classPrivateFieldGet(this, _Inode_atimeMs_accessor_storage, "f"); }
|
|
472
|
+
set atimeMs(value) { __classPrivateFieldSet(this, _Inode_atimeMs_accessor_storage, value, "f"); }
|
|
473
|
+
get birthtimeMs() { return __classPrivateFieldGet(this, _Inode_birthtimeMs_accessor_storage, "f"); }
|
|
474
|
+
set birthtimeMs(value) { __classPrivateFieldSet(this, _Inode_birthtimeMs_accessor_storage, value, "f"); }
|
|
475
|
+
get mtimeMs() { return __classPrivateFieldGet(this, _Inode_mtimeMs_accessor_storage, "f"); }
|
|
476
|
+
set mtimeMs(value) { __classPrivateFieldSet(this, _Inode_mtimeMs_accessor_storage, value, "f"); }
|
|
477
|
+
/**
|
|
478
|
+
* The time the inode was changed.
|
|
479
|
+
*
|
|
480
|
+
* This is automatically updated whenever changed are made using `update()`.
|
|
481
|
+
*/
|
|
482
|
+
get ctimeMs() { return __classPrivateFieldGet(this, _Inode_ctimeMs_accessor_storage, "f"); }
|
|
483
|
+
set ctimeMs(value) { __classPrivateFieldSet(this, _Inode_ctimeMs_accessor_storage, value, "f"); }
|
|
484
|
+
get ino() { return __classPrivateFieldGet(this, _Inode_ino_accessor_storage, "f"); }
|
|
485
|
+
set ino(value) { __classPrivateFieldSet(this, _Inode_ino_accessor_storage, value, "f"); }
|
|
486
|
+
/** For future use */
|
|
487
|
+
get __ino_old() { return __classPrivateFieldGet(this, _Inode___ino_old_accessor_storage, "f"); }
|
|
488
|
+
set __ino_old(value) { __classPrivateFieldSet(this, _Inode___ino_old_accessor_storage, value, "f"); }
|
|
489
|
+
get flags() { return __classPrivateFieldGet(this, _Inode_flags_accessor_storage, "f"); }
|
|
490
|
+
set flags(value) { __classPrivateFieldSet(this, _Inode_flags_accessor_storage, value, "f"); }
|
|
491
|
+
/** For future use */
|
|
492
|
+
get __after_flags() { return __classPrivateFieldGet(this, _Inode___after_flags_accessor_storage, "f"); }
|
|
493
|
+
set __after_flags(value) { __classPrivateFieldSet(this, _Inode___after_flags_accessor_storage, value, "f"); }
|
|
494
|
+
/**
|
|
495
|
+
* The "version" of the inode/data.
|
|
496
|
+
* Unrelated to the inode format!
|
|
497
|
+
*/
|
|
498
|
+
get version() { return __classPrivateFieldGet(this, _Inode_version_accessor_storage, "f"); }
|
|
499
|
+
set version(value) { __classPrivateFieldSet(this, _Inode_version_accessor_storage, value, "f"); }
|
|
500
|
+
/**
|
|
501
|
+
* Padding up to 128 bytes.
|
|
502
|
+
* This ensures there is enough room for expansion without breaking the ABI.
|
|
503
|
+
* @internal
|
|
504
|
+
*/
|
|
505
|
+
get __padding() { return __classPrivateFieldGet(this, _Inode___padding_accessor_storage, "f"); }
|
|
506
|
+
set __padding(value) { __classPrivateFieldSet(this, _Inode___padding_accessor_storage, value, "f"); }
|
|
507
|
+
get attributes() { return __classPrivateFieldGet(this, _Inode_attributes_accessor_storage, "f"); }
|
|
508
|
+
set attributes(value) { __classPrivateFieldSet(this, _Inode_attributes_accessor_storage, value, "f"); }
|
|
509
|
+
/**
|
|
510
|
+
* Since the attribute data uses dynamic arrays,
|
|
511
|
+
* it is necessary to add this so attributes can be added.
|
|
512
|
+
* @internal @hidden
|
|
513
|
+
*/
|
|
514
|
+
get __data() { return __classPrivateFieldGet(this, _Inode___data_accessor_storage, "f"); }
|
|
515
|
+
set __data(value) { __classPrivateFieldSet(this, _Inode___data_accessor_storage, value, "f"); }
|
|
157
516
|
toString() {
|
|
158
517
|
return `<Inode ${this.ino}>`;
|
|
159
518
|
}
|
|
160
519
|
toJSON() {
|
|
161
|
-
return
|
|
520
|
+
return {
|
|
521
|
+
...pick(this, _inode_fields),
|
|
522
|
+
attributes: this.attributes,
|
|
523
|
+
};
|
|
162
524
|
}
|
|
163
525
|
/**
|
|
164
526
|
* Handy function that converts the Inode to a Node Stats object.
|
|
@@ -188,15 +550,43 @@ let Inode = (() => {
|
|
|
188
550
|
continue;
|
|
189
551
|
if (this[key] === data[key])
|
|
190
552
|
continue;
|
|
553
|
+
if (key == 'atimeMs' && this.flags & InodeFlags.NoAtime)
|
|
554
|
+
continue;
|
|
191
555
|
this[key] = data[key];
|
|
192
556
|
hasChanged = true;
|
|
193
557
|
}
|
|
558
|
+
if (data.attributes) {
|
|
559
|
+
this.attributes.copyFrom(data.attributes);
|
|
560
|
+
hasChanged = true;
|
|
561
|
+
}
|
|
562
|
+
if (hasChanged)
|
|
563
|
+
this.ctimeMs = Date.now();
|
|
194
564
|
return hasChanged;
|
|
195
565
|
}
|
|
196
566
|
};
|
|
567
|
+
_Inode_data_accessor_storage = new WeakMap();
|
|
568
|
+
_Inode___data_old_accessor_storage = new WeakMap();
|
|
569
|
+
_Inode_size_accessor_storage = new WeakMap();
|
|
570
|
+
_Inode_mode_accessor_storage = new WeakMap();
|
|
571
|
+
_Inode_nlink_accessor_storage = new WeakMap();
|
|
572
|
+
_Inode_uid_accessor_storage = new WeakMap();
|
|
573
|
+
_Inode_gid_accessor_storage = new WeakMap();
|
|
574
|
+
_Inode_atimeMs_accessor_storage = new WeakMap();
|
|
575
|
+
_Inode_birthtimeMs_accessor_storage = new WeakMap();
|
|
576
|
+
_Inode_mtimeMs_accessor_storage = new WeakMap();
|
|
577
|
+
_Inode_ctimeMs_accessor_storage = new WeakMap();
|
|
578
|
+
_Inode_ino_accessor_storage = new WeakMap();
|
|
579
|
+
_Inode___ino_old_accessor_storage = new WeakMap();
|
|
580
|
+
_Inode_flags_accessor_storage = new WeakMap();
|
|
581
|
+
_Inode___after_flags_accessor_storage = new WeakMap();
|
|
582
|
+
_Inode_version_accessor_storage = new WeakMap();
|
|
583
|
+
_Inode___padding_accessor_storage = new WeakMap();
|
|
584
|
+
_Inode_attributes_accessor_storage = new WeakMap();
|
|
585
|
+
_Inode___data_accessor_storage = new WeakMap();
|
|
197
586
|
__setFunctionName(_classThis, "Inode");
|
|
198
587
|
(() => {
|
|
199
|
-
|
|
588
|
+
var _a;
|
|
589
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
200
590
|
_data_decorators = [(_a = t).uint32.bind(_a)];
|
|
201
591
|
___data_old_decorators = [(_b = t).uint32.bind(_b)];
|
|
202
592
|
_size_decorators = [(_c = t).uint32.bind(_c)];
|
|
@@ -211,22 +601,30 @@ let Inode = (() => {
|
|
|
211
601
|
_ino_decorators = [(_m = t).uint32.bind(_m)];
|
|
212
602
|
___ino_old_decorators = [(_o = t).uint32.bind(_o)];
|
|
213
603
|
_flags_decorators = [(_p = t).uint32.bind(_p)];
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
__esDecorate(
|
|
220
|
-
__esDecorate(
|
|
221
|
-
__esDecorate(
|
|
222
|
-
__esDecorate(
|
|
223
|
-
__esDecorate(
|
|
224
|
-
__esDecorate(
|
|
225
|
-
__esDecorate(
|
|
226
|
-
__esDecorate(
|
|
227
|
-
__esDecorate(
|
|
228
|
-
__esDecorate(
|
|
229
|
-
__esDecorate(
|
|
604
|
+
___after_flags_decorators = [(_q = t).uint16.bind(_q)];
|
|
605
|
+
_version_decorators = [(_r = t).uint32.bind(_r)];
|
|
606
|
+
___padding_decorators = [t.uint8(48)];
|
|
607
|
+
_attributes_decorators = [field(Attributes)];
|
|
608
|
+
___data_decorators = [t.uint8(maxDynamicData)];
|
|
609
|
+
__esDecorate(_classThis, null, _data_decorators, { kind: "accessor", name: "data", static: false, private: false, access: { has: obj => "data" in obj, get: obj => obj.data, set: (obj, value) => { obj.data = value; } }, metadata: _metadata }, _data_initializers, _data_extraInitializers);
|
|
610
|
+
__esDecorate(_classThis, null, ___data_old_decorators, { kind: "accessor", name: "__data_old", static: false, private: false, access: { has: obj => "__data_old" in obj, get: obj => obj.__data_old, set: (obj, value) => { obj.__data_old = value; } }, metadata: _metadata }, ___data_old_initializers, ___data_old_extraInitializers);
|
|
611
|
+
__esDecorate(_classThis, null, _size_decorators, { kind: "accessor", name: "size", static: false, private: false, access: { has: obj => "size" in obj, get: obj => obj.size, set: (obj, value) => { obj.size = value; } }, metadata: _metadata }, _size_initializers, _size_extraInitializers);
|
|
612
|
+
__esDecorate(_classThis, null, _mode_decorators, { kind: "accessor", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode, set: (obj, value) => { obj.mode = value; } }, metadata: _metadata }, _mode_initializers, _mode_extraInitializers);
|
|
613
|
+
__esDecorate(_classThis, null, _nlink_decorators, { kind: "accessor", name: "nlink", static: false, private: false, access: { has: obj => "nlink" in obj, get: obj => obj.nlink, set: (obj, value) => { obj.nlink = value; } }, metadata: _metadata }, _nlink_initializers, _nlink_extraInitializers);
|
|
614
|
+
__esDecorate(_classThis, null, _uid_decorators, { kind: "accessor", name: "uid", static: false, private: false, access: { has: obj => "uid" in obj, get: obj => obj.uid, set: (obj, value) => { obj.uid = value; } }, metadata: _metadata }, _uid_initializers, _uid_extraInitializers);
|
|
615
|
+
__esDecorate(_classThis, null, _gid_decorators, { kind: "accessor", name: "gid", static: false, private: false, access: { has: obj => "gid" in obj, get: obj => obj.gid, set: (obj, value) => { obj.gid = value; } }, metadata: _metadata }, _gid_initializers, _gid_extraInitializers);
|
|
616
|
+
__esDecorate(_classThis, null, _atimeMs_decorators, { kind: "accessor", name: "atimeMs", static: false, private: false, access: { has: obj => "atimeMs" in obj, get: obj => obj.atimeMs, set: (obj, value) => { obj.atimeMs = value; } }, metadata: _metadata }, _atimeMs_initializers, _atimeMs_extraInitializers);
|
|
617
|
+
__esDecorate(_classThis, null, _birthtimeMs_decorators, { kind: "accessor", name: "birthtimeMs", static: false, private: false, access: { has: obj => "birthtimeMs" in obj, get: obj => obj.birthtimeMs, set: (obj, value) => { obj.birthtimeMs = value; } }, metadata: _metadata }, _birthtimeMs_initializers, _birthtimeMs_extraInitializers);
|
|
618
|
+
__esDecorate(_classThis, null, _mtimeMs_decorators, { kind: "accessor", name: "mtimeMs", static: false, private: false, access: { has: obj => "mtimeMs" in obj, get: obj => obj.mtimeMs, set: (obj, value) => { obj.mtimeMs = value; } }, metadata: _metadata }, _mtimeMs_initializers, _mtimeMs_extraInitializers);
|
|
619
|
+
__esDecorate(_classThis, null, _ctimeMs_decorators, { kind: "accessor", name: "ctimeMs", static: false, private: false, access: { has: obj => "ctimeMs" in obj, get: obj => obj.ctimeMs, set: (obj, value) => { obj.ctimeMs = value; } }, metadata: _metadata }, _ctimeMs_initializers, _ctimeMs_extraInitializers);
|
|
620
|
+
__esDecorate(_classThis, null, _ino_decorators, { kind: "accessor", name: "ino", static: false, private: false, access: { has: obj => "ino" in obj, get: obj => obj.ino, set: (obj, value) => { obj.ino = value; } }, metadata: _metadata }, _ino_initializers, _ino_extraInitializers);
|
|
621
|
+
__esDecorate(_classThis, null, ___ino_old_decorators, { kind: "accessor", name: "__ino_old", static: false, private: false, access: { has: obj => "__ino_old" in obj, get: obj => obj.__ino_old, set: (obj, value) => { obj.__ino_old = value; } }, metadata: _metadata }, ___ino_old_initializers, ___ino_old_extraInitializers);
|
|
622
|
+
__esDecorate(_classThis, null, _flags_decorators, { kind: "accessor", name: "flags", static: false, private: false, access: { has: obj => "flags" in obj, get: obj => obj.flags, set: (obj, value) => { obj.flags = value; } }, metadata: _metadata }, _flags_initializers, _flags_extraInitializers);
|
|
623
|
+
__esDecorate(_classThis, null, ___after_flags_decorators, { kind: "accessor", name: "__after_flags", static: false, private: false, access: { has: obj => "__after_flags" in obj, get: obj => obj.__after_flags, set: (obj, value) => { obj.__after_flags = value; } }, metadata: _metadata }, ___after_flags_initializers, ___after_flags_extraInitializers);
|
|
624
|
+
__esDecorate(_classThis, null, _version_decorators, { kind: "accessor", name: "version", static: false, private: false, access: { has: obj => "version" in obj, get: obj => obj.version, set: (obj, value) => { obj.version = value; } }, metadata: _metadata }, _version_initializers, _version_extraInitializers);
|
|
625
|
+
__esDecorate(_classThis, null, ___padding_decorators, { kind: "accessor", name: "__padding", static: false, private: false, access: { has: obj => "__padding" in obj, get: obj => obj.__padding, set: (obj, value) => { obj.__padding = value; } }, metadata: _metadata }, ___padding_initializers, ___padding_extraInitializers);
|
|
626
|
+
__esDecorate(_classThis, null, _attributes_decorators, { kind: "accessor", name: "attributes", static: false, private: false, access: { has: obj => "attributes" in obj, get: obj => obj.attributes, set: (obj, value) => { obj.attributes = value; } }, metadata: _metadata }, _attributes_initializers, _attributes_extraInitializers);
|
|
627
|
+
__esDecorate(_classThis, null, ___data_decorators, { kind: "accessor", name: "__data", static: false, private: false, access: { has: obj => "__data" in obj, get: obj => obj.__data, set: (obj, value) => { obj.__data = value; } }, metadata: _metadata }, ___data_initializers, ___data_extraInitializers);
|
|
230
628
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
231
629
|
Inode = _classThis = _classDescriptor.value;
|
|
232
630
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -235,7 +633,58 @@ let Inode = (() => {
|
|
|
235
633
|
return Inode = _classThis;
|
|
236
634
|
})();
|
|
237
635
|
export { Inode };
|
|
636
|
+
export function isFile(metadata) {
|
|
637
|
+
return (metadata.mode & c.S_IFMT) === c.S_IFREG;
|
|
638
|
+
}
|
|
639
|
+
export function isDirectory(metadata) {
|
|
640
|
+
return (metadata.mode & c.S_IFMT) === c.S_IFDIR;
|
|
641
|
+
}
|
|
642
|
+
export function isSymbolicLink(metadata) {
|
|
643
|
+
return (metadata.mode & c.S_IFMT) === c.S_IFLNK;
|
|
644
|
+
}
|
|
645
|
+
export function isSocket(metadata) {
|
|
646
|
+
return (metadata.mode & c.S_IFMT) === c.S_IFSOCK;
|
|
647
|
+
}
|
|
648
|
+
export function isBlockDevice(metadata) {
|
|
649
|
+
return (metadata.mode & c.S_IFMT) === c.S_IFBLK;
|
|
650
|
+
}
|
|
651
|
+
export function isCharacterDevice(metadata) {
|
|
652
|
+
return (metadata.mode & c.S_IFMT) === c.S_IFCHR;
|
|
653
|
+
}
|
|
654
|
+
export function isFIFO(metadata) {
|
|
655
|
+
return (metadata.mode & c.S_IFMT) === c.S_IFIFO;
|
|
656
|
+
}
|
|
238
657
|
/**
|
|
239
|
-
*
|
|
658
|
+
* Checks if a given user/group has access to this item
|
|
659
|
+
* @param access The requested access, combination of `W_OK`, `R_OK`, and `X_OK`
|
|
660
|
+
* @internal
|
|
240
661
|
*/
|
|
241
|
-
export
|
|
662
|
+
export function hasAccess($, inode, access) {
|
|
663
|
+
const credentials = ($ === null || $ === void 0 ? void 0 : $.credentials) || defaultContext.credentials;
|
|
664
|
+
if (isSymbolicLink(inode) || credentials.euid === 0 || credentials.egid === 0)
|
|
665
|
+
return true;
|
|
666
|
+
let perm = 0;
|
|
667
|
+
if (credentials.uid === inode.uid) {
|
|
668
|
+
if (inode.mode & c.S_IRUSR)
|
|
669
|
+
perm |= c.R_OK;
|
|
670
|
+
if (inode.mode & c.S_IWUSR)
|
|
671
|
+
perm |= c.W_OK;
|
|
672
|
+
if (inode.mode & c.S_IXUSR)
|
|
673
|
+
perm |= c.X_OK;
|
|
674
|
+
}
|
|
675
|
+
if (credentials.gid === inode.gid || credentials.groups.includes(Number(inode.gid))) {
|
|
676
|
+
if (inode.mode & c.S_IRGRP)
|
|
677
|
+
perm |= c.R_OK;
|
|
678
|
+
if (inode.mode & c.S_IWGRP)
|
|
679
|
+
perm |= c.W_OK;
|
|
680
|
+
if (inode.mode & c.S_IXGRP)
|
|
681
|
+
perm |= c.X_OK;
|
|
682
|
+
}
|
|
683
|
+
if (inode.mode & c.S_IROTH)
|
|
684
|
+
perm |= c.R_OK;
|
|
685
|
+
if (inode.mode & c.S_IWOTH)
|
|
686
|
+
perm |= c.W_OK;
|
|
687
|
+
if (inode.mode & c.S_IXOTH)
|
|
688
|
+
perm |= c.X_OK;
|
|
689
|
+
return (perm & access) === access;
|
|
690
|
+
}
|