All files / json-pack/src/nfs/v4/server/operations OpenFileState.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 1/1
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                26x             210x           210x           210x             210x             210x             210x             210x             210x      
import type * as struct from '../../structs';
import type {FileHandle} from 'node:fs/promises';
 
/**
 * Open file state record for NFSv4 OPEN operations.
 * Tracks state for an individual file that has been opened by a client,
 * including the stateid, file descriptor, share reservations, and confirmation status.
 */
export class OpenFileState {
  constructor(
    /**
     * Stateid assigned to this open file.
     * Used by client to identify this particular open in subsequent operations
     * (CLOSE, OPEN_DOWNGRADE, READ, WRITE, etc.).
     */
    public readonly stateid: struct.Nfsv4Stateid,
 
    /**
     * Absolute file system path of the opened file.
     * Used to identify the file and check for share reservation conflicts.
     */
    public readonly path: string,
 
    /**
     * Node.js file descriptor/handle for the opened file.
     * Used to perform I/O operations and must be closed when the file is closed.
     */
    public readonly fd: FileHandle,
 
    /**
     * Share access mode - which operations this open allows.
     * Bitwise OR of OPEN4_SHARE_ACCESS_READ, OPEN4_SHARE_ACCESS_WRITE.
     * Controls what the opener can do with the file.
     */
    public shareAccess: number,
 
    /**
     * Share deny mode - which operations this open denies to others.
     * Bitwise OR of OPEN4_SHARE_DENY_READ, OPEN4_SHARE_DENY_WRITE, or OPEN4_SHARE_DENY_NONE.
     * Controls what conflicting operations are blocked for other opens.
     */
    public shareDeny: number,
 
    /**
     * Key identifying the open-owner that opened this file.
     * Format: `${clientid}:${base64(owner)}`.
     * Links this open back to the owner for sequence number management.
     */
    public readonly openOwnerKey: string,
 
    /**
     * Sequence number for this open.
     * Used to detect replayed or out-of-order operations.
     * Incremented on OPEN_CONFIRM and OPEN_DOWNGRADE.
     */
    public seqid: number,
 
    /**
     * Whether this open has been confirmed via OPEN_CONFIRM.
     * NFSv4.0 requires new opens from new open-owners to be confirmed.
     * Once confirmed, the open can be used for READ/WRITE operations.
     */
    public confirmed: boolean,
  ) {}
}