Operating system for OpenComputers
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

30 wiersze
719B

  1. local fsmanager = {}
  2. local function mount(addr)
  3. dest = component.invoke(addr,"getLabel") or "mnt/"..addr:sub(1,3)
  4. dest = "/"..dest
  5. syslog("Mounting "..addr.." to "..dest)
  6. fs.makeDirectory(dest)
  7. local w,r = fs.mount(dest,component.proxy(addr))
  8. if not w then
  9. syslog("Failed to mount: "..r)
  10. end
  11. end
  12. for addr, _ in component.list("filesystem") do
  13. mount(addr)
  14. end
  15. function fsmanager.start()
  16. return os.spawn(function()
  17. while true do
  18. local tE = {coroutine.yield()}
  19. if tE[1] == "component_added" and tE[3] == "filesystem" then
  20. mount(tE[2])
  21. elseif tE[1] == "component_removed" and tE[3] == "filesystem" then
  22. fs.umount("/mnt/"..tE[2]:sub(1,3))
  23. end
  24. end
  25. end,"fsmanager")
  26. end
  27. return fsmanager