1 -- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local fs = require "nixio.fs"
5 local util = require "nixio.util"
7 local has_extroot = fs.access("/sbin/block")
8 local has_fscheck = fs.access("/usr/sbin/e2fsck")
11 util.consume((fs.glob("/dev/sd*")), devices)
12 util.consume((fs.glob("/dev/hd*")), devices)
13 util.consume((fs.glob("/dev/scd*")), devices)
14 util.consume((fs.glob("/dev/mmc*")), devices)
17 for i, dev in ipairs(devices) do
18 local s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev:sub(6))))
19 size[dev] = s and math.floor(s / 2048)
23 m = Map("fstab", translate("Mount Points - Mount Entry"))
24 m.redirect = luci.dispatcher.build_url("admin/system/fstab")
26 if not arg[1] or m.uci:get("fstab", arg[1]) ~= "mount" then
27 luci.http.redirect(m.redirect)
33 mount = m:section(NamedSection, arg[1], "mount", translate("Mount Entry"))
34 mount.anonymous = true
35 mount.addremove = false
37 mount:tab("general", translate("General Settings"))
38 mount:tab("advanced", translate("Advanced Settings"))
41 mount:taboption("general", Flag, "enabled", translate("Enable this mount")).rmempty = false
44 o = mount:taboption("general", Value, "device", translate("Device"),
45 translate("The device file of the memory or partition (<abbr title=\"for example\">e.g.</abbr> <code>/dev/sda1</code>)"))
47 for i, d in ipairs(devices) do
48 o:value(d, size[d] and "%s (%s MB)" % {d, size[d]})
51 o = mount:taboption("advanced", Value, "uuid", translate("UUID"),
52 translate("If specified, mount the device by its UUID instead of a fixed device node"))
54 o = mount:taboption("advanced", Value, "label", translate("Label"),
55 translate("If specified, mount the device by the partition label instead of a fixed device node"))
58 o = mount:taboption("general", Value, "target", translate("Mount point"),
59 translate("Specifies the directory the device is attached to"))
61 o:depends("is_rootfs", "")
64 o = mount:taboption("general", Value, "fstype", translate("Filesystem"),
65 translate("The filesystem that was used to format the memory (<abbr title=\"for example\">e.g.</abbr> <samp><abbr title=\"Third Extended Filesystem\">ext3</abbr></samp>)"))
68 for fs in io.lines("/proc/filesystems") do
76 o = mount:taboption("advanced", Value, "options", translate("Mount options"),
77 translate("See \"mount\" manpage for details"))
79 o.placeholder = "defaults"
83 o = mount:taboption("general", Flag, "is_rootfs", translate("Use as root filesystem"),
84 translate("Configures this mount as overlay storage for block-extroot"))
86 o:depends("fstype", "jffs")
87 o:depends("fstype", "ext2")
88 o:depends("fstype", "ext3")
89 o:depends("fstype", "ext4")
93 o = mount:taboption("general", Flag, "enabled_fsck", translate("Run filesystem check"),
94 translate("Run a filesystem check before mounting the device"))