diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-10-31 16:25:49 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-11-01 12:03:33 +0100 |
commit | 5ce16764ad3212367547555dbbfe9c5f4f221118 (patch) | |
tree | 3218177ddadb8f823a12a2fbd60d392ff48346d7 /modules/luci-mod-system | |
parent | c67d2ddc2ce34bb2d985b3864706d2cf49e65b6c (diff) |
luci-base, luci-mod-system: replace luci/setUmount with fs.exec calls
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-mod-system')
-rw-r--r-- | modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js | 88 |
1 files changed, 31 insertions, 57 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js index 301ebab33..b4f5cf71a 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/mounts.js @@ -1,10 +1,10 @@ 'use strict'; +'require fs'; 'require uci'; 'require rpc'; 'require form'; -var callBlockDevices, callMountPoints, callBlockDetect, callUmount, - callFileRead, callFileStat, callFileExec; +var callBlockDevices, callMountPoints, callBlockDetect; callBlockDevices = rpc.declare({ object: 'luci', @@ -24,44 +24,6 @@ callBlockDetect = rpc.declare({ expect: { result: false } }); -callUmount = rpc.declare({ - object: 'luci', - method: 'setUmount', - params: [ 'path' ], - expect: { result: false } -}); - -callFileRead = rpc.declare({ - object: 'file', - method: 'read', - params: [ 'path' ], - expect: { data: '' }, - filter: function(s) { - return (s || '').split(/\n/).filter(function(ln) { - return ln.match(/\S/) && !ln.match(/^nodev\t/); - }).map(function(ln) { - return ln.trim(); - }); - } -}); - -callFileStat = rpc.declare({ - object: 'file', - method: 'stat', - params: [ 'path' ], - expect: { '': {} }, - filter: function(st) { - return (L.isObject(st) && st.path != null); - } -}); - -callFileExec = rpc.declare({ - object: 'file', - method: 'exec', - params: [ 'command', 'params' ], - expect: { code: 255 } -}); - function device_textvalue(devices, section_id) { var v = (uci.get('fstab', section_id, 'uuid') || '').toLowerCase(), e = Object.keys(devices).filter(function(dev) { return (devices[dev].uuid || '-').toLowerCase() == v })[0]; @@ -114,30 +76,32 @@ return L.view.extend({ }, handleMountAll: function(m, ev) { - return callFileExec('/sbin/block', ['mount']) - .then(function(rc) { - if (rc != 0) - L.ui.addNotification(null, E('p', _('The <em>block mount</em> command failed with code %d').format(rc))); + return fs.exec('/sbin/block', ['mount']) + .then(function(res) { + if (res.code != 0) + L.ui.addNotification(null, E('p', _('The <em>block mount</em> command failed with code %d').format(res.code))); }) .then(L.bind(uci.unload, uci, 'fstab')) .then(L.bind(m.render, m)); }, handleUmount: function(m, path, ev) { - return callUmount(path) + return fs.exec('/bin/umount', [path]) .then(L.bind(uci.unload, uci, 'fstab')) - .then(L.bind(m.render, m)); + .then(L.bind(m.render, m)) + .catch(function(e) { L.ui.addNotification(null, E('p', e.message)) }); }, load: function() { return Promise.all([ callBlockDevices(), - callFileRead('/proc/filesystems'), - callFileRead('/etc/filesystems'), - callFileStat('/usr/sbin/e2fsck'), - callFileStat('/usr/sbin/fsck.f2fs'), - callFileStat('/usr/sbin/dosfsck'), - callFileStat('/usr/bin/btrfsck'), + fs.lines('/proc/filesystems'), + fs.lines('/etc/filesystems'), + L.resolveDefault(fs.stat('/usr/sbin/e2fsck'), null), + L.resolveDefault(fs.stat('/usr/sbin/fsck.f2fs'), null), + L.resolveDefault(fs.stat('/usr/sbin/fsck.fat'), null), + L.resolveDefault(fs.stat('/usr/bin/btrfsck'), null), + L.resolveDefault(fs.stat('/usr/bin/ntfsfix'), null), uci.load('fstab') ]); }, @@ -149,19 +113,29 @@ return L.view.extend({ triggers = {}, trigger, m, s, o; - var filesystems = procfs.concat(etcfs.filter(function(fs) { - return procfs.indexOf(fs) < 0; - })).sort(); - var fsck = { ext2: results[3], ext3: results[3], ext4: results[3], f2fs: results[4], vfat: results[5], - btrfs: results[6] + btrfs: results[6], + ntfs: results[7] }; + var filesystems = {}; + + for (var i = 0; i < procfs.length; i++) + if (procfs[i].match(/\S/) && !procfs[i].match(/^nodev\t/)) + filesystems[procfs[i].trim()] = true; + + for (var i = 0; i < etcfs.length; i++) + if (etcfs[i].match(/\S/)) + filesystems[etcfs[i].trim()] = true; + + filesystems = Object.keys(filesystems).sort(); + + if (!uci.sections('fstab', 'global').length) uci.add('fstab', 'global'); |