34 lines
1.1 KiB
Plaintext
34 lines
1.1 KiB
Plaintext
--:Minify:--
|
|
local kernel = ...
|
|
|
|
local function trim(str)
|
|
local s, e = 1, #str
|
|
while s <= e and (str:sub(s,s) == " " or str:sub(s,s) == "\t") do s = s + 1 end
|
|
while e >= s and (str:sub(e,e) == " " or str:sub(e,e) == "\t" or str:sub(e,e) == "\n" or str:sub(e,e) == "\r") do e = e - 1 end
|
|
if s > e then return "" end
|
|
return str:sub(s,e)
|
|
end
|
|
|
|
for _, line in ipairs(string.split(kernel.fstab, "\n")) do
|
|
line = trim(line)
|
|
if line ~= "" and line:sub(1,1) == "U" then
|
|
local semicolon_pos
|
|
for i = 3, #line do
|
|
if line:sub(i,i) == ";" then
|
|
semicolon_pos = i
|
|
break
|
|
end
|
|
end
|
|
|
|
if not semicolon_pos or semicolon_pos == 3 then
|
|
kernel.log("Invalid fstab line: "..line.." ... Skipping.", "WARN", 8)
|
|
else
|
|
local id = line:sub(3, semicolon_pos - 1)
|
|
local path = trim(line:sub(semicolon_pos + 1))
|
|
kernel.log("Mounted "..id.." to "..path)
|
|
if id ~= "$" then
|
|
kernel.vfs.mount(path, id)
|
|
end
|
|
end
|
|
end
|
|
end |