[RFC] ubi: updatevol: Support volume to volume update
Ezequiel Garcia
ezequiel at vanguardiasur.com.ar
Wed Jul 16 09:19:57 PDT 2014
This commit adds the support for ubiupdatevol to recieve a UBI volume
as the second parameter. This could be useful to update a UBI volume,
from another UBI volume present in the system, for instance when
a redundant scheme is used.
Not-yet-signed-off-by: Ezequiel Garcia <ezequiel at vanguardiasur.com.ar>
---
Hello,
I'm submitting this patch, to discuss about its inclusion.
If the idea is acceptable we should fix the parameter documentation,
and maybe cleanup the implementation a bit.
One thing to consider, is that this volume to volume update feature
could be moved to the kernel (through yet another ioctl). However,
I think there's no advantage over this simpler approach.
ubi-utils/ubiupdatevol.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/ubi-utils/ubiupdatevol.c b/ubi-utils/ubiupdatevol.c
index 5096791..6b30210 100644
--- a/ubi-utils/ubiupdatevol.c
+++ b/ubi-utils/ubiupdatevol.c
@@ -212,7 +212,24 @@ static int update_volume(libubi_t libubi, struct ubi_vol_info *vol_info)
goto out_free;
}
- bytes = st.st_size - args.skip;
+ /* If the argument is a character device and a UBI volume
+ * we update from it. In this case, skip and size parameters
+ * are not used.
+ */
+ if (S_ISCHR(st.st_mode) &&
+ ubi_probe_node(libubi, args.img) == 2) {
+
+ struct ubi_vol_info src_vol_info;
+
+ err = ubi_get_vol_info(libubi, args.img, &src_vol_info);
+ if (!err)
+ bytes = src_vol_info.data_bytes;
+ else
+ bytes = 0;
+ } else {
+
+ bytes = st.st_size - args.skip;
+ }
} else
bytes = args.size;
--
2.0.1
More information about the linux-mtd
mailing list