Browse Source

uvol: fixes and adapt to in-tree ucode

Don't use features which are not yet present in the version of ucode
currently shipped with OpenWrt (such as `fs.access()` or assuming raw
mode by default).
Fix syntax error in main executable.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
(cherry picked from commit 74caff0d59)
lilik-openwrt-22.03
Daniel Golle 3 years ago
parent
commit
17d2376261
4 changed files with 12 additions and 10 deletions
  1. +1
    -1
      utils/uvol/Makefile
  2. +3
    -0
      utils/uvol/files/blockdev_common.uc
  3. +5
    -2
      utils/uvol/files/lvm.uc
  4. +3
    -7
      utils/uvol/files/uvol

+ 1
- 1
utils/uvol/Makefile View File

@ -32,7 +32,7 @@ define Package/uvol
endef
define Package/uvol/description
'uvol' is tool to automate storage volume handling on embedded
'uvol' is a tool to automate storage volume handling on embedded
devices in a generic way.
Depending on what is available, 'uvol' will use either UBI or LVM2
as storage backends and transparently offer identical operations on


+ 3
- 0
utils/uvol/files/blockdev_common.uc View File

@ -108,6 +108,9 @@ let get_bootdev = function(void) {
// adapted from /lib/upgrade/common.sh
let get_partition = function(dev, num) {
if (!dev)
return null;
for (let bd in get_blockdevs()) {
let r = get_uevent_major_minor(sprintf("/sys/class/block/%s/uevent", bd));
if (r.major == dev.major && r.minor == dev.minor + num) {


+ 5
- 2
utils/uvol/files/lvm.uc View File

@ -50,6 +50,9 @@ function pvs() {
}
include("/usr/lib/uvol/blockdev_common.uc");
let rootdev = blockdev_common.get_partition(blockdev_common.get_bootdev(), 0);
if (!rootdev)
return null;
let tmp = lvm("pvs", "-o", "vg_name", "-S", sprintf("\"pv_name=~^/dev/%s.*\$\"", rootdev));
if (tmp.report.pv)
return tmp.report.pv[0].vg_name;
@ -112,8 +115,8 @@ function getdev(lv) {
function lvm_init(ctx) {
cursor = ctx.cursor;
fs = ctx.fs;
if (!fs.access(lvm_exec, "x"))
return false;
// if (!fs.access(lvm_exec, "x"))
// return false;
vg_name = pvs();
if (!vg_name)


+ 3
- 7
utils/uvol/files/uvol View File

@ -1,4 +1,4 @@
#!/usr/bin/ucode
#!/usr/bin/ucode -R
// SPDX-License-Identifier: GPL-2.0-or-later
// uvol - storage volume manager for OpenWrt
// (c) 2022 Daniel Golle <daniel@makrotopia.org>
@ -25,11 +25,7 @@ commands:
1 - volume is not ready for use
2 - volume doesn'y exist
write volname size write to volume from stdin, size in bytes
"
function help() {
printf("%s", help_output);
);
";
let fs = require("fs");
let uci = require("uci");
@ -71,7 +67,7 @@ if (!backend) {
let cmd = shift(ARGV);
if (!cmd || cmd == "-h" || cmd == "help") {
help();
printf("%s", help_output);
return cmd?0:22;
}


Loading…
Cancel
Save