This repository was archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiskfire.lua
More file actions
71 lines (64 loc) · 1.37 KB
/
diskfire.lua
File metadata and controls
71 lines (64 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!lua
local function df_probe (opt, disk)
local str, errno
str, errno = df.cmd("probe", "--" .. opt, disk)
if (errno ~= 0) then
return ""
end
return string.sub(str, 0, -2)
end
local function df_name_disk (disk, num)
if (df_probe("rm", disk) == "REMOVABLE") then
return "RM" .. num
end
return "DISK" .. num
end
local function df_get_label (label)
if (label == nil or label == "") then
return ""
end
return "[" .. label .. "]"
end
local function df_get_fs (fs)
if (fs) then
return string.upper(fs)
end
return "UNKNOWN"
end
local function df_get_flag (disk, partmap)
local flag = df_probe("flag", disk)
if (partmap == "msdos") then
if (string.find(flag, "ACTIVE")) then
return "激活"
end
else
local attr = string.match(flag, "^[%x%-]+ ([%a%s]+)$", 1)
if (attr) then
return attr
end
end
return ""
end
local function df_enum_iter (disk, fs, uuid, label, size)
local num
if (disk == "proc") then
return 0
end
num = string.match(disk, "^%ld(%d+)$", 1)
if (num) then
print(string.format("%-6s %-10s %s %s",
df_name_disk(disk, num),
size,
df_probe("bus", disk),
df_probe("pid", disk)))
else
partmap, num = string.match(disk, "^%ld%d+,(%a+)(%d+)$", 1)
print(string.format("|- PART%d %-10s %-10s %s %s",
num,
size,
df_get_fs(fs),
df_get_flag(disk, partmap),
df_get_label(label)))
end
end
df.enum_device(df_enum_iter)