{"id":20110899,"url":"https://github.com/nohomey/open-ioctl","last_synced_at":"2026-05-13T02:34:16.467Z","repository":{"id":57315069,"uuid":"62938658","full_name":"NoHomey/open-ioctl","owner":"NoHomey","description":"Opens device file in non-blocking ioctl mode only","archived":false,"fork":false,"pushed_at":"2020-11-17T15:50:08.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T12:18:04.918Z","etag":null,"topics":["device-drivers","nodejs","nonblock","open-files","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NoHomey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-09T07:46:09.000Z","updated_at":"2022-02-04T03:04:21.000Z","dependencies_parsed_at":"2022-09-18T20:51:15.665Z","dependency_job_id":null,"html_url":"https://github.com/NoHomey/open-ioctl","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoHomey%2Fopen-ioctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoHomey%2Fopen-ioctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoHomey%2Fopen-ioctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoHomey%2Fopen-ioctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NoHomey","download_url":"https://codeload.github.com/NoHomey/open-ioctl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241550765,"owners_count":19980809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["device-drivers","nodejs","nonblock","open-files","typescript"],"created_at":"2024-11-13T18:13:59.351Z","updated_at":"2026-05-13T02:34:16.433Z","avatar_url":"https://github.com/NoHomey.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# open-ioctl\n\nOpens device file in non-blocking ioctl mode only\n\n[![npm version](https://badge.fury.io/js/open-ioctl.svg)](https://badge.fury.io/js/open-ioctl)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/NoHomey/open-ioctl)\n[![Build Status](https://semaphoreci.com/api/v1/nohomey/open-ioctl/branches/master/badge.svg)](https://semaphoreci.com/nohomey/open-ioctl)\n[![Code Climate](https://codeclimate.com/github/NoHomey/open-ioctl/badges/gpa.svg)](https://codeclimate.com/github/NoHomey/open-ioctl)\n[![Test Coverage](https://codeclimate.com/github/NoHomey/open-ioctl/badges/coverage.svg)](https://codeclimate.com/github/NoHomey/open-ioctl/coverage)\n[![Issue Count](https://codeclimate.com/github/NoHomey/open-ioctl/badges/issue_count.svg)](https://codeclimate.com/github/NoHomey/open-ioctl)\n![TypeScript](https://img.shields.io/badge/%3C%20%2F%3E-TypeScript-blue.svg)\n![Typings](https://img.shields.io/badge/typings-%E2%9C%93-brightgreen.svg)\n\n# Installation\n\nInstall with npm:\n\n```bash\n$ npm install open-ioctl\n```\n\n# Description\n\nOpening ioctl only device drivers made easy.\n\nOpens device file in non-blocking ioctl mode. File is opend with flags 3 | O_NONBLOCK.\n\nFlag 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).\n\nFlag O_NONBLOCK means that ioctl calls will not put process and thread from which they came to sleep.\n\n# Warning\n\n## O_NONBLOCK\n\nO_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).\nO_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.\n\nO_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).\n\n# Usage\n\n## openIoctl(path, callback)\n\n- path \\\u003cString\\\u003e\n- callback \\\u003cFunction\\\u003e\n\n### path is based on /dev\n\nThe callback gets two arguments (err, fd).\n\n- err \\\u003cErrnoException\\\u003e\n- fd \\\u003cInteger\\\u003e\n\n```javascript\nconst { openIoctl } = require('open-ioctl');\nconst { close } = require('fs');\nopenIoctl('test_dev', function(err, fd) { // /dev/test_dev\n  if(err) {\n    console.log(err);\n  } else {\n    console.log(fd);\n    /* ioctl calls */\n    close(fd, function(err) {\n      if(err) {\n        console.log(err);\n      }\n    });\n  }\n});\n```\n\n## openIoctlSync(path)\n\n- path \\\u003cString\\\u003e\n\nSynchronous version of openIoctl(). Returns an integer representing the file descriptor \\\u003cInteger\\\u003e.\n\n```javascript\nconst { openIoctlSync } = require('open-ioctl');\nconst { closeSync } = require('fs');\nvar fd = openIoctlSync('test/test_dev'); // /dev/test/test_dev\nconsole.log(fd);\n/* ioctl calls */\ncloseSync(fd);\n```\n\n## open device file located outside of /dev\n\n```javascript\nconst { openIoctlSync } = require('open-ioctl');\nconst { closeSync } = require('fs');\nvar fd = openIoctlSync('../proc/some_dev'); // /proc/some_dev\nconsole.log(fd);\n/* ioctl calls */\ncloseSync(fd);\n```\n\n# For full working example code visit: (https://github.com/NoHomey/nodejs-ioctl-example)\n\n# Written in TypeScript and TypeScript Ready!\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnohomey%2Fopen-ioctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnohomey%2Fopen-ioctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnohomey%2Fopen-ioctl/lists"}