@k13engineering/linux-fuse 0.0.1 → 0.0.3

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.
@@ -0,0 +1,755 @@
1
+ import type { TParsedMessageFromKernel, TParsedMessageToKernel } from "./message.js";
2
+ type TRequesterInfo = {
3
+ uid: bigint;
4
+ gid: bigint;
5
+ pid: bigint;
6
+ };
7
+ type TOpenFlagsToKernel = {
8
+ directIo: boolean;
9
+ keepCache: boolean;
10
+ nonSeekable: boolean;
11
+ };
12
+ type TFuseAttr = {
13
+ ino: bigint;
14
+ mode: bigint;
15
+ nlink: bigint;
16
+ uid: bigint;
17
+ gid: bigint;
18
+ rdev: bigint;
19
+ size: bigint;
20
+ blksize: bigint;
21
+ blocks: bigint;
22
+ atimeNsec: bigint;
23
+ mtimeNsec: bigint;
24
+ ctimeNsec: bigint;
25
+ };
26
+ type TFuseEntry = {
27
+ nodeId: bigint;
28
+ generation: bigint;
29
+ entryValidNsec: bigint;
30
+ attrValidNsec: bigint;
31
+ attr: TFuseAttr;
32
+ };
33
+ type TFuseXAttrResult = {
34
+ data: Uint8Array;
35
+ } | {
36
+ size: bigint;
37
+ };
38
+ type TFuseRequest = {
39
+ unique: bigint;
40
+ requester: TRequesterInfo;
41
+ } & ({
42
+ opcode: "INIT";
43
+ major: bigint;
44
+ minor: bigint;
45
+ } | {
46
+ opcode: "FORGET";
47
+ nodeId: bigint;
48
+ lookupCount: bigint;
49
+ } | {
50
+ opcode: "BATCH_FORGET";
51
+ forgets: Array<{
52
+ nodeId: bigint;
53
+ lookupCount: bigint;
54
+ }>;
55
+ } | {
56
+ opcode: "GETATTR";
57
+ getattrMode: "node";
58
+ nodeId: bigint;
59
+ } | {
60
+ opcode: "GETATTR";
61
+ getattrMode: "fileHandle";
62
+ fh: bigint;
63
+ } | {
64
+ opcode: "LISTXATTR";
65
+ nodeId: bigint;
66
+ size: bigint;
67
+ } | {
68
+ opcode: "GETXATTR";
69
+ nodeId: bigint;
70
+ size: bigint;
71
+ name: string;
72
+ } | {
73
+ opcode: "SETATTR";
74
+ nodeId: bigint;
75
+ fh: bigint | undefined;
76
+ size: bigint | undefined;
77
+ lockOwner: bigint;
78
+ atimeNsec: bigint | "now" | undefined;
79
+ mtimeNsec: bigint | "now" | undefined;
80
+ ctimeNsec: bigint;
81
+ mode: bigint | undefined;
82
+ uid: bigint | undefined;
83
+ gid: bigint | undefined;
84
+ } | {
85
+ opcode: "READLINK";
86
+ nodeId: bigint;
87
+ } | {
88
+ opcode: "SYMLINK";
89
+ parentNodeId: bigint;
90
+ name: string;
91
+ target: string;
92
+ } | {
93
+ opcode: "MKNOD";
94
+ parentNodeId: bigint;
95
+ name: string;
96
+ mode: bigint;
97
+ rdev: bigint;
98
+ umask: bigint;
99
+ } | {
100
+ opcode: "MKDIR";
101
+ parentNodeId: bigint;
102
+ name: string;
103
+ mode: bigint;
104
+ umask: bigint;
105
+ } | {
106
+ opcode: "UNLINK";
107
+ parentNodeId: bigint;
108
+ name: string;
109
+ } | {
110
+ opcode: "RMDIR";
111
+ parentNodeId: bigint;
112
+ name: string;
113
+ } | {
114
+ opcode: "RENAME";
115
+ parentNodeId: bigint;
116
+ newParentNodeId: bigint;
117
+ oldName: string;
118
+ newName: string;
119
+ flags: bigint;
120
+ } | {
121
+ opcode: "LINK";
122
+ oldNodeId: bigint;
123
+ newParentNodeId: bigint;
124
+ name: string;
125
+ } | {
126
+ opcode: "OPENDIR";
127
+ nodeId: bigint;
128
+ flags: bigint;
129
+ } | {
130
+ opcode: "READDIR";
131
+ nodeId: bigint;
132
+ fh: bigint;
133
+ offset: bigint;
134
+ size: bigint;
135
+ readFlags: bigint;
136
+ lockOwner: bigint;
137
+ flags: bigint;
138
+ } | {
139
+ opcode: "RELEASE";
140
+ nodeId: bigint;
141
+ fh: bigint;
142
+ flags: bigint;
143
+ releaseFlags: bigint;
144
+ lockOwner: bigint;
145
+ } | {
146
+ opcode: "RELEASEDIR";
147
+ nodeId: bigint;
148
+ fh: bigint;
149
+ flags: bigint;
150
+ releaseFlags: bigint;
151
+ lockOwner: bigint;
152
+ } | {
153
+ opcode: "FSYNCDIR";
154
+ nodeId: bigint;
155
+ fh: bigint;
156
+ fsyncFlags: bigint;
157
+ } | {
158
+ opcode: "STATFS";
159
+ } | {
160
+ opcode: "LOOKUP";
161
+ parentNodeId: bigint;
162
+ name: string;
163
+ } | {
164
+ opcode: "OPEN";
165
+ nodeId: bigint;
166
+ flags: bigint;
167
+ } | {
168
+ opcode: "READ";
169
+ nodeId: bigint;
170
+ fh: bigint;
171
+ offset: bigint;
172
+ size: bigint;
173
+ readFlags: bigint;
174
+ lockOwner: bigint;
175
+ } | {
176
+ opcode: "WRITE";
177
+ nodeId: bigint;
178
+ fh: bigint;
179
+ offset: bigint;
180
+ data: Uint8Array;
181
+ writeFlags: bigint;
182
+ lockOwner: bigint;
183
+ } | {
184
+ opcode: "FLUSH";
185
+ nodeId: bigint;
186
+ fh: bigint;
187
+ lockOwner: bigint;
188
+ } | {
189
+ opcode: "FSYNC";
190
+ nodeId: bigint;
191
+ fh: bigint;
192
+ fsyncFlags: bigint;
193
+ } | {
194
+ opcode: "ACCESS";
195
+ nodeId: bigint;
196
+ mask: bigint;
197
+ } | {
198
+ opcode: "SETXATTR";
199
+ nodeId: bigint;
200
+ name: string;
201
+ data: Uint8Array;
202
+ flags: bigint;
203
+ setxattrFlags: bigint;
204
+ } | {
205
+ opcode: "REMOVEXATTR";
206
+ nodeId: bigint;
207
+ name: string;
208
+ } | {
209
+ opcode: "CREATE";
210
+ parentNodeId: bigint;
211
+ name: string;
212
+ flags: bigint;
213
+ mode: bigint;
214
+ umask: bigint;
215
+ } | {
216
+ opcode: "DESTROY";
217
+ } | {
218
+ opcode: "GETLK";
219
+ nodeId: bigint;
220
+ fh: bigint;
221
+ owner: bigint;
222
+ lockStart: bigint;
223
+ lockEnd: bigint;
224
+ lockType: bigint;
225
+ lockPid: bigint;
226
+ lkFlags: bigint;
227
+ } | {
228
+ opcode: "SETLK";
229
+ nodeId: bigint;
230
+ fh: bigint;
231
+ owner: bigint;
232
+ lockStart: bigint;
233
+ lockEnd: bigint;
234
+ lockType: bigint;
235
+ lockPid: bigint;
236
+ lkFlags: bigint;
237
+ } | {
238
+ opcode: "SETLKW";
239
+ nodeId: bigint;
240
+ fh: bigint;
241
+ owner: bigint;
242
+ lockStart: bigint;
243
+ lockEnd: bigint;
244
+ lockType: bigint;
245
+ lockPid: bigint;
246
+ lkFlags: bigint;
247
+ } | {
248
+ opcode: "INTERRUPT";
249
+ targetUnique: bigint;
250
+ } | {
251
+ opcode: "BMAP";
252
+ nodeId: bigint;
253
+ block: bigint;
254
+ blocksize: bigint;
255
+ } | {
256
+ opcode: "IOCTL";
257
+ nodeId: bigint;
258
+ fh: bigint;
259
+ flags: bigint;
260
+ cmd: bigint;
261
+ arg: bigint;
262
+ inData: Uint8Array;
263
+ outSize: bigint;
264
+ } | {
265
+ opcode: "POLL";
266
+ nodeId: bigint;
267
+ fh: bigint;
268
+ kh: bigint;
269
+ flags: bigint;
270
+ events: bigint;
271
+ } | {
272
+ opcode: "NOTIFY_REPLY";
273
+ data: Uint8Array;
274
+ } | {
275
+ opcode: "FALLOCATE";
276
+ nodeId: bigint;
277
+ fh: bigint;
278
+ offset: bigint;
279
+ length: bigint;
280
+ mode: bigint;
281
+ } | {
282
+ opcode: "READDIRPLUS";
283
+ nodeId: bigint;
284
+ fh: bigint;
285
+ offset: bigint;
286
+ size: bigint;
287
+ readFlags: bigint;
288
+ lockOwner: bigint;
289
+ flags: bigint;
290
+ });
291
+ type TFuseResponse = {
292
+ forOpcode: "INIT";
293
+ unique: bigint;
294
+ errorCode: number;
295
+ result: undefined;
296
+ } | {
297
+ forOpcode: "INIT";
298
+ unique: bigint;
299
+ errorCode: undefined;
300
+ result: {
301
+ major: bigint;
302
+ minor: bigint;
303
+ maxReadahead: bigint;
304
+ flags: bigint;
305
+ maxBackground: bigint;
306
+ congestionThreshold: bigint;
307
+ maxWrite: bigint;
308
+ timeGran: bigint;
309
+ maxPages: bigint;
310
+ mapAlignment: bigint;
311
+ flags2: bigint;
312
+ maxStackDepth: bigint;
313
+ requestTimeout: bigint;
314
+ };
315
+ } | {
316
+ forOpcode: "GETATTR";
317
+ unique: bigint;
318
+ errorCode: number;
319
+ result: undefined;
320
+ } | {
321
+ forOpcode: "GETATTR";
322
+ unique: bigint;
323
+ errorCode: undefined;
324
+ result: {
325
+ attrValidNsec: bigint;
326
+ attr: TFuseAttr;
327
+ };
328
+ } | {
329
+ forOpcode: "SETATTR";
330
+ unique: bigint;
331
+ errorCode: number;
332
+ result: undefined;
333
+ } | {
334
+ forOpcode: "SETATTR";
335
+ unique: bigint;
336
+ errorCode: undefined;
337
+ result: {
338
+ attrValidNsec: bigint;
339
+ attr: TFuseAttr;
340
+ };
341
+ } | {
342
+ forOpcode: "LISTXATTR";
343
+ unique: bigint;
344
+ errorCode: number;
345
+ result: undefined;
346
+ } | {
347
+ forOpcode: "LISTXATTR";
348
+ unique: bigint;
349
+ errorCode: undefined;
350
+ result: TFuseXAttrResult;
351
+ } | {
352
+ forOpcode: "GETXATTR";
353
+ unique: bigint;
354
+ errorCode: number;
355
+ result: undefined;
356
+ } | {
357
+ forOpcode: "GETXATTR";
358
+ unique: bigint;
359
+ errorCode: undefined;
360
+ result: TFuseXAttrResult;
361
+ } | {
362
+ forOpcode: "READLINK";
363
+ unique: bigint;
364
+ errorCode: number;
365
+ result: undefined;
366
+ } | {
367
+ forOpcode: "READLINK";
368
+ unique: bigint;
369
+ errorCode: undefined;
370
+ result: {
371
+ target: string;
372
+ };
373
+ } | {
374
+ forOpcode: "MKNOD";
375
+ unique: bigint;
376
+ errorCode: number;
377
+ result: undefined;
378
+ } | {
379
+ forOpcode: "MKNOD";
380
+ unique: bigint;
381
+ errorCode: undefined;
382
+ result: TFuseEntry;
383
+ } | {
384
+ forOpcode: "OPENDIR";
385
+ unique: bigint;
386
+ errorCode: number;
387
+ result: undefined;
388
+ } | {
389
+ forOpcode: "OPENDIR";
390
+ unique: bigint;
391
+ errorCode: undefined;
392
+ result: {
393
+ fh: bigint;
394
+ openFlagsToKernel: TOpenFlagsToKernel;
395
+ };
396
+ } | {
397
+ forOpcode: "READDIR";
398
+ unique: bigint;
399
+ errorCode: number;
400
+ result: undefined;
401
+ } | {
402
+ forOpcode: "READDIR";
403
+ unique: bigint;
404
+ errorCode: undefined;
405
+ result: {
406
+ data: Uint8Array;
407
+ };
408
+ } | {
409
+ forOpcode: "RELEASEDIR";
410
+ unique: bigint;
411
+ errorCode: number;
412
+ result: undefined;
413
+ } | {
414
+ forOpcode: "RELEASEDIR";
415
+ unique: bigint;
416
+ errorCode: undefined;
417
+ result: Record<string, never>;
418
+ } | {
419
+ forOpcode: "FSYNCDIR";
420
+ unique: bigint;
421
+ errorCode: number;
422
+ result: undefined;
423
+ } | {
424
+ forOpcode: "FSYNCDIR";
425
+ unique: bigint;
426
+ errorCode: undefined;
427
+ result: Record<string, never>;
428
+ } | {
429
+ forOpcode: "RELEASE";
430
+ unique: bigint;
431
+ errorCode: number;
432
+ result: undefined;
433
+ } | {
434
+ forOpcode: "RELEASE";
435
+ unique: bigint;
436
+ errorCode: undefined;
437
+ result: Record<string, never>;
438
+ } | {
439
+ forOpcode: "STATFS";
440
+ unique: bigint;
441
+ errorCode: number;
442
+ result: undefined;
443
+ } | {
444
+ forOpcode: "STATFS";
445
+ unique: bigint;
446
+ errorCode: undefined;
447
+ result: {
448
+ blocks: bigint;
449
+ bfree: bigint;
450
+ bavail: bigint;
451
+ files: bigint;
452
+ ffree: bigint;
453
+ bsize: bigint;
454
+ namelen: bigint;
455
+ frsize: bigint;
456
+ };
457
+ } | {
458
+ forOpcode: "LOOKUP";
459
+ unique: bigint;
460
+ errorCode: number;
461
+ result: undefined;
462
+ } | {
463
+ forOpcode: "LOOKUP";
464
+ unique: bigint;
465
+ errorCode: undefined;
466
+ result: TFuseEntry;
467
+ } | {
468
+ forOpcode: "SYMLINK";
469
+ unique: bigint;
470
+ errorCode: number;
471
+ result: undefined;
472
+ } | {
473
+ forOpcode: "SYMLINK";
474
+ unique: bigint;
475
+ errorCode: undefined;
476
+ result: TFuseEntry;
477
+ } | {
478
+ forOpcode: "MKDIR";
479
+ unique: bigint;
480
+ errorCode: number;
481
+ result: undefined;
482
+ } | {
483
+ forOpcode: "MKDIR";
484
+ unique: bigint;
485
+ errorCode: undefined;
486
+ result: TFuseEntry;
487
+ } | {
488
+ forOpcode: "LINK";
489
+ unique: bigint;
490
+ errorCode: number;
491
+ result: undefined;
492
+ } | {
493
+ forOpcode: "LINK";
494
+ unique: bigint;
495
+ errorCode: undefined;
496
+ result: TFuseEntry;
497
+ } | {
498
+ forOpcode: "UNLINK";
499
+ unique: bigint;
500
+ errorCode: number;
501
+ result: undefined;
502
+ } | {
503
+ forOpcode: "UNLINK";
504
+ unique: bigint;
505
+ errorCode: undefined;
506
+ result: Record<string, never>;
507
+ } | {
508
+ forOpcode: "RMDIR";
509
+ unique: bigint;
510
+ errorCode: number;
511
+ result: undefined;
512
+ } | {
513
+ forOpcode: "RMDIR";
514
+ unique: bigint;
515
+ errorCode: undefined;
516
+ result: Record<string, never>;
517
+ } | {
518
+ forOpcode: "RENAME";
519
+ unique: bigint;
520
+ errorCode: number;
521
+ result: undefined;
522
+ } | {
523
+ forOpcode: "RENAME";
524
+ unique: bigint;
525
+ errorCode: undefined;
526
+ result: Record<string, never>;
527
+ } | {
528
+ forOpcode: "OPEN";
529
+ unique: bigint;
530
+ errorCode: number;
531
+ result: undefined;
532
+ } | {
533
+ forOpcode: "OPEN";
534
+ unique: bigint;
535
+ errorCode: undefined;
536
+ result: {
537
+ fh: bigint;
538
+ openFlagsToKernel: TOpenFlagsToKernel;
539
+ };
540
+ } | {
541
+ forOpcode: "READ";
542
+ unique: bigint;
543
+ errorCode: number;
544
+ result: undefined;
545
+ } | {
546
+ forOpcode: "READ";
547
+ unique: bigint;
548
+ errorCode: undefined;
549
+ result: {
550
+ data: Uint8Array;
551
+ };
552
+ } | {
553
+ forOpcode: "WRITE";
554
+ unique: bigint;
555
+ errorCode: number;
556
+ result: undefined;
557
+ } | {
558
+ forOpcode: "WRITE";
559
+ unique: bigint;
560
+ errorCode: undefined;
561
+ result: {
562
+ bytesWritten: bigint;
563
+ };
564
+ } | {
565
+ forOpcode: "FLUSH";
566
+ unique: bigint;
567
+ errorCode: number;
568
+ result: undefined;
569
+ } | {
570
+ forOpcode: "FLUSH";
571
+ unique: bigint;
572
+ errorCode: undefined;
573
+ result: Record<string, never>;
574
+ } | {
575
+ forOpcode: "FSYNC";
576
+ unique: bigint;
577
+ errorCode: number;
578
+ result: undefined;
579
+ } | {
580
+ forOpcode: "FSYNC";
581
+ unique: bigint;
582
+ errorCode: undefined;
583
+ result: Record<string, never>;
584
+ } | {
585
+ forOpcode: "ACCESS";
586
+ unique: bigint;
587
+ errorCode: number;
588
+ result: undefined;
589
+ } | {
590
+ forOpcode: "ACCESS";
591
+ unique: bigint;
592
+ errorCode: undefined;
593
+ result: Record<string, never>;
594
+ } | {
595
+ forOpcode: "SETXATTR";
596
+ unique: bigint;
597
+ errorCode: number;
598
+ result: undefined;
599
+ } | {
600
+ forOpcode: "SETXATTR";
601
+ unique: bigint;
602
+ errorCode: undefined;
603
+ result: Record<string, never>;
604
+ } | {
605
+ forOpcode: "REMOVEXATTR";
606
+ unique: bigint;
607
+ errorCode: number;
608
+ result: undefined;
609
+ } | {
610
+ forOpcode: "REMOVEXATTR";
611
+ unique: bigint;
612
+ errorCode: undefined;
613
+ result: Record<string, never>;
614
+ } | {
615
+ forOpcode: "CREATE";
616
+ unique: bigint;
617
+ errorCode: number;
618
+ result: undefined;
619
+ } | {
620
+ forOpcode: "CREATE";
621
+ unique: bigint;
622
+ errorCode: undefined;
623
+ result: TFuseEntry & {
624
+ fh: bigint;
625
+ openFlagsToKernel: TOpenFlagsToKernel;
626
+ };
627
+ } | {
628
+ forOpcode: "DESTROY";
629
+ unique: bigint;
630
+ errorCode: number;
631
+ result: undefined;
632
+ } | {
633
+ forOpcode: "DESTROY";
634
+ unique: bigint;
635
+ errorCode: undefined;
636
+ result: Record<string, never>;
637
+ } | {
638
+ forOpcode: "GETLK";
639
+ unique: bigint;
640
+ errorCode: number;
641
+ result: undefined;
642
+ } | {
643
+ forOpcode: "GETLK";
644
+ unique: bigint;
645
+ errorCode: undefined;
646
+ result: {
647
+ lockStart: bigint;
648
+ lockEnd: bigint;
649
+ lockType: bigint;
650
+ lockPid: bigint;
651
+ };
652
+ } | {
653
+ forOpcode: "SETLK";
654
+ unique: bigint;
655
+ errorCode: number;
656
+ result: undefined;
657
+ } | {
658
+ forOpcode: "SETLK";
659
+ unique: bigint;
660
+ errorCode: undefined;
661
+ result: Record<string, never>;
662
+ } | {
663
+ forOpcode: "SETLKW";
664
+ unique: bigint;
665
+ errorCode: number;
666
+ result: undefined;
667
+ } | {
668
+ forOpcode: "SETLKW";
669
+ unique: bigint;
670
+ errorCode: undefined;
671
+ result: Record<string, never>;
672
+ } | {
673
+ forOpcode: "BMAP";
674
+ unique: bigint;
675
+ errorCode: number;
676
+ result: undefined;
677
+ } | {
678
+ forOpcode: "BMAP";
679
+ unique: bigint;
680
+ errorCode: undefined;
681
+ result: {
682
+ block: bigint;
683
+ };
684
+ } | {
685
+ forOpcode: "IOCTL";
686
+ unique: bigint;
687
+ errorCode: number;
688
+ result: undefined;
689
+ } | {
690
+ forOpcode: "IOCTL";
691
+ unique: bigint;
692
+ errorCode: undefined;
693
+ result: {
694
+ ioctlResult: bigint;
695
+ flags: bigint;
696
+ data: Uint8Array;
697
+ };
698
+ } | {
699
+ forOpcode: "POLL";
700
+ unique: bigint;
701
+ errorCode: number;
702
+ result: undefined;
703
+ } | {
704
+ forOpcode: "POLL";
705
+ unique: bigint;
706
+ errorCode: undefined;
707
+ result: {
708
+ revents: bigint;
709
+ };
710
+ } | {
711
+ forOpcode: "FALLOCATE";
712
+ unique: bigint;
713
+ errorCode: number;
714
+ result: undefined;
715
+ } | {
716
+ forOpcode: "FALLOCATE";
717
+ unique: bigint;
718
+ errorCode: undefined;
719
+ result: Record<string, never>;
720
+ } | {
721
+ forOpcode: "READDIRPLUS";
722
+ unique: bigint;
723
+ errorCode: number;
724
+ result: undefined;
725
+ } | {
726
+ forOpcode: "READDIRPLUS";
727
+ unique: bigint;
728
+ errorCode: undefined;
729
+ result: {
730
+ data: Uint8Array;
731
+ };
732
+ };
733
+ type TGenericInterpretResult<T> = {
734
+ error: Error;
735
+ interpreted: undefined;
736
+ } | {
737
+ error: undefined;
738
+ interpreted: T;
739
+ };
740
+ declare const createMessageFromKernelInterpreter: () => {
741
+ interpretMessageFromKernel: ({ parsedMessageFromKernel }: {
742
+ parsedMessageFromKernel: TParsedMessageFromKernel;
743
+ }) => TGenericInterpretResult<TFuseRequest>;
744
+ };
745
+ declare const createMessageToKernelInterpreter: () => {
746
+ encodeMessageToKernel: ({ response }: {
747
+ response: TFuseResponse;
748
+ }) => TParsedMessageToKernel;
749
+ interpretMessageToKernel: ({ request, parsedMessageToKernel }: {
750
+ request: TFuseRequest;
751
+ parsedMessageToKernel: TParsedMessageToKernel;
752
+ }) => TGenericInterpretResult<TFuseResponse>;
753
+ };
754
+ export { createMessageFromKernelInterpreter, createMessageToKernelInterpreter, };
755
+ export type { TFuseRequest, TFuseResponse, };