fix de cfiles

This commit is contained in:
Marc
2022-02-15 12:28:44 +01:00
parent 6c697e63c7
commit 07b7ca5482
+2 -3
View File
@@ -1,7 +1,6 @@
//@ts-check //@ts-check
//@ts-expect-error //@ts-expect-error
const { syscall } = require('./syscall.node') const { syscall } = require('./syscall.node')
const { close, open, modes } = require('./cfiles.js')
const errno = require('./errno') const errno = require('./errno')
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
@@ -22,7 +21,7 @@ const doProcExists = () => fs.existsSync('/proc')
* @deprecated un tested dangerous * @deprecated un tested dangerous
*/ */
function finit_module(path, params = "", flags = 0) { function finit_module(path, params = "", flags = 0) {
const fileDescriptor = open(path, modes.O_RDONLY) const fileDescriptor = fs.openSync(path, 'r')
const result = syscall(SYSCALL_FINIT_MODULE, fileDescriptor, params, flags) const result = syscall(SYSCALL_FINIT_MODULE, fileDescriptor, params, flags)
if(result > 0) { if(result > 0) {
throw new Error(errno[result]) throw new Error(errno[result])
@@ -63,4 +62,4 @@ function lsmod() {
return fs.readFileSync('/proc/modules').toString('utf-8').split('\n') return fs.readFileSync('/proc/modules').toString('utf-8').split('\n')
} }
module.exports = { modprobe, uname, finit_module, doProcExists, lsmod } module.exports = { modprobe, uname, finit_module, doProcExists, lsmod, syscall }