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>
This commit is contained in:
parent
8988b0a32f
commit
74caff0d59
4 changed files with 12 additions and 10 deletions
|
@ -32,7 +32,7 @@ define Package/uvol
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/uvol/description
|
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.
|
devices in a generic way.
|
||||||
Depending on what is available, 'uvol' will use either UBI or LVM2
|
Depending on what is available, 'uvol' will use either UBI or LVM2
|
||||||
as storage backends and transparently offer identical operations on
|
as storage backends and transparently offer identical operations on
|
||||||
|
|
|
@ -108,6 +108,9 @@ let get_bootdev = function(void) {
|
||||||
|
|
||||||
// adapted from /lib/upgrade/common.sh
|
// adapted from /lib/upgrade/common.sh
|
||||||
let get_partition = function(dev, num) {
|
let get_partition = function(dev, num) {
|
||||||
|
if (!dev)
|
||||||
|
return null;
|
||||||
|
|
||||||
for (let bd in get_blockdevs()) {
|
for (let bd in get_blockdevs()) {
|
||||||
let r = get_uevent_major_minor(sprintf("/sys/class/block/%s/uevent", bd));
|
let r = get_uevent_major_minor(sprintf("/sys/class/block/%s/uevent", bd));
|
||||||
if (r.major == dev.major && r.minor == dev.minor + num) {
|
if (r.major == dev.major && r.minor == dev.minor + num) {
|
||||||
|
|
|
@ -50,6 +50,9 @@ function pvs() {
|
||||||
}
|
}
|
||||||
include("/usr/lib/uvol/blockdev_common.uc");
|
include("/usr/lib/uvol/blockdev_common.uc");
|
||||||
let rootdev = blockdev_common.get_partition(blockdev_common.get_bootdev(), 0);
|
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));
|
let tmp = lvm("pvs", "-o", "vg_name", "-S", sprintf("\"pv_name=~^/dev/%s.*\$\"", rootdev));
|
||||||
if (tmp.report.pv)
|
if (tmp.report.pv)
|
||||||
return tmp.report.pv[0].vg_name;
|
return tmp.report.pv[0].vg_name;
|
||||||
|
@ -112,8 +115,8 @@ function getdev(lv) {
|
||||||
function lvm_init(ctx) {
|
function lvm_init(ctx) {
|
||||||
cursor = ctx.cursor;
|
cursor = ctx.cursor;
|
||||||
fs = ctx.fs;
|
fs = ctx.fs;
|
||||||
if (!fs.access(lvm_exec, "x"))
|
// if (!fs.access(lvm_exec, "x"))
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
vg_name = pvs();
|
vg_name = pvs();
|
||||||
if (!vg_name)
|
if (!vg_name)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/ucode
|
#!/usr/bin/ucode -R
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
// uvol - storage volume manager for OpenWrt
|
// uvol - storage volume manager for OpenWrt
|
||||||
// (c) 2022 Daniel Golle <daniel@makrotopia.org>
|
// (c) 2022 Daniel Golle <daniel@makrotopia.org>
|
||||||
|
@ -25,11 +25,7 @@ commands:
|
||||||
1 - volume is not ready for use
|
1 - volume is not ready for use
|
||||||
2 - volume doesn'y exist
|
2 - volume doesn'y exist
|
||||||
write volname size write to volume from stdin, size in bytes
|
write volname size write to volume from stdin, size in bytes
|
||||||
"
|
";
|
||||||
|
|
||||||
function help() {
|
|
||||||
printf("%s", help_output);
|
|
||||||
);
|
|
||||||
|
|
||||||
let fs = require("fs");
|
let fs = require("fs");
|
||||||
let uci = require("uci");
|
let uci = require("uci");
|
||||||
|
@ -71,7 +67,7 @@ if (!backend) {
|
||||||
let cmd = shift(ARGV);
|
let cmd = shift(ARGV);
|
||||||
|
|
||||||
if (!cmd || cmd == "-h" || cmd == "help") {
|
if (!cmd || cmd == "-h" || cmd == "help") {
|
||||||
help();
|
printf("%s", help_output);
|
||||||
return cmd?0:22;
|
return cmd?0:22;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue