Installer import into contrib (real import this time)
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / backend / lua / lib / mountpoint.lua
1 -- $Id: mountpoint.lua,v 1.1 2005/03/27 07:21:08 cpressey Exp $
2
3 MountPoints = {}
4
5 MountPoints.enumerate = function()
6         local tab = {}
7         local pty, line, found, len
8         local device, mtpt, fstype, opts, dump, pass
9         local retval
10
11         pty = Pty.open(App.expand("${root}${MOUNT} -p"))
12         if not pty then
13                 return nil, "could not open pty to mount"
14         end
15
16         line = pty:readline()
17         found = true
18         while line and found do
19                 found, len, device, mtpt, fstype, opts, dump, pass = string.find(line,
20                     "^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+(%d+)%s+(%d+)"
21                 )
22                 if found then
23                         table.insert(tab, {
24                             device = device,
25                             mountpoint = mtpt,
26                             type = fstype
27                         })
28                 end
29                 line = pty:readline()
30         end
31
32         retval = pty:close()
33         if retval ~= 0 then
34                 return nil, "mount failed with return code " .. tostring(retval)
35         end
36
37         return tab
38 end