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
This commit is contained in:
@@ -1,18 +1,11 @@
|
||||
//@ts-check
|
||||
const fs =require('fs')
|
||||
/**
|
||||
* @type {{ mount: (device_path: string, mount_point: string, fs: string, flags: number, fsparams: string ) => number }}
|
||||
*///@ts-expect-error
|
||||
const nodemount = require("./mount.node")
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
const cmount = nodemount.mount
|
||||
|
||||
import * as fs from 'fs'
|
||||
import { dlopen, FFIType } from 'bun:ffi'
|
||||
import { filesystems } from './suportedFilesystems'
|
||||
|
||||
/* These are the fs-independent mount-flags: up to 16 flags are
|
||||
supported */
|
||||
const flags = {
|
||||
export const flags = {
|
||||
MS_RDONLY: 1, /* Mount read-only. */
|
||||
MS_NOSUID: 2, /* Ignore suid and sgid bits. */
|
||||
MS_NODEV: 4, /* Disallow access to device special files. */
|
||||
@@ -41,6 +34,19 @@ const flags = {
|
||||
MS_NOUSER: 1 << 31
|
||||
};
|
||||
|
||||
const {
|
||||
symbols: {
|
||||
mount,
|
||||
},
|
||||
} = dlopen('/usr/lib/libc.so.6', {
|
||||
mount: {
|
||||
args: [ FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.u64, FFIType.cstring ],
|
||||
returns: FFIType.int,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} devicePath
|
||||
* @param {string} mountPoint
|
||||
@@ -49,20 +55,13 @@ const flags = {
|
||||
* @param {string} fsparams
|
||||
* @returns {number}
|
||||
*/
|
||||
function mount(devicePath, mountPoint, fstype, flags, fsparams) {
|
||||
const supportedFilesystems = require('./suportedFilesystems')
|
||||
|
||||
const filesystem = supportedFilesystems.find( v => v.name === fstype)
|
||||
export function JSmount(devicePath, mountPoint, fstype, flags, fsparams) {
|
||||
const filesystem = filesystems.find( v => v.name === fstype)
|
||||
if(! filesystem) {
|
||||
throw "Invalid filesystem"
|
||||
}
|
||||
|
||||
if(! fs.existsSync(devicePath) && filesystem.hasdev)
|
||||
throw "Device don't exist"
|
||||
return cmount(devicePath, mountPoint, fstype, flags, fsparams)
|
||||
return mount(Buffer.from(devicePath), Buffer.from(mountPoint), Buffer.from(fstype), flags, Buffer.from(fsparams))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = { mount, cmount, flags }
|
||||
Reference in New Issue
Block a user