working on api docs
This commit is contained in:
1 parent
56d8fb2016
commit
38d56ced19
43 files changed
+5669
-618
No files matched your search
@@ -301,11 +301,70 @@ for i,v in pairs(kernel.vfs.mounts) do
|
||||
|
||||
end
|
||||
|
||||
local function newdev(path, device)
|
||||
if kernel.uid ~= 0 then error("EACCES") end
|
||||
if type(path) ~= "string" or path == "" then
|
||||
error("EINVAL")
|
||||
end
|
||||
if type(device) ~= "function" then
|
||||
error("EINVAL")
|
||||
end
|
||||
|
||||
-- Normalize path
|
||||
path = path:gsub("^/+", ""):gsub("/+$", "")
|
||||
|
||||
if path == "" then error("EINVAL") end
|
||||
|
||||
local steps = kernel.vfs.splitPath(path)
|
||||
|
||||
if #steps == 0 then error("EINVAL") end
|
||||
|
||||
local step = data
|
||||
|
||||
-- Create intermediate directories
|
||||
for i = 1, #steps - 1 do
|
||||
local name = steps[i]
|
||||
|
||||
if name == "." or name == ".." then
|
||||
error("EINVAL")
|
||||
end
|
||||
|
||||
local entry = step[name]
|
||||
|
||||
if entry == nil then
|
||||
entry = {}
|
||||
step[name] = entry
|
||||
elseif type(entry) ~= "table" then
|
||||
error("ENOTDIR")
|
||||
end
|
||||
|
||||
step = entry
|
||||
end
|
||||
|
||||
local name = steps[#steps]
|
||||
|
||||
if name == "." or name == ".." then
|
||||
error("EINVAL")
|
||||
end
|
||||
|
||||
-- Don't overwrite existing devices or directories
|
||||
if step[name] ~= nil then
|
||||
error("EEXIST")
|
||||
end
|
||||
|
||||
-- Register device
|
||||
step[name] = device
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
data["raw"]={["by-type"]={}}
|
||||
data["gfx"]={}
|
||||
data["input"]={}
|
||||
data["tty"]={}
|
||||
kernel.devfs={}
|
||||
kernel.devfs.newdev=newdev
|
||||
kernel.syscalls.newdev=kernel.devfs.newdev
|
||||
kernel.devfs.data=data
|
||||
kernel.devfs.proxy=proxy
|
||||
kernel.disks["devfs0000"]=proxy
|
||||
Reference in new issue
Block a user