1
1
miroir de https://git.shadowkat.net/izaya/OC-PsychOS2.git synchronisé 2024-09-27 14:45:18 -04:00

moved tape-iofs to tape-devfs, made it handle tape drive addition/removal over time

Cette révision appartient à :
XeonSquared 2019-12-20 15:22:18 +11:00
Parent 3c8ec4cabc
révision 200b99eb0c
2 fichiers modifiés avec 23 ajouts et 8 suppressions

23
service/tape-devfs.lua Fichier normal
Voir le fichier

@ -0,0 +1,23 @@
local counter = 0
local td = {}
local function addNode(addr)
devfs.register("tape"..tonumber(counter),function()
local tape = component.proxy(addr)
return tape.read, tape.write, function() end, tape.seek
end)
td[addr] = counter
counter = counter + 1
end
for addr in component.list("tape_drive") do
addNode(addr)
end
while true do
local tE = {coroutine.yield()}
if tE[1] == "component_added" and tE[3] == "tape_drive" then
addNode[tE[2]]
elseif tE[1] == "component_removed" and tE[3] == "tape_drive" then
if td[tE[2]] then
fs.remove("/dev/tape"..tostring(td[tE[2]]))
end
end
end

Voir le fichier

@ -1,8 +0,0 @@
local counter = 0
for addr in component.list("tape_drive") do
iofs.register("tape"..tonumber(counter),function()
local tape = component.proxy(addr)
return tape.read, tape.write, function() end, tape.seek
end)
counter = counter + 1
end