luci-mod-system: flash.js: fix "rootfs_data" partition detection
authorJo-Philipp Wich <jo@mein.io>
Wed, 2 Oct 2019 10:59:23 +0000 (12:59 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 2 Oct 2019 11:02:04 +0000 (13:02 +0200)
The `/sys/devices/virtual/mtd/` information is not available on all
devices so rely on the contents of `/proc/mtd` instead to check for
the existence of the `rootfs_data` partition.

Fixes: #3136
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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 182f2498843cf914f9f9eca60a71b63ddc7a24e0..54caa743634543eca7099d325e1e08f991f9ae24 100644 (file)
@@ -34,7 +34,6 @@
                                "/proc/mtd": [ "read" ],
                                "/proc/partitions": [ "read" ],
                                "/proc/sys/kernel/hostname": [ "read" ],
-                               "/sys/devices/virtual/mtd/*/name": [ "read" ],
                                "/sys/devices/virtual/ubi/*/name": [ "read" ]
                        },
                        "ubus": {
index 6f245533dabc209d8679097e319d7f1979db1aaf..2309c82682e521db40d107b55fab0a291faf21d9 100644 (file)
@@ -215,7 +215,7 @@ var mapdata = { actions: {}, config: {} };
 
 return L.view.extend({
        load: function() {
-               var max_mtd = 10, max_ubi = 2, max_ubi_vol = 4;
+               var max_ubi = 2, max_ubi_vol = 4;
                var tasks = [
                        callFileStat('/lib/upgrade/platform.sh'),
                        callFileRead('/proc/sys/kernel/hostname'),
@@ -223,9 +223,6 @@ return L.view.extend({
                        callFileRead('/proc/partitions')
                ];
 
-               for (var i = 0; i < max_mtd; i++)
-                       tasks.push(callFileRead('/sys/devices/virtual/mtd/mtd%d/name'.format(i)));
-
                for (var i = 0; i < max_ubi; i++)
                        for (var j = 0; j < max_ubi_vol; j++)
                                tasks.push(callFileRead('/sys/devices/virtual/ubi/ubi%d/ubi%d_%d/name'.format(i, i, j)));
@@ -497,7 +494,7 @@ return L.view.extend({
                    hostname = rpc_replies[1],
                    procmtd = rpc_replies[2],
                    procpart = rpc_replies[3],
-                   has_rootfs_data = rpc_replies.slice(4).filter(function(n) { return n == 'rootfs_data' })[0],
+                   has_rootfs_data = (procmtd.match(/"rootfs_data"/) != null) || rpc_replies.slice(4).filter(function(n) { return n == 'rootfs_data' })[0],
                    storage_size = findStorageSize(procmtd, procpart),
                    m, s, o, ss;