luci-mod-system: refine flash reset 3145/head
authorChen Minqiang <ptpt52@gmail.com>
Wed, 25 Sep 2019 01:02:59 +0000 (09:02 +0800)
committerChen Minqiang <ptpt52@gmail.com>
Mon, 7 Oct 2019 15:37:35 +0000 (23:37 +0800)
We determine flash reset capability by checking overlayfs in /proc/mounts

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json
modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js

index 001e6deec8c61cf783c4c12252cca89757686cc5..bd260863d7505a3520a4678642a5243501861cb9 100644 (file)
@@ -34,7 +34,7 @@
                                "/proc/mtd": [ "read" ],
                                "/proc/partitions": [ "read" ],
                                "/proc/sys/kernel/hostname": [ "read" ],
-                               "/sys/devices/virtual/ubi/*/name": [ "read" ]
+                               "/proc/mounts": [ "read" ]
                        },
                        "ubus": {
                                "file": [ "list", "read", "stat" ],
index 915c3c7fa052d603abec3766dc3830d1a7e10d3b..6cbd3c13b5da9f143c8e2765621c325cfb67dee3 100644 (file)
@@ -143,18 +143,14 @@ var mapdata = { actions: {}, config: {} };
 
 return L.view.extend({
        load: function() {
-               var max_ubi = 2, max_ubi_vol = 4;
                var tasks = [
                        L.resolveDefault(fs.stat('/lib/upgrade/platform.sh'), {}),
                        fs.trimmed('/proc/sys/kernel/hostname'),
                        fs.trimmed('/proc/mtd'),
-                       fs.trimmed('/proc/partitions')
+                       fs.trimmed('/proc/partitions'),
+                       fs.trimmed('/proc/mounts')
                ];
 
-               for (var i = 0; i < max_ubi; i++)
-                       for (var j = 0; j < max_ubi_vol; j++)
-                               tasks.push(fs.trimmed('/sys/devices/virtual/ubi/ubi%d/ubi%d_%d/name'.format(i, i, j)));
-
                return Promise.all(tasks);
        },
 
@@ -428,7 +424,8 @@ return L.view.extend({
                    hostname = rpc_replies[1],
                    procmtd = rpc_replies[2],
                    procpart = rpc_replies[3],
-                   has_rootfs_data = (procmtd.match(/"rootfs_data"/) != null) || rpc_replies.slice(4).filter(function(n) { return n == 'rootfs_data' })[0],
+                   procmounts = rpc_replies[4],
+                   has_rootfs_data = (procmtd.match(/"rootfs_data"/) != null) || (procmounts.match("overlayfs:\/overlay \/ ") != null),
                    storage_size = findStorageSize(procmtd, procpart),
                    m, s, o, ss;