2 LuCI - Lua Configuration Interface
4 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
15 local fs = require "nixio.fs"
16 local util = require "nixio.util"
18 local has_extroot = fs.access("/sbin/block")
19 local has_fscheck = fs.access("/usr/sbin/e2fsck")
22 util.consume((fs.glob("/dev/sd*")), devices)
23 util.consume((fs.glob("/dev/hd*")), devices)
24 util.consume((fs.glob("/dev/scd*")), devices)
25 util.consume((fs.glob("/dev/mmc*")), devices)
28 for i, dev in ipairs(devices) do
29 local s = tonumber((fs.readfile("/sys/class/block/%s/size" % dev:sub(6))))
30 size[dev] = s and math.floor(s / 2048)
34 m = Map("fstab", translate("Mount Points - Mount Entry"))
35 m.redirect = luci.dispatcher.build_url("admin/system/fstab")
37 if not arg[1] or m.uci:get("fstab", arg[1]) ~= "mount" then
38 luci.http.redirect(m.redirect)
44 mount = m:section(NamedSection, arg[1], "mount", translate("Mount Entry"))
45 mount.anonymous = true
46 mount.addremove = false
48 mount:tab("general", translate("General Settings"))
49 mount:tab("advanced", translate("Advanced Settings"))
52 mount:taboption("general", Flag, "enabled", translate("Enable this mount")).rmempty = false
55 o = mount:taboption("general", Value, "device", translate("Device"),
56 translate("The device file of the memory or partition (<abbr title=\"for example\">e.g.</abbr> <code>/dev/sda1</code>)"))
58 for i, d in ipairs(devices) do
59 o:value(d, size[d] and "%s (%s MB)" % {d, size[d]})
62 o = mount:taboption("advanced", Value, "uuid", translate("UUID"),
63 translate("If specified, mount the device by its UUID instead of a fixed device node"))
65 o = mount:taboption("advanced", Value, "label", translate("Label"),
66 translate("If specified, mount the device by the partition label instead of a fixed device node"))
69 o = mount:taboption("general", Value, "target", translate("Mount point"),
70 translate("Specifies the directory the device is attached to"))
72 o:depends("is_rootfs", "")
75 o = mount:taboption("general", Value, "fstype", translate("Filesystem"),
76 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>)"))
79 for fs in io.lines("/proc/filesystems") do
87 o = mount:taboption("advanced", Value, "options", translate("Mount options"),
88 translate("See \"mount\" manpage for details"))
90 o.placeholder = "defaults"
94 o = mount:taboption("general", Flag, "is_rootfs", translate("Use as root filesystem"),
95 translate("Configures this mount as overlay storage for block-extroot"))
97 o:depends("fstype", "jffs")
98 o:depends("fstype", "ext2")
99 o:depends("fstype", "ext3")
100 o:depends("fstype", "ext4")
104 o = mount:taboption("general", Flag, "enabled_fsck", translate("Run filesystem check"),
105 translate("Run a filesystem check before mounting the device"))