linux-devnode
v0.0.1
Published
Linux device node library for Node.js
Downloads
13
Readme
node-linux-devnode
Linux device node library for Node.js
API
devnode.open(options)
=> Promise(FileHandle
)
Opens a device node as Node.js FileHandle
.
options.type
type of device node, either"character"
or"block"
options.major
major number of device nodeoptions.minor
minor number of device nodeoptions.flags
open flags, either"r"
,"w"
or"r+"
, see Node.js fs.open() documentation
For a description of the FileHandle
API, visit Node.js's documentation
Minimal example
import devnode from "linux-devnode";
// /dev/zero is 1:5
const fh = await devnode.open({
"type": "character",
"major": 1,
"minor": 5,
"flags": "r"
});
const zero = await fh.read(Buffer.alloc(32), 0, 32, 0);
console.log("zero =", zero);
await fh.close();