summaryrefslogtreecommitdiffstats
path: root/lbu-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lbu-model.lua')
-rw-r--r--lbu-model.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/lbu-model.lua b/lbu-model.lua
index 204d958..873d73d 100644
--- a/lbu-model.lua
+++ b/lbu-model.lua
@@ -39,12 +39,25 @@ end
local function availablemedias()
local medias = {}
+ local found = {}
+ -- First, look in fstab
local fstab = fs.read_file("/etc/fstab") or ""
for media in string.gmatch(fstab, "/media/(%w+)%s") do
if not string.find(media, "^cdrom") and not string.find(media, "^dvd") then
medias[#medias+1] = media
+ found[media] = true
end
end
+ -- Then, look in result of 'mount'
+ local f = io.popen("mount")
+ local mount = f:read("*a")
+ f:close()
+ for media in string.gmatch(mount, "/media/(%w+)%s") do
+ if not string.find(media, "^cdrom") and not string.find(media, "^dvd") and not found[media] then
+ medias[#medias+1] = media
+ end
+ end
+ table.sort(medias)
return medias
end