メインコンテンツへスキップ

@php-wasm/node

Index

Type Aliases

Fd

Fd: number

FileLockManager

FileLockManager: { findFirstConflictingByteRangeLock: (path: string, desiredLock: RequestedRangeLock) => Omit<RequestedRangeLock, fd> | undefined; lockFileByteRange: (path: string, requestedLock: RequestedRangeLock) => boolean; lockWholeFile: (path: string, op: WholeFileLockOp) => boolean; releaseLocksForProcess: (pid: number) => void; releaseLocksForProcessFd: (pid: number, fd: number, path: string) => void }

This is an interface used to abstract byte range locking like fcntl() and whole-file locking like flock().


Type declaration

  • findFirstConflictingByteRangeLock: (path: string, desiredLock: RequestedRangeLock) => Omit<RequestedRangeLock, fd> | undefined

    Get the first lock that would conflict with the specified lock.

    This method is meant to satisfy the needs of the F_GETLK fcntl() command. https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fGETLK-1

    @returns

    A promise for the first conflicting lock, or undefined if there is no conflict.

  • lockFileByteRange: (path: string, requestedLock: RequestedRangeLock) => boolean

    Update the lock on a byte range of a file.

    This method is for locking with the F_SETLK fcntl() command. https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fSETLK-1

    @returns

    A promise for a boolean value. When locking: True if the lock was acquired, false if it was not. When unlocking: Always true.

      • Parameters

        • path: string

          The path of the file to lock. This should be the path of the file in the underlying filesystem.

        • requestedLock: RequestedRangeLock

          The lock to request, including start, end, type, and pid.

        Returns boolean

  • lockWholeFile: (path: string, op: WholeFileLockOp) => boolean

    Update the lock on the whole file.

    This method is for updating the lock on the whole file with the F_SETLKW fcntl() command. https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fSETLKW-1

    @returns

    A promise for a boolean value.

      • Parameters

        • path: string

          The path of the file to lock. This should be the path of the file in the underlying filesystem.

        • op: WholeFileLockOp

          The operation to perform, including 'shared', 'exclusive', or 'unlock'.

        Returns boolean

  • releaseLocksForProcess: (pid: number) => void

    Release all locks for a given process.

    Used when a process exits or is otherwise terminated.

      • (pid: number): void
      • Parameters

        • pid: number

          The PID of the process that wants to release the locks.

        Returns void

  • releaseLocksForProcessFd: (pid: number, fd: number, path: string) => void

    Release all locks for the given process and file descriptor.

      • (pid: number, fd: number, path: string): void
      • Parameters

        • pid: number

          The process ID to release locks for.

        • fd: number

          The file descriptor to release locks for.

        • path: string

          The path to the file to release locks for. This should be the path of the file in the underlying filesystem.

        Returns void

Pid

Pid: number

RequestedRangeLock

RequestedRangeLock: Readonly<{ end: bigint; pid: Pid; start: bigint; type: shared | exclusive | unlocked }>

WholeFileLock

WholeFileLockOp

WholeFileLockOp: { fd: number; pid: number; type: shared | exclusive | unlock }

Type declaration

  • fd: number
  • pid: number
  • type: shared | exclusive | unlock

WholeFileLock_Exclusive

WholeFileLock_Exclusive: { fd: Fd; pid: Pid; type: exclusive }

Type declaration

  • fd: Fd
  • pid: Pid
  • type: exclusive

WholeFileLock_Shared

WholeFileLock_Shared: { pidFds: Map<Pid, Set<Fd>>; type: shared }

Type declaration

  • pidFds: Map<Pid, Set<Fd>>

    NOTE: flock() locks are associated with open file descriptors and duplicated file descriptors. We do not currently recognize duplicate file descriptors.

  • type: shared

WholeFileLock_Unlocked

WholeFileLock_Unlocked: { type: unlocked }

Type declaration

  • type: unlocked