Skip to content

allocDeviceId

allocDeviceId(): number

Defined in: packages/core/src/kernel/fileservers/identity.ts:44

Allocate a unique device number for a fileserver instance.

number

A previously-unused positive integer device id.

Every fileserver factory in this package calls allocDeviceId() once at construction and stores the result as the dev field on every Stat it emits. The kernel pairs (dev, ino) to uniquely identify inodes across mounted fileservers. Custom fileservers that synthesize Stat results should call this once per instance to stay compatible with that identity model.

import { allocDeviceId } from '@fishnet/core'
const dev = allocDeviceId()
const stat = { name: 'foo', size: 0, type: 'file', mtime: 0, mode: 0o644, ino: 1, dev, nlink: 1 }

Not stable across module re-evaluation (HMR / multi-bundle). Fine for in-process identity, unsuitable for persistent storage.