@k13engineering/linux-fuse 0.0.1 → 0.0.2

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