Files
Linux.js---javascript-OS/rootfs overrides/usr/bin/modprobe.js
T
Marc 721c919c7b ChibraxOS 2
Changes:
- kernel 6.0.2
- Broken init scripts
- Switch to bun for better peroformance an easier ffi
- Removed grup
- Efi support without graphics (at least graphics werent tested)
- Suppression de toutes les dépendance non libc
- new splash
- broken audio
- typescript support
- ls rewritten to be more reliable
2022-10-22 13:47:33 +02:00

45 lines
1.1 KiB
JavaScript

//@ts-check
import { finit_module, uname } from '../../core/kernel.js'
import * as fs from 'fs'
import * as path from '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
}