more modprobe work, still not functionnal
This commit is contained in:
@@ -1,3 +1,44 @@
|
||||
const { modprobe } = require('/chibrax/kernel.js')
|
||||
if(process.argv[3])modprobe(process.argv[3])
|
||||
//@ts-check
|
||||
const { finit_module, uname } = require('../../chibrax/kernel.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const name = uname()
|
||||
const modulePath = path.join('/lib/modules', name, 'kernel')
|
||||
|
||||
|
||||
if(process.argv[3]) {
|
||||
let filename = process.argv[3]
|
||||
if(!filename.endsWith('.ko')) {
|
||||
filename += '.ko'
|
||||
}
|
||||
const kernModule = findmodule(modulePath, filename)
|
||||
if(kernModule) {
|
||||
finit_module(kernModule)
|
||||
} else {
|
||||
console.log('module not found')
|
||||
}
|
||||
}
|
||||
else console.log("missing argument")
|
||||
|
||||
/**
|
||||
* @param { string } modulesPath
|
||||
* @param { string } moduleName
|
||||
* @returns {string | null }
|
||||
*/
|
||||
function findmodule(modulesPath, moduleName) {
|
||||
if (fs.existsSync(path.join(modulesPath, moduleName))) {
|
||||
return path.join(modulesPath, moduleName)
|
||||
}
|
||||
const subfiles = fs.readdirSync(modulesPath, { withFileTypes: true })
|
||||
|
||||
for (const file of subfiles) {
|
||||
if(file.isDirectory()) {
|
||||
const foundModule = findmodule(path.join(modulesPath, file.name), moduleName)
|
||||
if(foundModule) {
|
||||
return foundModule
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user