@zenfs/core 2.7.4 → 2.7.5
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/internal/filesystem.js +2 -2
- package/dist/internal/inode.d.ts +12 -2
- package/dist/internal/inode.js +12 -2
- package/dist/internal/ioctl.d.ts +83 -25
- package/dist/internal/ioctl.js +50 -185
- package/dist/vfs/xattr.d.ts +2 -0
- package/dist/vfs/xattr.js +5 -4
- package/package.json +2 -2
|
@@ -146,7 +146,7 @@ export class FileSystem {
|
|
|
146
146
|
const cmd = ioctl_default_ops_async[command];
|
|
147
147
|
if (!cmd)
|
|
148
148
|
throw withErrno('ENOTTY');
|
|
149
|
-
return await cmd(
|
|
149
|
+
return await cmd(context, ...args);
|
|
150
150
|
}
|
|
151
151
|
/** @internal */
|
|
152
152
|
ioctlSync(context, command, ...args) {
|
|
@@ -154,6 +154,6 @@ export class FileSystem {
|
|
|
154
154
|
const cmd = ioctl_default_ops_sync[command];
|
|
155
155
|
if (!cmd)
|
|
156
156
|
throw withErrno('ENOTTY');
|
|
157
|
-
return cmd(
|
|
157
|
+
return cmd(context, ...args);
|
|
158
158
|
}
|
|
159
159
|
}
|
package/dist/internal/inode.d.ts
CHANGED
|
@@ -145,9 +145,19 @@ export declare enum InodeFlags {
|
|
|
145
145
|
/** File is in use by the kernel (eg. fs/cachefiles) */
|
|
146
146
|
KernelFile = 131072
|
|
147
147
|
}
|
|
148
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* User visible flags
|
|
150
|
+
* These are actually masks for userspace `FileFlag`s, not `InodeFlags`.
|
|
151
|
+
* @deprecated Use the export from `/internal/ioctl`
|
|
152
|
+
* @todo [breaking] remove
|
|
153
|
+
*/
|
|
149
154
|
export declare const userVisibleFlags = 253951;
|
|
150
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* User modifiable flags
|
|
157
|
+
* These are actually masks for userspace `FileFlag`s, not `InodeFlags`.
|
|
158
|
+
* @deprecated Use the export from `/internal/ioctl`
|
|
159
|
+
* @todo [breaking] remove these re-exports
|
|
160
|
+
*/
|
|
151
161
|
export declare const userModifiableFlags = 229631;
|
|
152
162
|
declare const Inode_base: import("memium").StructConstructor<BufferView<any>>;
|
|
153
163
|
/**
|
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/vfs/xattr.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export interface SetOptions extends Options {
|
|
|
44
44
|
*/
|
|
45
45
|
replace?: boolean;
|
|
46
46
|
}
|
|
47
|
+
/** Attributes outside the `user` namespace that are supported. */
|
|
48
|
+
export declare const allowedRestrictedNames: Set<`user.${string}` | `trusted.${string}` | `system.${string}` | `security.${string}`>;
|
|
47
49
|
/**
|
|
48
50
|
* Gets the value of an extended attribute.
|
|
49
51
|
*
|
package/dist/vfs/xattr.js
CHANGED
|
@@ -6,14 +6,15 @@ import { normalizePath } from '../utils.js';
|
|
|
6
6
|
import { checkAccess } from './config.js';
|
|
7
7
|
import { R_OK, W_OK } from '../constants.js';
|
|
8
8
|
import { resolveMount } from './shared.js';
|
|
9
|
-
|
|
9
|
+
/** Attributes outside the `user` namespace that are supported. */
|
|
10
|
+
export const allowedRestrictedNames = new Set();
|
|
10
11
|
/**
|
|
11
12
|
* Check permission for the attribute name.
|
|
12
|
-
*
|
|
13
|
-
* @throws ENOTSUP for
|
|
13
|
+
* Only the 'user' namespace and whatever is in {@link allowedRestrictedNames} are supported.
|
|
14
|
+
* @throws ENOTSUP for any other attribute
|
|
14
15
|
*/
|
|
15
16
|
function checkName($, name, path, syscall) {
|
|
16
|
-
if (!name.startsWith('user.') && !
|
|
17
|
+
if (!name.startsWith('user.') && !allowedRestrictedNames.has(name))
|
|
17
18
|
throw UV('ENOTSUP', syscall, path);
|
|
18
19
|
}
|
|
19
20
|
export async function get(path, name, opt = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.5",
|
|
4
4
|
"description": "A filesystem, anywhere",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"typedoc": "^0.28.18",
|
|
94
94
|
"typescript": "^6.0.0",
|
|
95
95
|
"typescript-eslint": "^8.58.0",
|
|
96
|
-
"zbench-js": "^0.
|
|
96
|
+
"zbench-js": "^0.2.0"
|
|
97
97
|
},
|
|
98
98
|
"prettier": {
|
|
99
99
|
"singleQuote": true,
|