rename fdisk to slicer, part two

This commit is contained in:
Izaya 2023-10-07 08:50:58 +10:00
parent de1ec005e6
commit 2f8abe0a0b
2 changed files with 11 additions and 11 deletions

View File

@ -1,11 +1,11 @@
local component = require "component"
local tA = {...}
local fdisk = {}
local slicer = {}
local addr = component.get(table.remove(tA, 1))
assert(addr, "drive not found")
local cmd = table.remove(tA, 1) or "show"
function fdisk.show()
function slicer.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 fdisk.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 fdisk.del(i)
function slicer.del(i)
local pt = require("diskpart").getPartitions(addr)
table.remove(pt, tonumber(i))
require("diskpart").setPartitions(addr, pt)
fdisk.show()
slicer.show()
end
function fdisk.set(id, name, ftype, start, len)
function slicer.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)
fdisk.show()
slicer.show()
end
function fdisk.add(name, ftype, start, len)
fdisk.set(#require("diskpart").getPartitions(addr)+1, name, ftype, start, len)
function slicer.add(name, ftype, start, len)
slicer.set(#require("diskpart").getPartitions(addr)+1, name, ftype, start, len)
end
assert(fdisk[cmd], "unknown command")
fdisk[cmd](table.unpack(tA))
assert(slicer[cmd], "unknown command")
slicer[cmd](table.unpack(tA))

View File

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