@effect-vfs/nfs 0.4.0 → 0.6.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/README.md CHANGED
@@ -5,7 +5,8 @@ evidence; the trusted-network profile remains `experimental`. Start with the [ru
5
5
  to mount a fixture and observe live updates.
6
6
 
7
7
  The scoped server supports TCP or a UNIX-domain socket, metadata and directory reads, symlinks, regular-file reads,
8
- and NFSv4.1 sessions. Mutations return `NFS4ERR_ROFS`. It is not a conformant NFSv4.1 server: RFC 8881 requires
8
+ and NFSv4.1 sessions. Mutations return `NFS4ERR_ROFS` by default. Explicit `writable: true` requires a volume whose
9
+ `durability` is at least `survives-power-loss`; the server rejects weaker volumes before listening. It is not a conformant NFSv4.1 server: RFC 8881 requires
9
10
  RPCSEC_GSS with Kerberos, which this package excludes. It also omits delegations, write locks, layouts, migration,
10
11
  and recovery. Backchannels and connection trunking are implemented, but the server grants no delegation or layout to
11
12
  recall.
@@ -18,8 +19,8 @@ The package describes what it does with a capability profile and how well that i
18
19
  | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
19
20
  | `read-only-local` | complete read path, `NFS4ERR_ROFS` on mutation, loopback binding, `AUTH_SYS` accepted as untrusted, backchannel and connection binding | preview |
20
21
  | `read-only-networked` | `AUTH_SYS` identity mapped to VFS callers by application policy, non-loopback binding behind that policy and an explicit opt-in | experimental |
21
- | `writable` | create, write, rename, remove, durable `WRITE` and `COMMIT`, share reservations, and advisory byte-range locks | not public |
22
- | `stateful` | grace and reclaim, restart recovery, persistent filehandles | not public |
22
+ | `writable` | create, write, rename, remove, durable `WRITE` and `COMMIT`, share reservations, and advisory byte-range locks | experimental |
23
+ | `stateful` | grace and reclaim, restart recovery of sessions, opens, and locks | not public |
23
24
 
24
25
  The current read-only export tracks advisory byte-range read locks between NFS clients. `LOCK` requires an open stateid; `LOCKU` releases an exact range. Write locks still return `NFS4ERR_ROFS`. `maxLockOwners` and `maxLocks` bound the in-memory state, which is removed on lease expiry or client revocation. Direct VFS callers do not participate in NFS locks.
25
26
 
@@ -27,6 +28,15 @@ The current read-only export tracks advisory byte-range read locks between NFS c
27
28
 
28
29
  `NfsServer.make` and `NfsServer.layer` accept local `{ volume, caller }` or networked `{ volume, policy, peer }` options. Both require an Effect `SocketServer`; the application chooses and binds its platform implementation. Local mode accepts only loopback TCP or a UNIX-domain socket. Networked mode can bind elsewhere only with `allowNonLoopback: true`. The server defaults to a 30-second lease, a 30-second callback timeout, and finite resource limits. RPCSEC_GSS credentials are refused with `AUTH_TOOWEAK`.
29
30
 
31
+ The optional `writable: true` profile is limited to one gateway owning one qualified live volume. The application
32
+ must prevent another gateway from opening the same storage image; the server does not provide a distributed lease.
33
+ Successful mutations rely on the live provider's synchronous commit guarantee. The [R2 writable test app](../../apps/demo-r2-nfs/README.md)
34
+ shows the public API with a bounded R2 image, a trusted-client policy, mounted Debian and macOS checks, restart
35
+ recovery, and an injected lost R2 HTTP response. Filehandles carry the object's core reference key, so over a volume
36
+ whose commits survive at least a process crash they persist across a restart and `fh_expire_type` reports
37
+ `FH4_PERSISTENT`. The key's tag keeps a client from forging a handle for an object by guessing its inode number. Sessions, opens, and locks do not survive, so remount clients after gateway restart; this is not
38
+ the `stateful` recovery profile. Do not set a stronger `Volume.durability` for an unqualified storage provider.
39
+
30
40
  In local mode, one application-supplied caller performs every read. Decoded `AUTH_SYS` fields never grant VFS authority, and ACCESS answers derived from them are advisory. In networked mode, the application supplies a peer resolver evaluated for each accepted socket and a policy that maps the decoded credential and peer to a VFS identity or denies it. The server creates and caches callers per distinct identity, bounded by `maxIdentities`. Policy denials and cache exhaustion answer RPC `AUTH_FAILED` before the compound executes. A resolver returning `null` closes the connection. UNIX peers have `address: null` and `port: null`; `path` is the server socket path, not a client address. Applications must enforce their trusted-client boundary in the policy. This profile is experimental: protocol and socket tests pass, but a networked kernel-client gate has not been recorded. See the [authentication and export policy decision](https://github.com/lloydrichards/effect-virtual-fs/blob/main/.okf/decisions/nfs/nfs-authentication-and-export-policy.md).
31
41
 
32
42
  `NfsServerConfig`, `NfsServerConfigOverrides`, `NfsServerLimits`, `NfsServerLimitOverrides`, `NfsServerAddress`, `NfsServerTcpAddress`, `NfsServerNetworkTcpAddress`, and `NfsServerUnixAddress` are public Effect schemas. Byte limits use `effect/ByteSize`, so their units are explicit and validated before the server converts them to the numeric representation used by XDR. `NfsServerConfig.default`, `NfsServerLimits.default`, and `NfsServerLimits.constrained` expose frozen complete policies. Callers can override only the settings they need. `Volume`, `Caller`, and `SocketServer` remain live Effect capabilities rather than schema data.
@@ -91,7 +101,8 @@ bun run --filter @repo/nfs-preview start
91
101
  ```
92
102
 
93
103
  Applications continue writing through the VFS API while native clients read the mounted view. Stop the server,
94
- unmount, and mount again after a restart because filehandles and sessions are intentionally volatile.
104
+ unmount, and mount again after a restart because its memory volume's filehandles and every session are intentionally
105
+ volatile.
95
106
 
96
107
  Run the focused checks from this directory:
97
108
 
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Models and constructors for the experimental read-only NFSv4.1 server.
2
+ * Models and constructors for the experimental NFSv4.1 server.
3
3
  *
4
4
  * The server exports one live `@effect-vfs/core` volume over NFSv4.1 so that
5
5
  * ordinary NFS clients can mount a virtual filesystem. It implements the
6
- * supported read-only operations, returns `NFS4ERR_ROFS` for filesystem
7
- * mutations, and rejects other unsupported operations.
6
+ * supported read-only operations. Writable operation dispatch requires an
7
+ * explicit option and a volume that reports power-loss durability.
8
8
  *
9
9
  * @since 0.1.0
10
10
  */
@@ -74,7 +74,6 @@ declare const NfsServerLimitsSchema: Schema.Struct<{
74
74
  readonly maxReaddirEntries: Schema.Finite;
75
75
  readonly maxReaddirReplyBytes: Schema.ByteSize;
76
76
  readonly maxNameBytes: Schema.ByteSize;
77
- readonly maxFilehandles: Schema.Finite;
78
77
  }>;
79
78
  /**
80
79
  * Every resource bound enforced by the preview server.
@@ -118,7 +117,6 @@ export declare const NfsServerLimits: Schema.Struct<{
118
117
  readonly maxReaddirEntries: Schema.Finite;
119
118
  readonly maxReaddirReplyBytes: Schema.ByteSize;
120
119
  readonly maxNameBytes: Schema.ByteSize;
121
- readonly maxFilehandles: Schema.Finite;
122
120
  }> & {
123
121
  constrained: {
124
122
  readonly maxConnections: number;
@@ -149,7 +147,6 @@ export declare const NfsServerLimits: Schema.Struct<{
149
147
  readonly maxReaddirEntries: number;
150
148
  readonly maxReaddirReplyBytes: ByteSize.ByteSize;
151
149
  readonly maxNameBytes: ByteSize.ByteSize;
152
- readonly maxFilehandles: number;
153
150
  };
154
151
  default: {
155
152
  readonly maxConnections: number;
@@ -180,7 +177,6 @@ export declare const NfsServerLimits: Schema.Struct<{
180
177
  readonly maxReaddirEntries: number;
181
178
  readonly maxReaddirReplyBytes: ByteSize.ByteSize;
182
179
  readonly maxNameBytes: ByteSize.ByteSize;
183
- readonly maxFilehandles: number;
184
180
  };
185
181
  };
186
182
  /**
@@ -218,7 +214,6 @@ export declare const NfsServerLimitOverrides: Schema.Struct<{
218
214
  readonly maxReaddirEntries: Schema.optionalKey<Schema.Finite>;
219
215
  readonly maxReaddirReplyBytes: Schema.optionalKey<Schema.ByteSize>;
220
216
  readonly maxNameBytes: Schema.optionalKey<Schema.ByteSize>;
221
- readonly maxFilehandles: Schema.optionalKey<Schema.Finite>;
222
217
  }>;
223
218
  /**
224
219
  * A selective override of the default NFS server resource policy.
@@ -261,7 +256,6 @@ declare const NfsServerConfigSchema: Schema.Struct<{
261
256
  readonly maxReaddirEntries: Schema.Finite;
262
257
  readonly maxReaddirReplyBytes: Schema.ByteSize;
263
258
  readonly maxNameBytes: Schema.ByteSize;
264
- readonly maxFilehandles: Schema.Finite;
265
259
  }> & {
266
260
  constrained: {
267
261
  readonly maxConnections: number;
@@ -292,7 +286,6 @@ declare const NfsServerConfigSchema: Schema.Struct<{
292
286
  readonly maxReaddirEntries: number;
293
287
  readonly maxReaddirReplyBytes: ByteSize.ByteSize;
294
288
  readonly maxNameBytes: ByteSize.ByteSize;
295
- readonly maxFilehandles: number;
296
289
  };
297
290
  default: {
298
291
  readonly maxConnections: number;
@@ -323,7 +316,6 @@ declare const NfsServerConfigSchema: Schema.Struct<{
323
316
  readonly maxReaddirEntries: number;
324
317
  readonly maxReaddirReplyBytes: ByteSize.ByteSize;
325
318
  readonly maxNameBytes: ByteSize.ByteSize;
326
- readonly maxFilehandles: number;
327
319
  };
328
320
  };
329
321
  }>;
@@ -373,7 +365,6 @@ export declare const NfsServerConfig: Schema.Struct<{
373
365
  readonly maxReaddirEntries: Schema.Finite;
374
366
  readonly maxReaddirReplyBytes: Schema.ByteSize;
375
367
  readonly maxNameBytes: Schema.ByteSize;
376
- readonly maxFilehandles: Schema.Finite;
377
368
  }> & {
378
369
  constrained: {
379
370
  readonly maxConnections: number;
@@ -404,7 +395,6 @@ export declare const NfsServerConfig: Schema.Struct<{
404
395
  readonly maxReaddirEntries: number;
405
396
  readonly maxReaddirReplyBytes: ByteSize.ByteSize;
406
397
  readonly maxNameBytes: ByteSize.ByteSize;
407
- readonly maxFilehandles: number;
408
398
  };
409
399
  default: {
410
400
  readonly maxConnections: number;
@@ -435,7 +425,6 @@ export declare const NfsServerConfig: Schema.Struct<{
435
425
  readonly maxReaddirEntries: number;
436
426
  readonly maxReaddirReplyBytes: ByteSize.ByteSize;
437
427
  readonly maxNameBytes: ByteSize.ByteSize;
438
- readonly maxFilehandles: number;
439
428
  };
440
429
  };
441
430
  }> & {
@@ -471,7 +460,6 @@ export declare const NfsServerConfig: Schema.Struct<{
471
460
  readonly maxReaddirEntries: number;
472
461
  readonly maxReaddirReplyBytes: ByteSize.ByteSize;
473
462
  readonly maxNameBytes: ByteSize.ByteSize;
474
- readonly maxFilehandles: number;
475
463
  };
476
464
  };
477
465
  };
@@ -513,7 +501,6 @@ export declare const NfsServerConfigOverrides: Schema.Struct<{
513
501
  readonly maxReaddirEntries: Schema.optionalKey<Schema.Finite>;
514
502
  readonly maxReaddirReplyBytes: Schema.optionalKey<Schema.ByteSize>;
515
503
  readonly maxNameBytes: Schema.optionalKey<Schema.ByteSize>;
516
- readonly maxFilehandles: Schema.optionalKey<Schema.Finite>;
517
504
  }>>;
518
505
  }>;
519
506
  /**
@@ -602,6 +589,7 @@ export type NfsServerAddress = typeof NfsServerAddress.Type;
602
589
  export type NfsServerLocalOptions = NfsServerConfigOverrides & {
603
590
  readonly volume: Vfs.Volume;
604
591
  readonly caller: Vfs.Caller;
592
+ readonly writable?: never;
605
593
  readonly policy?: never;
606
594
  readonly peer?: never;
607
595
  readonly allowNonLoopback?: never;
@@ -648,6 +636,8 @@ export type NfsIdentityPolicy = (request: {
648
636
  /** @since 0.1.0 */
649
637
  export type NfsServerNetworkedOptions = NfsServerConfigOverrides & {
650
638
  readonly volume: Vfs.Volume;
639
+ /** Enable mutations only for a volume qualified to survive power loss. */
640
+ readonly writable?: true;
651
641
  readonly policy: NfsIdentityPolicy;
652
642
  /** Evaluated in each accepted socket's context; null closes a connection without a trustworthy peer. */
653
643
  readonly peer: Effect.Effect<NfsPeer | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"NfsServer.d.ts","sourceRoot":"","sources":["../src/NfsServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,IAAI,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,YAAY,MAAM,qCAAqC,CAAA;AAiCnE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,gDAAwC,CAAA;AAEjE;;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gB,KACxB,KAAK,CAAC,KAAK,CACZ,SAAS,EACT,kBAAkB,GAAG,cAAc,EACnC,YAAY,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAC1C,CAAqC;CACvC"}
package/dist/NfsServer.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Models and constructors for the experimental read-only NFSv4.1 server.
2
+ * Models and constructors for the experimental NFSv4.1 server.
3
3
  *
4
4
  * The server exports one live `@effect-vfs/core` volume over NFSv4.1 so that
5
5
  * ordinary NFS clients can mount a virtual filesystem. It implements the
6
- * supported read-only operations, returns `NFS4ERR_ROFS` for filesystem
7
- * mutations, and rejects other unsupported operations.
6
+ * supported read-only operations. Writable operation dispatch requires an
7
+ * explicit option and a volume that reports power-loss durability.
8
8
  *
9
9
  * @since 0.1.0
10
10
  */
@@ -72,8 +72,7 @@ const NfsServerLimitsSchema = Schema.Struct({
72
72
  maxWriteBytes: PositiveByteSize,
73
73
  maxReaddirEntries: PositiveSafeInteger,
74
74
  maxReaddirReplyBytes: PositiveByteSize,
75
- maxNameBytes: NameByteSize,
76
- maxFilehandles: PositiveSafeInteger
75
+ maxNameBytes: NameByteSize
77
76
  });
78
77
  const makeNfsServerLimits = (limits) => Object.freeze({ ...limits });
79
78
  const constrained = makeNfsServerLimits({
@@ -104,8 +103,7 @@ const constrained = makeNfsServerLimits({
104
103
  maxWriteBytes: ByteSize.kibibytes(64),
105
104
  maxReaddirEntries: 64,
106
105
  maxReaddirReplyBytes: ByteSize.kibibytes(64),
107
- maxNameBytes: ByteSize.bytes(255),
108
- maxFilehandles: 512
106
+ maxNameBytes: ByteSize.bytes(255)
109
107
  });
110
108
  const defaultLimits = makeNfsServerLimits({
111
109
  maxConnections: 16,
@@ -135,8 +133,7 @@ const defaultLimits = makeNfsServerLimits({
135
133
  maxWriteBytes: ByteSize.mebibytes(1),
136
134
  maxReaddirEntries: 1_024,
137
135
  maxReaddirReplyBytes: ByteSize.mebibytes(1),
138
- maxNameBytes: ByteSize.bytes(255),
139
- maxFilehandles: 8_192
136
+ maxNameBytes: ByteSize.bytes(255)
140
137
  });
141
138
  /**
142
139
  * Schema for every resource bound enforced by the preview server, with frozen presets.
@@ -182,8 +179,7 @@ export const NfsServerLimitOverrides = Schema.Struct({
182
179
  maxWriteBytes: Schema.optionalKey(NfsServerLimits.fields.maxWriteBytes),
183
180
  maxReaddirEntries: Schema.optionalKey(NfsServerLimits.fields.maxReaddirEntries),
184
181
  maxReaddirReplyBytes: Schema.optionalKey(NfsServerLimits.fields.maxReaddirReplyBytes),
185
- maxNameBytes: Schema.optionalKey(NfsServerLimits.fields.maxNameBytes),
186
- maxFilehandles: Schema.optionalKey(NfsServerLimits.fields.maxFilehandles)
182
+ maxNameBytes: Schema.optionalKey(NfsServerLimits.fields.maxNameBytes)
187
183
  });
188
184
  /** Schema for configuration that can be validated without opening runtime capabilities. */
189
185
  const NfsServerConfigSchema = Schema.Struct({
@@ -290,7 +286,7 @@ const configurationField = (issue) => {
290
286
  return path.length === 0 ? "options" : path.map(String).join(".");
291
287
  };
292
288
  const decodeConfig = (options) => Effect.suspend(() => {
293
- const { caller: _caller, volume: _volume, policy: _policy, peer: _peer, allowNonLoopback: _allowNonLoopback, acceptedFlavors: _acceptedFlavors, ...supplied } = options;
289
+ const { caller: _caller, volume: _volume, policy: _policy, peer: _peer, allowNonLoopback: _allowNonLoopback, acceptedFlavors: _acceptedFlavors, writable: _writable, ...supplied } = options;
294
290
  const suppliedLimits = supplied.limits;
295
291
  const limits = suppliedLimits === undefined
296
292
  ? NfsServerLimits.default
@@ -316,6 +312,16 @@ const make = (options) => Effect.gen(function* () {
316
312
  const limits = config.limits;
317
313
  const policy = options.policy;
318
314
  const networked = policy !== undefined;
315
+ const writable = options.writable;
316
+ if (writable !== undefined && writable !== true) {
317
+ return yield* configurationError("writable", "expected true or omission");
318
+ }
319
+ if (options.writable && !Vfs.isVolumeDurabilityAtLeast(options.volume.durability, "survives-power-loss")) {
320
+ return yield* configurationError("volume.durability", "writable NFS requires survives-power-loss");
321
+ }
322
+ if (options.writable && !networked) {
323
+ return yield* configurationError("policy", "writable NFS requires an explicit identity policy");
324
+ }
319
325
  if (networked && !Predicate.isFunction(policy)) {
320
326
  return yield* configurationError("policy", "policy must be a function");
321
327
  }
@@ -357,8 +363,8 @@ const make = (options) => Effect.gen(function* () {
357
363
  .pipe(Effect.mapError(() => configurationError("volume", "volume could not create a caller")));
358
364
  if (options.caller !== undefined) {
359
365
  const [volumeRoot, callerRoot] = yield* Effect.all([
360
- volumeCaller.rootReference,
361
- options.caller.rootReference
366
+ volumeCaller.root,
367
+ options.caller.root
362
368
  ]).pipe(Effect.mapError(() => configurationError("caller", "caller must be open and belong to volume")));
363
369
  if (volumeRoot !== callerRoot) {
364
370
  return yield* configurationError("caller", "caller must belong to volume");
@@ -366,10 +372,10 @@ const make = (options) => Effect.gen(function* () {
366
372
  }
367
373
  const crypto = yield* Crypto.Crypto;
368
374
  const generation = yield* crypto.randomBytes(16).pipe(Effect.mapError((cause) => new NfsServerError({ cause })));
369
- const identity = Result.getOrThrow(Encoding.decodeHex(options.volume.identity));
370
375
  const storageGeneration = Result.getOrThrow(Encoding.decodeHex(options.volume.incarnation));
371
- const export_ = makeExport(options.caller ?? volumeCaller, storageGeneration, limits, identity, options.volume);
376
+ const export_ = makeExport(options.volume, options.caller ?? volumeCaller, limits);
372
377
  const callers = new Map();
378
+ let writableIdentityKey;
373
379
  const callerFor = policy === undefined ?
374
380
  undefined :
375
381
  (call) => Effect.gen(function* () {
@@ -404,14 +410,19 @@ const make = (options) => Effect.gen(function* () {
404
410
  mapped.groups.length,
405
411
  [...mapped.groups].sort((a, b) => a - b)
406
412
  ].flat().join(":");
413
+ if (options.writable && writableIdentityKey !== undefined && key !== writableIdentityKey)
414
+ return null;
407
415
  const existing = callers.get(key);
408
416
  if (existing !== undefined)
409
417
  return existing;
410
418
  if (callers.size >= limits.maxIdentities)
411
419
  return null;
412
420
  const created = yield* options.volume.caller({ identity: mapped }).pipe(Effect.orElseSucceed(() => null));
413
- if (created !== null)
421
+ if (created !== null) {
414
422
  callers.set(key, created);
423
+ if (options.writable)
424
+ writableIdentityKey = key;
425
+ }
415
426
  return created;
416
427
  });
417
428
  const handlerOptions = {
@@ -421,7 +432,8 @@ const make = (options) => Effect.gen(function* () {
421
432
  callbackTimeout: Duration.seconds(config.callbackTimeoutSeconds),
422
433
  limits,
423
434
  securityFlavors: acceptedFlavors.map((flavor) => flavor === "sys" ? 1 : 0),
424
- now: Date.now
435
+ now: Date.now,
436
+ writable: options.writable ?? false
425
437
  };
426
438
  const handler = yield* makeNfs4Handler(export_, callerFor === undefined ? handlerOptions : { ...handlerOptions, callerFor }).pipe(Effect.mapError((cause) => new NfsServerError({ cause })));
427
439
  yield* startServer(socketServer, networked ? { limits, peer: options.peer } : { limits }, handler).pipe(Effect.mapError((cause) => new NfsServerError({ cause })));
@@ -1,61 +1,62 @@
1
- import type { VirtualFileSystem as Vfs } from "@effect-vfs/core";
1
+ import { VirtualFileSystem as Vfs } from "@effect-vfs/core";
2
2
  import * as ByteSize from "effect/ByteSize";
3
3
  import * as Effect from "effect/Effect";
4
+ import * as Scope from "effect/Scope";
4
5
  /** @internal */
5
6
  export interface ExportLimits {
6
- readonly maxFilehandles: number;
7
7
  readonly maxNameBytes: ByteSize.ByteSize;
8
8
  }
9
9
  /** @internal */
10
+ export type ExportVolume = Pick<Vfs.Volume, "identity" | "durability" | "referenceKey" | "resolveReferenceKey" | "limits" | "usage">;
11
+ /** @internal */
10
12
  export interface OpenedFile {
11
13
  readonly handle: Vfs.FileHandle;
12
14
  readonly close: Effect.Effect<void>;
13
15
  }
14
16
  /** @internal */
15
17
  export interface NfsExport {
16
- readonly capacity: Pick<Vfs.Volume, "limits" | "usage"> | undefined;
17
- /** Selects a caller for one compound while retaining the export's filehandle registry. */
18
+ readonly capacity: Pick<Vfs.Volume, "limits" | "usage">;
19
+ /** Whether filehandles outlive the server: the volume's committed state survives at least a process crash. */
20
+ readonly persistentHandles: boolean;
21
+ /** Selects a caller for one compound; filehandles belong to the volume, not the caller. */
18
22
  readonly withCaller: (caller: Vfs.Caller) => NfsExport;
19
- readonly root: Effect.Effect<Vfs.ObjectReference, Vfs.FsError>;
20
- readonly handleFor: (reference: Vfs.ObjectReference) => Effect.Effect<Uint8Array, ExportCapacityError>;
21
- readonly resolve: (handle: Uint8Array) => Effect.Effect<Vfs.ObjectReference, InvalidFilehandleError>;
22
- readonly observeMetadata: (reference: Vfs.ObjectReference) => Effect.Effect<Vfs.ObjectObservation<Vfs.Metadata>, Vfs.FsError>;
23
- readonly observeDirectory: (reference: Vfs.ObjectReference) => Effect.Effect<Vfs.ObjectObservation<ReadonlyArray<Vfs.DirectoryEntry>>, Vfs.FsError>;
24
- readonly lookup: (directory: Vfs.ObjectReference, name: Uint8Array) => Effect.Effect<Vfs.ObjectReference, Vfs.FsError | InvalidNameError>;
25
- readonly parent: (directory: Vfs.ObjectReference) => Effect.Effect<Vfs.ObjectReference, Vfs.FsError>;
26
- readonly readLink: (reference: Vfs.ObjectReference) => Effect.Effect<Uint8Array, Vfs.FsError>;
27
- readonly mkdir: (directory: Vfs.ObjectReference, name: Uint8Array, settings?: Vfs.MkdirReferenceSettings) => Effect.Effect<Vfs.ReferenceEntryResult, Vfs.FsError | InvalidNameError | ExportCapacityError>;
28
- readonly symlink: (target: Vfs.PathInput, directory: Vfs.ObjectReference, name: Uint8Array, settings?: Vfs.SymlinkReferenceSettings) => Effect.Effect<Vfs.ReferenceEntryResult, Vfs.FsError | InvalidNameError | ExportCapacityError>;
29
- readonly link: Vfs.Caller["linkReference"];
30
- readonly remove: Vfs.Caller["removeReference"];
31
- readonly rename: Vfs.Caller["renameReference"];
32
- readonly chmod: Vfs.Caller["chmodReference"];
33
- readonly chown: Vfs.Caller["chownReference"];
34
- readonly utimes: Vfs.Caller["utimesReference"];
35
- readonly truncate: Vfs.Caller["truncateReference"];
36
- readonly open: (reference: Vfs.ObjectReference, access?: Vfs.OpenReferenceSettings["access"]) => Effect.Effect<OpenedFile, Vfs.FsError>;
37
- readonly openChild: (directory: Vfs.ObjectReference, name: Uint8Array, settings: Vfs.OpenChildReferenceSettings) => Effect.Effect<Vfs.OpenChildReferenceResult & {
23
+ readonly root: Effect.Effect<Vfs.ObjectReference, Vfs.VfsError>;
24
+ readonly handleFor: (reference: Vfs.ObjectReference) => Effect.Effect<Uint8Array, Vfs.VfsError>;
25
+ readonly resolve: (handle: Uint8Array) => Effect.Effect<Vfs.ObjectReference, InvalidFilehandleError | Vfs.VfsError>;
26
+ readonly observeMetadata: (reference: Vfs.ObjectReference) => Effect.Effect<Vfs.ObjectObservation<Vfs.Metadata>, Vfs.VfsError>;
27
+ readonly observeDirectory: (reference: Vfs.ObjectReference) => Effect.Effect<Vfs.ObjectObservation<ReadonlyArray<Vfs.DirectoryEntry>>, Vfs.VfsError>;
28
+ readonly lookup: (directory: Vfs.ObjectReference, name: Uint8Array) => Effect.Effect<Vfs.ObjectReference, Vfs.VfsError | InvalidNameError>;
29
+ readonly parent: (directory: Vfs.ObjectReference) => Effect.Effect<Vfs.ObjectReference, Vfs.VfsError>;
30
+ readonly readLink: (reference: Vfs.ObjectReference) => Effect.Effect<Uint8Array, Vfs.VfsError>;
31
+ readonly mkdir: (directory: Vfs.ObjectReference, name: Uint8Array, settings?: Vfs.MkdirOptions) => Effect.Effect<Vfs.ReferenceEntryResult, Vfs.VfsError | InvalidNameError>;
32
+ readonly symlink: (target: Vfs.PathInput, directory: Vfs.ObjectReference, name: Uint8Array, settings?: Vfs.SymlinkOptions) => Effect.Effect<Vfs.ReferenceEntryResult, Vfs.VfsError | InvalidNameError>;
33
+ readonly link: (source: Vfs.ObjectReference, directory: Vfs.ObjectReference, name: Uint8Array) => Effect.Effect<Vfs.ReferenceEntryResult, Vfs.VfsError>;
34
+ readonly remove: (directory: Vfs.ObjectReference, name: Uint8Array) => Effect.Effect<Vfs.DirectoryChange, Vfs.VfsError>;
35
+ readonly rename: (sourceDirectory: Vfs.ObjectReference, sourceName: Uint8Array, destinationDirectory: Vfs.ObjectReference, destinationName: Uint8Array) => Effect.Effect<Vfs.RenameReferenceResult, Vfs.VfsError>;
36
+ readonly setattr: (reference: Vfs.ObjectReference, attributes: Vfs.SetattrOptions) => Effect.Effect<void, Vfs.VfsError>;
37
+ /** The bits of `bits` the caller may exercise on the object. */
38
+ readonly access: (reference: Vfs.ObjectReference, bits: number) => Effect.Effect<number, Vfs.VfsError>;
39
+ /**
40
+ * Opens into a scope forked from the one in context, so closing that scope closes the file, and `close`
41
+ * closes the file early and unregisters it, never failing.
42
+ */
43
+ readonly open: (reference: Vfs.ObjectReference, access?: Vfs.OpenOptions["access"]) => Effect.Effect<OpenedFile, Vfs.VfsError, Scope.Scope>;
44
+ /** Looks up or creates and opens a child, into a forked scope as `open` does. */
45
+ readonly openChild: (directory: Vfs.ObjectReference, name: Uint8Array, settings: Vfs.OpenEntryOptions) => Effect.Effect<Vfs.OpenEntryResult & {
38
46
  readonly close: Effect.Effect<void>;
39
- }, Vfs.FsError | InvalidNameError | ExportCapacityError>;
47
+ }, Vfs.VfsError | InvalidNameError, Scope.Scope>;
40
48
  readonly fsid: readonly [bigint, bigint];
41
49
  }
42
- declare const ExportCapacityError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
43
- readonly _tag: "ExportCapacityError";
44
- } & Readonly<A>;
45
50
  /** @internal */
46
- export declare class ExportCapacityError extends ExportCapacityError_base<{
47
- readonly detail: string;
48
- }> {
49
- constructor(message: string);
50
- }
51
+ export type InvalidFilehandleReason = "Malformed" | "Expired" | "Stale";
51
52
  declare const InvalidFilehandleError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
52
53
  readonly _tag: "InvalidFilehandleError";
53
54
  } & Readonly<A>;
54
55
  /** @internal */
55
56
  export declare class InvalidFilehandleError extends InvalidFilehandleError_base<{
56
- readonly reason: "Malformed" | "WrongGeneration" | "Stale" | "Unknown" | "Unavailable";
57
+ readonly reason: InvalidFilehandleReason;
57
58
  }> {
58
- constructor(reason: "Malformed" | "WrongGeneration" | "Stale" | "Unknown" | "Unavailable");
59
+ constructor(reason: InvalidFilehandleReason);
59
60
  }
60
61
  /** @internal */
61
62
  export type InvalidNameReason = "Empty" | "TooLong" | "ForbiddenByte" | "Encoding" | "Reserved";
@@ -72,6 +73,6 @@ export declare class InvalidNameError extends InvalidNameError_base<{
72
73
  /** @internal */
73
74
  export declare const validateName: (bytes: Uint8Array, maxNameBytes: ByteSize.ByteSize) => string;
74
75
  /** @internal */
75
- export declare const makeExport: (caller: Vfs.Caller, generation: Uint8Array, limits: ExportLimits, identity?: Uint8Array, capacity?: Pick<Vfs.Volume, "limits" | "usage">) => NfsExport;
76
+ export declare const makeExport: (volume: ExportVolume, caller: Vfs.Caller, limits: ExportLimits) => NfsExport;
76
77
  export {};
77
78
  //# sourceMappingURL=export.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/internal/export.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,IAAI,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAE3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAUvC,gBAAgB;AAChB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAA;CACzC;AAED,gBAAgB;AAChB,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,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