added more hpv funcs and made primshell

This commit is contained in:
2026-01-16 14:17:28 -05:00
parent bd8fe50770
commit 70532f6e2c
14 changed files with 321 additions and 121 deletions

View File

@@ -71,13 +71,9 @@ local function allocFD(task)
return fd
end
local total=0
local function checkSystemLimit()
-- enforce system-wide limit
local total = 0
for _, task in pairs(kernel.tasks or {}) do
for _ in pairs(task.fd) do total = total + 1 end
end
if total >= kernel.config.maxOpenFiles then
if total >= kernel.config.maxOpenFiles-16 then
error("ENFILE") -- Too many open files in the system
end
end
@@ -100,6 +96,7 @@ function vfs.open(path, mode)
local file = newFileObject(disk.address, handle, mode, path)
local fd = allocFD(task)
task.fd[fd] = file
total=total+1
return fd
end
@@ -114,6 +111,7 @@ function vfs.close(fd)
if file.refcount == 0 then
file.handle.close()
end
total=total-1
return true
end
@@ -184,6 +182,12 @@ function vfs.type(path)
return disk:type(diskPath)
end
function vfs.isDirectory(path)
local disk, diskPath = resolvePath(path)
if not disk then return false end
return disk:directoryExists(diskPath)
end
-- CWD
function vfs.getcwd()
return kernel.currentTask.cwd
@@ -274,5 +278,6 @@ kernel.syscalls["VFS_setcwd"] = vfs.setcwd
kernel.syscalls["VFS_whereis"] = vfs.whereis
kernel.syscalls["VFS_dup"] = vfs.dup
kernel.syscalls["VFS_dup2"] = vfs.dup2
kernel.syscalls["VFS_isDirectory"]= vfs.isDirectory
kernel.log("VFS module loaded")