Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

open-ioctl

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

open-ioctl

Opens device file in non-blocking ioctl mode only

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

open-ioctl

Opens device file in non-blocking ioctl mode only

npm version license Build Status Code Climate Test Coverage Issue Count TypeScript Typings

Installation

Install with npm:

$ npm install open-ioctl

NPM

Description

Opening ioctl only device drivers made easy.

Opens device file in non-blocking ioctl mode. File is opend with flags 3 | O_NONBLOCK.

Flag 3 means that only ioctl calls can be made for comunication with the device driver (remember read/write operations are expensive this is why open-ioctl was made in first place to make it easer for performance and command oriented device drivers).

Flag O_NONBLOCK means that ioctl calls will not put process and thread from which they came to sleep.

Warning

O_NONBLOCK

O_NONBLOCK: flag is different compared to O_ASYNC (which is recomended to use only in rear an special cases, also you have no access to it in node). O_NONBLOCK means that all syscalls respectivly ioctl calls will not put the process and thread from which they were made to sleep while the result is awaited. This is perfect for in node process call so no even loop block will occure.

O_ASYNC can't be used on regular device files only terminals, sockets and pipes also it's not exported in fs.constants from the 'fs' module with a reason! For more information see: Posix open(2), open(3).

Usage

openIoctl(path, callback)

  • path <String>
  • callback <Function>

path is based on /dev

The callback gets two arguments (err, fd).

  • err <ErrnoException>
  • fd <Integer>
const { openIoctl } = require('open-ioctl');
const { close } = require('fs');
openIoctl('test_dev', function(err, fd) { // /dev/test_dev
  if(err) {
    console.log(err);
  } else {
    console.log(fd);
    /* ioctl calls */
    close(fd, function(err) {
      if(err) {
        console.log(err);
      }
    });
  }
});

openIoctlSync(path)

  • path <String>

Synchronous version of openIoctl(). Returns an integer representing the file descriptor <Integer>.

const { openIoctlSync } = require('open-ioctl');
const { closeSync } = require('fs');
var fd = openIoctlSync('test/test_dev'); // /dev/test/test_dev
console.log(fd);
/* ioctl calls */
closeSync(fd);

open device file located outside of /dev

const { openIoctlSync } = require('open-ioctl');
const { closeSync } = require('fs');
var fd = openIoctlSync('../proc/some_dev'); // /proc/some_dev
console.log(fd);
/* ioctl calls */
closeSync(fd);

For full working example code visit: (https://github.com/NoHomey/nodejs-ioctl-example)

Written in TypeScript and TypeScript Ready!

Keywords

FAQs

Package last updated on 18 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc