mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-05 18:44:03 +08:00
🎁 Sync 2026-10-18 22:41:16
This commit is contained in:
1 parent
3eca35a513
commit
3159b4f938
88 files changed
+5597
-1051
No files matched your search
@@ -0,0 +1,25 @@
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const source = fs.readFileSync(path.join(__dirname, '../../luci-base/root/usr/share/rpcd/ucode/luci'), 'utf8');
|
||||
const method = source.slice(source.indexOf('\tgetMountPoints: {'), source.indexOf('\tgetRealtimeStats: {'));
|
||||
let visited = [], closed = false;
|
||||
const lines = ['/dev/root /rom squashfs ro 0 0', '/dev/ubi0_5 /overlay ubifs rw 0 0',
|
||||
'overlayfs:/overlay / overlay rw 0 0', '/dev/sda1 /mnt/USB\\040Disk vfat rw 0 0'];
|
||||
const api = new Function('open', 'split', 'replace', 'chr', 'int', 'statvfs', 'length', 'push',
|
||||
'return ({' + method + '}).getMountPoints;')(
|
||||
() => { let i = 0; return {read: () => lines[i++] || '', close: () => {closed = true;}}; },
|
||||
(s, sep) => s.split(sep), (s, re, fn) => s.replace(re, fn), String.fromCharCode, parseInt,
|
||||
mount => {visited.push(mount); return {blocks: 100, bsize: 4096, bavail: 20, bfree: 25};},
|
||||
s => s.length, (a, v) => a.push(v));
|
||||
const roots = api.call({args: {root_only: true}}).result;
|
||||
assert.deepEqual(visited, ['/overlay', '/'], 'overview must not stat unrelated filesystems');
|
||||
assert.deepEqual(roots.map(m => m.mount), visited);
|
||||
assert.equal(roots[0].size, 409600);
|
||||
assert(closed);
|
||||
visited = []; closed = false;
|
||||
const all = api.call({args: {}}).result;
|
||||
assert.deepEqual(visited, ['/rom', '/overlay', '/', '/mnt/USB Disk']);
|
||||
assert.equal(all.length, 4, 'existing callers must retain all mounts');
|
||||
assert(closed);
|
||||
console.log('Root-only storage query and backward-compatible full mount listing passed');
|
||||
Reference in new issue
Block a user