Compare commits

..

No commits in common. "2f8abe0a0ba492d11cc26d9343ae4df209d42d8a" and "fc6f168bbd81e4eff2de65497be371368f9521b9" have entirely different histories.

2 changed files with 11 additions and 11 deletions

View File

@ -1,11 +1,11 @@
local component = require "component"
local tA = {...}
local slicer = {}
local fdisk = {}
local addr = component.get(table.remove(tA, 1))
assert(addr, "drive not found")
local cmd = table.remove(tA, 1) or "show"
function slicer.show()
function fdisk.show()
local ts = component.invoke(addr, component.type(addr) == "tape_drive" and "getSize" or "getCapacity")
local cs = ts / 512
print(string.format("Drive %s - %iKiB, %0.0f sectors:", addr:sub(1,8), ts//1024,cs))
@ -14,21 +14,21 @@ function slicer.show()
print(string.format("%2i: %-20s %4s %5i %5i %5i",k,v[1],v[2],v[3],v[4],(v[3] + v[4])-1))
end
end
function slicer.del(i)
function fdisk.del(i)
local pt = require("diskpart").getPartitions(addr)
table.remove(pt, tonumber(i))
require("diskpart").setPartitions(addr, pt)
slicer.show()
fdisk.show()
end
function slicer.set(id, name, ftype, start, len)
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)
slicer.show()
fdisk.show()
end
function slicer.add(name, ftype, start, len)
slicer.set(#require("diskpart").getPartitions(addr)+1, name, ftype, start, len)
function fdisk.add(name, ftype, start, len)
fdisk.set(#require("diskpart").getPartitions(addr)+1, name, ftype, start, len)
end
assert(slicer[cmd], "unknown command")
slicer[cmd](table.unpack(tA))
assert(fdisk[cmd], "unknown command")
fdisk[cmd](table.unpack(tA))

View File

@ -1,4 +1,4 @@
{["name"]="slicer",
{["name"]="fdisk",
["description"]="Partition management utility",
["authors"]="Izaya",
["dependencies"]={"diskpart"}}