Compare commits

..

2 Commits

4 changed files with 16 additions and 7 deletions

View File

@ -1,3 +1,4 @@
local component = require "component"
local partition = {} local partition = {}
local eformat = "c20c4>I4>I4" local eformat = "c20c4>I4>I4"

View File

@ -1,3 +1,4 @@
local component = require "component"
local tA = {...} local tA = {...}
local fdisk = {} local fdisk = {}
local addr = component.get(table.remove(tA, 1)) local addr = component.get(table.remove(tA, 1))
@ -15,15 +16,18 @@ function fdisk.show()
end end
function fdisk.del(i) function fdisk.del(i)
local pt = require("diskpart").getPartitions(addr) local pt = require("diskpart").getPartitions(addr)
table.remove(pt, i) table.remove(pt, tonumber(i))
require("diskpart").setPartitions(addr, pt)
fdisk.show()
end
function fdisk.set(id, name, ftype, start, len)
local pt = require("diskpart").getPartitions(addr)
pt[tonumber(id)] = {name, ftype, tonumber(start), tonumber(len)}
require("diskpart").setPartitions(addr, pt) require("diskpart").setPartitions(addr, pt)
fdisk.show() fdisk.show()
end end
function fdisk.add(name, ftype, start, len) function fdisk.add(name, ftype, start, len)
local pt = require("diskpart").getPartitions(addr) fdisk.set(#require("diskpart").getPartitions(addr)+1, name, ftype, start, len)
pt[#pt+1] = {name, ftype, start, len}
require("diskpart").setPartitions(addr, pt)
fdisk.show()
end end
assert(fdisk[cmd], "unknown command") assert(fdisk[cmd], "unknown command")

View File

@ -1,3 +1,6 @@
local fs = fs or require "filesystem"
local component = require "component"
local computer = require "computer"
local cache = (package.loaded["fs.rtfs"] or {}).cache or {hitsR=0, hitsW=0, missesR=0, missesW=0} local cache = (package.loaded["fs.rtfs"] or {}).cache or {hitsR=0, hitsW=0, missesR=0, missesW=0}
local proxy = {} local proxy = {}
local rtfs = {proxy=proxy, cache=cache} local rtfs = {proxy=proxy, cache=cache}

View File

@ -1,3 +1,4 @@
local fs = fs or require "filesystem"
local common = require "fs.rtfs" local common = require "fs.rtfs"
local rtfs, proxy = {}, setmetatable({},{__index=common.proxy}) local rtfs, proxy = {}, setmetatable({},{__index=common.proxy})
local ieformat = ">I2I8I8c46" -- type (4 bits) and index (12 bits), start sector (32 bits), lenth in bytes (32 bits), name/path (46 bytes) local ieformat = ">I2I8I8c46" -- type (4 bits) and index (12 bits), start sector (32 bits), lenth in bytes (32 bits), name/path (46 bytes)
@ -373,7 +374,7 @@ function proxy:compactIndex(ti)
return ri return ri
end end
function rtfs.mount(p) function rtfs.mount(p,ro)
local d = common.getProxy(p) local d = common.getProxy(p)
local p = setmetatable({}, {__index=proxy}) local p = setmetatable({}, {__index=proxy})
p.d = d p.d = d
@ -420,7 +421,7 @@ function rtfs.mount(p)
function p.spaceTotal() function p.spaceTotal()
return p.capacity - (math.ceil(p.isize / (p.blockSize / iesize))*p.blockSize) - p.blockSize return p.capacity - (math.ceil(p.isize / (p.blockSize / iesize))*p.blockSize) - p.blockSize
end end
p.isReadOnly = p.d.isReadOnly p.isReadOnly = p.d.isReadOnly or function() return ro or false end
function p.list(name) function p.list(name)
name = fnormalize(name) name = fnormalize(name)