Compare commits
10 Commits
94a6f27684
...
b5f94355a0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5f94355a0 | ||
|
|
024cfeac1b | ||
|
|
17b7b13984 | ||
|
|
97a96ca433 | ||
|
|
24a8777feb | ||
|
|
4ad2a861d9 | ||
|
|
f71c2863d1 | ||
|
|
1882e28d76 | ||
|
|
1bddd11e72 | ||
|
|
37ea01fa3e |
@ -3,11 +3,7 @@
|
||||
|
||||
STOP=90
|
||||
|
||||
restart() {
|
||||
:
|
||||
}
|
||||
|
||||
stop() {
|
||||
shutdown() {
|
||||
if [ ! -f /rom/rom/note ]; then
|
||||
sync /overlay
|
||||
umount /overlay
|
||||
@ -15,6 +11,11 @@ stop() {
|
||||
umount /ext_overlay
|
||||
else
|
||||
# pivot
|
||||
mount --make-private / 2>&-
|
||||
mount --make-private /tmp 2>&-
|
||||
mount --make-private /mnt 2>&-
|
||||
mount --make-private /overlay 2>&-
|
||||
mount --make-private /ext_overlay 2>&-
|
||||
mount --move /dev /rom/dev
|
||||
mount --move /tmp /rom/tmp
|
||||
mount --move /sys /rom/sys
|
||||
@ -22,6 +23,7 @@ stop() {
|
||||
mount --move /overlay /rom/overlay
|
||||
mount --move /proc /rom/proc
|
||||
if pivot_root /rom /rom/mnt; then
|
||||
echo "<1>umount: pivot_root success" >/dev/kmsg
|
||||
sync
|
||||
/usr/bin/umount -R -d /mnt
|
||||
sync /mnt
|
||||
@ -31,8 +33,13 @@ stop() {
|
||||
sync /ext_overlay
|
||||
umount /ext_overlay
|
||||
else
|
||||
echo "<1>umount: pivot_root failed!" >/rom/dev/kmsg
|
||||
mount --move /rom/proc /proc
|
||||
mount --move /rom/dev /dev
|
||||
mount --move /rom/tmp /tmp
|
||||
mount --move /rom/sys /sys
|
||||
mount --move /rom/ext_overlay /ext_overlay
|
||||
mount --move /rom/overlay /overlay
|
||||
sync
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -144,9 +144,9 @@ clean_overlayfs_redundant_whiteout_marker()
|
||||
{
|
||||
local line
|
||||
cd "$1"
|
||||
find upper ! -path 'upper/opt/*' -type c -perm 0 -user 0 -group 0 | sed 's#^upper/#/#g' | while read; do
|
||||
find upper -xdev -path 'upper/opt' -prune ! -type d -o -type c -perm 0 -user 0 -group 0 | sed 's#^upper/#/#g' | while read; do
|
||||
line="$REPLY"
|
||||
[ ! -e "$line" -a \( -z "$2" -o ! -f "$2/upper$line" \) ] && \
|
||||
[ ! -e "$line" -a \( -z "$2" -o ! -e "$2/upper$line" \) ] && \
|
||||
busybox ls -l "upper$line" | grep -Fq 'c--------- 1 root root 0, 0 ' && \
|
||||
rm -f "upper$line"
|
||||
done
|
||||
@ -158,9 +158,9 @@ clean_overlayfs_redundant_whiteout_marker_luci()
|
||||
local line
|
||||
[ -d "$1/upper/usr/lib/lua/luci" ] || return 0
|
||||
cd "$1/upper/usr/lib/lua"
|
||||
find luci -type c -perm 0 -user 0 -group 0 | while read; do
|
||||
find luci -xdev -type c -perm 0 -user 0 -group 0 | while read; do
|
||||
line="$REPLY"
|
||||
[ ! -e "/usr/lib/lua/$line" -a \( -z "$2" -o ! -f "$2/upper/usr/lib/lua/$line" \) ] && \
|
||||
[ ! -e "/usr/lib/lua/$line" -a \( -z "$2" -o ! -e "$2/upper/usr/lib/lua/$line" \) ] && \
|
||||
busybox ls -l "$line" | grep -Fq 'c--------- 1 root root 0, 0 ' && \
|
||||
rm -f "$line"
|
||||
done
|
||||
@ -198,7 +198,6 @@ prepare_primary_overlay()
|
||||
else
|
||||
if [ -d /overlay/upper ] ; then
|
||||
if update_overlay_lower_uuid /overlay || [ -f /overlay/.upgrading ] ; then
|
||||
rm -f /overlay/upper/etc/opkg/distfeeds.conf
|
||||
is_overlayfs_use_xattr && clean_overlayfs_origin /overlay/upper
|
||||
clean_overlayfs_redundant_whiteout_marker /overlay
|
||||
else
|
||||
@ -272,7 +271,6 @@ prepare_ext_overlay()
|
||||
fi
|
||||
# should change to $newoverlaydir/.upgrading
|
||||
if [ -f "$newoverlaydir/upper/usr/lib/opkg/.upgrading" ]; then
|
||||
rm -f "$newoverlaydir/upper/etc/opkg/distfeeds.conf"
|
||||
is_overlayfs_use_xattr && clean_overlayfs_origin "$newoverlaydir/upper"
|
||||
fi
|
||||
if [ -f "$newoverlaydir/.commit" ]; then
|
||||
@ -342,6 +340,8 @@ prepare_mnt()
|
||||
rm -f "/overlay/.sandbox"
|
||||
fi
|
||||
|
||||
sync
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI for OTA upgrade
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.3.1
|
||||
PKG_VERSION:=1.4.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>
|
||||
|
||||
|
||||
@ -182,10 +182,13 @@
|
||||
state_switch("downloading", "downloaded");
|
||||
break;
|
||||
case 1:
|
||||
if (d.msg.startsWith('#')) {
|
||||
if (d.msg.startsWith('#') || d.msg.startsWith(' ') || d.msg.startsWith('-')) {
|
||||
if (!refresh_download_progress_paused)
|
||||
cancel.disabled = undefined;
|
||||
download_progress.innerText = "<%:Downloading%>: "+d.msg.replaceAll(/[# ]/g, '');
|
||||
if (d.msg.endsWith('%'))
|
||||
download_progress.innerText = "<%:Downloading%>: "+d.msg.replaceAll(/[# ]/g, '');
|
||||
else
|
||||
download_progress.innerText = "<%:Downloading%>";
|
||||
} else {
|
||||
if (!refresh_download_progress_paused)
|
||||
cancel.disabled = 'disabled';
|
||||
|
||||
@ -1,5 +1,20 @@
|
||||
#!/bin/sh
|
||||
# author jjm2473
|
||||
|
||||
mirrors() {
|
||||
local url="$1"
|
||||
case "$url" in
|
||||
https://fw0.koolcenter.com/iStoreOS/*|\
|
||||
https://fw.koolcenter.com/iStoreOS/*)
|
||||
local path=$(echo "$url" | sed -E 's#^https?://[^/]+/(.*)#\1#')
|
||||
# echo "https://dl2.istoreos.com/$path"
|
||||
echo "https://dl.istoreos.com/$path"
|
||||
;;
|
||||
esac
|
||||
echo "$url"
|
||||
return 0
|
||||
}
|
||||
|
||||
if [ -f /lib/upgrade/ota.sh ]; then
|
||||
. /lib/upgrade/ota.sh
|
||||
export_ota_url
|
||||
@ -11,6 +26,7 @@ if [ -z "$OTA_URL_BASE" ]; then
|
||||
fi
|
||||
|
||||
WRLOCK=/var/lock/ota_background.lock
|
||||
STLOCK=/var/lock/ota_status.lock
|
||||
|
||||
action=${1}
|
||||
shift
|
||||
@ -19,42 +35,66 @@ sha256() {
|
||||
sha256sum $1 | cut -d' ' -f1
|
||||
}
|
||||
|
||||
fcurl() {
|
||||
curl -L --fail --show-error "$@"
|
||||
}
|
||||
alias fcurl='curl -L --fail --show-error'
|
||||
|
||||
download() {
|
||||
local img=$1
|
||||
local sum=$2
|
||||
exec 300>$STLOCK
|
||||
flock 300
|
||||
touch /tmp/firmware.img.part
|
||||
echo >/tmp/firmware.img.progress
|
||||
rm -f /tmp/firmware.img.sha256sum
|
||||
flock -u 300
|
||||
if [ -f /tmp/firmware.img ]; then
|
||||
echo "Checking existed firmware.img..." >> /tmp/firmware.img.progress
|
||||
if [ "`sha256 /tmp/firmware.img`" = "$sum" ]; then
|
||||
flock 300
|
||||
echo $sum > /tmp/firmware.img.sha256sum;
|
||||
rm -f /tmp/firmware.img.part
|
||||
rm -f /tmp/firmware.img.progress
|
||||
flock -u 300
|
||||
return 0;
|
||||
else
|
||||
echo "Check failed, redownload" >> /tmp/firmware.img.progress
|
||||
rm -f /tmp/firmware.img
|
||||
fi
|
||||
fi
|
||||
fcurl --connect-timeout 5 --progress-bar -o /tmp/firmware.img.part "$OTA_URL_BASE/$img" 2>/tmp/firmware.img.progress &
|
||||
local pid="$!"
|
||||
echo "$pid" > /var/run/ota/download.pid
|
||||
if wait $pid; then
|
||||
rm -f /var/run/ota/download.pid
|
||||
echo "Checking new firmware.img.part..." > /tmp/firmware.img.progress
|
||||
if [ "`sha256 /tmp/firmware.img.part`" = "$sum" ]; then
|
||||
mv /tmp/firmware.img.part /tmp/firmware.img && echo $sum > /tmp/firmware.img.sha256sum
|
||||
rm -f /tmp/firmware.img.progress
|
||||
return 0
|
||||
local pid url
|
||||
mirrors "$OTA_URL_BASE/$img" | while read; do
|
||||
url="$REPLY"
|
||||
echo "Try $url" >>/tmp/firmware.img.progress
|
||||
flock 300
|
||||
echo "#=#=#" >>/tmp/firmware.img.progress
|
||||
fcurl --connect-timeout 5 --progress-bar -o /tmp/firmware.img.part "$url" 2>>/tmp/firmware.img.progress &
|
||||
pid="$!"
|
||||
echo "$pid" > /var/run/ota/download.pid
|
||||
flock -u 300
|
||||
if wait $pid; then
|
||||
rm -f /var/run/ota/download.pid
|
||||
echo "Checking new firmware.img.part..." > /tmp/firmware.img.progress
|
||||
if [ "`sha256 /tmp/firmware.img.part`" = "$sum" ]; then
|
||||
flock 300
|
||||
mv /tmp/firmware.img.part /tmp/firmware.img && echo $sum > /tmp/firmware.img.sha256sum
|
||||
rm -f /tmp/firmware.img.progress
|
||||
flock -u 300
|
||||
return 0
|
||||
else
|
||||
echo "Checksum failed!" >>/tmp/firmware.img.progress
|
||||
fi
|
||||
else
|
||||
echo "Checksum failed!" >>/tmp/firmware.img.progress
|
||||
# on Terminated $? == 143, on Timeout $? == 28
|
||||
local ecode=$?
|
||||
echo >>/tmp/firmware.img.progress
|
||||
if [ $ecode -eq 143 ]; then
|
||||
echo "Canceled!" >> /tmp/firmware.img.progress
|
||||
break
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
flock 300
|
||||
sed -i '/\r/d' /tmp/firmware.img.progress
|
||||
flock -u 300
|
||||
done
|
||||
rm -f /var/run/ota/download.pid
|
||||
rm -f /tmp/firmware.img.part
|
||||
return 1
|
||||
@ -139,10 +179,20 @@ do_progress() {
|
||||
[ -f /tmp/firmware.img.progress ] || { echo "download not in progress" >&2 ; return 254; }
|
||||
[ -f /tmp/firmware.img.part ] && { cat /tmp/firmware.img.progress | tr '\r' '\n' | tail -n1; return 1; }
|
||||
tail -1 /tmp/firmware.img.progress | grep -Fq 'Canceled!' && { echo "Canceled"; return 2; }
|
||||
grep -v '\r' /tmp/firmware.img.progress >&2
|
||||
cat /tmp/firmware.img.progress | tr '\r' '\n' | grep -v '^$' | tail -n1 >&2
|
||||
return 3
|
||||
}
|
||||
|
||||
do_progress_locked() {
|
||||
local ret
|
||||
exec 300>$STLOCK
|
||||
flock -s 300
|
||||
do_progress
|
||||
ret=$?
|
||||
flock -u 300
|
||||
return $ret
|
||||
}
|
||||
|
||||
do_cancel() {
|
||||
if [ -f /var/run/ota/download.pid ]; then
|
||||
local pid=`cat /var/run/ota/download.pid`
|
||||
@ -153,8 +203,6 @@ do_cancel() {
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo "" >> /tmp/firmware.img.progress
|
||||
echo "Canceled!" >> /tmp/firmware.img.progress
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
@ -183,7 +231,7 @@ case $action in
|
||||
do_download
|
||||
;;
|
||||
"progress")
|
||||
do_progress
|
||||
do_progress_locked
|
||||
;;
|
||||
"cancel")
|
||||
do_cancel
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=rpcd
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/rpcd.git
|
||||
|
||||
@ -0,0 +1,119 @@
|
||||
From 9047361575e7219f46665637180ce4a9012006ab Mon Sep 17 00:00:00 2001
|
||||
From: Liangbin Lian <jjm2473@gmail.com>
|
||||
Date: Fri, 14 Jun 2024 14:19:24 +0800
|
||||
Subject: [PATCH] uci: recovery from a failed uci commit
|
||||
|
||||
---
|
||||
uci.c | 50 +++++++++++++++++++++++++++++++++++++-------------
|
||||
1 file changed, 37 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/uci.c b/uci.c
|
||||
index 3cd2b82..d4ea103 100644
|
||||
--- a/uci.c
|
||||
+++ b/uci.c
|
||||
@@ -1320,11 +1320,13 @@ rpc_uci_trigger_event(struct ubus_context *ctx, const char *config)
|
||||
free(pkg);
|
||||
}
|
||||
|
||||
+static int
|
||||
+rpc_uci_apply_config(struct ubus_context *ctx, const char *config);
|
||||
+
|
||||
static int
|
||||
rpc_uci_revert_commit(struct ubus_context *ctx, struct blob_attr *msg, bool commit)
|
||||
{
|
||||
struct blob_attr *tb[__RPC_C_MAX];
|
||||
- struct uci_package *p = NULL;
|
||||
struct uci_ptr ptr = { 0 };
|
||||
|
||||
if (apply_sid[0])
|
||||
@@ -1343,12 +1345,7 @@ rpc_uci_revert_commit(struct ubus_context *ctx, struct blob_attr *msg, bool comm
|
||||
|
||||
if (commit)
|
||||
{
|
||||
- if (!uci_load(cursor, ptr.package, &p))
|
||||
- {
|
||||
- uci_commit(cursor, &p, false);
|
||||
- uci_unload(cursor, p);
|
||||
- rpc_uci_trigger_event(ctx, blobmsg_get_string(tb[RPC_C_CONFIG]));
|
||||
- }
|
||||
+ rpc_uci_apply_config(ctx, ptr.package);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1441,17 +1438,19 @@ rpc_uci_purge_dir(const char *path)
|
||||
}
|
||||
|
||||
static int
|
||||
-rpc_uci_apply_config(struct ubus_context *ctx, char *config)
|
||||
+rpc_uci_apply_config(struct ubus_context *ctx, const char *config)
|
||||
{
|
||||
struct uci_package *p = NULL;
|
||||
+ int ret = 0;
|
||||
|
||||
if (!uci_load(cursor, config, &p)) {
|
||||
- uci_commit(cursor, &p, false);
|
||||
+ ret = uci_commit(cursor, &p, false);
|
||||
uci_unload(cursor, p);
|
||||
}
|
||||
- rpc_uci_trigger_event(ctx, config);
|
||||
+ if (!ret)
|
||||
+ rpc_uci_trigger_event(ctx, config);
|
||||
|
||||
- return 0;
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1531,7 +1530,7 @@ rpc_uci_do_rollback(struct ubus_context *ctx, glob_t *gl)
|
||||
continue;
|
||||
|
||||
rpc_uci_copy_file(RPC_SNAPSHOT_FILES, RPC_UCI_DIR, config);
|
||||
- rpc_uci_apply_config(ctx, config);
|
||||
+ rpc_uci_trigger_event(ctx, config);
|
||||
|
||||
if (deny)
|
||||
continue;
|
||||
@@ -1547,6 +1546,25 @@ rpc_uci_do_rollback(struct ubus_context *ctx, glob_t *gl)
|
||||
apply_ctx = NULL;
|
||||
}
|
||||
|
||||
+static void
|
||||
+rpc_uci_do_rollback_im(struct ubus_context *ctx, glob_t *gl, int end) {
|
||||
+ int i;
|
||||
+ char tmp[PATH_MAX];
|
||||
+ for (i = end; i >= 0; i--) {
|
||||
+ char *config = basename(gl->gl_pathv[i]);
|
||||
+
|
||||
+ if (*config == '.')
|
||||
+ continue;
|
||||
+
|
||||
+ rpc_uci_copy_file(RPC_SNAPSHOT_FILES, RPC_UCI_DIR, config);
|
||||
+ rpc_uci_trigger_event(ctx, config);
|
||||
+
|
||||
+ rpc_uci_copy_file(RPC_SNAPSHOT_DELTA, tmp, config);
|
||||
+ }
|
||||
+ rpc_uci_purge_dir(RPC_SNAPSHOT_FILES);
|
||||
+ rpc_uci_purge_dir(RPC_SNAPSHOT_DELTA);
|
||||
+}
|
||||
+
|
||||
static void
|
||||
rpc_uci_apply_timeout(struct uloop_timeout *t)
|
||||
{
|
||||
@@ -1629,7 +1647,13 @@ rpc_uci_apply(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
|
||||
rpc_uci_copy_file(RPC_UCI_DIR, RPC_SNAPSHOT_FILES, config);
|
||||
rpc_uci_copy_file(tmp, RPC_SNAPSHOT_DELTA, config);
|
||||
- rpc_uci_apply_config(ctx, config);
|
||||
+ ret = rpc_uci_apply_config(ctx, config);
|
||||
+ if (ret) {
|
||||
+ rpc_uci_do_rollback_im(ctx, &gl, i - 1);
|
||||
+ apply_sid[0] = 0;
|
||||
+ globfree(&gl);
|
||||
+ return UBUS_STATUS_UNKNOWN_ERROR;
|
||||
+ }
|
||||
}
|
||||
|
||||
globfree(&gl);
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=uci
|
||||
PKG_RELEASE:=5
|
||||
PKG_RELEASE:=6
|
||||
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/uci.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
From 237d5542986ddb00733e172e638339544058d2d8 Mon Sep 17 00:00:00 2001
|
||||
From: Liangbin Lian <jjm2473@gmail.com>
|
||||
Date: Thu, 6 Jun 2024 15:42:11 +0800
|
||||
Subject: [PATCH] file: don't save broken uci config
|
||||
|
||||
Signed-off-by: Liangbin Lian <jjm2473@gmail.com>
|
||||
---
|
||||
file.c | 32 +++++++++++++++++++++++---------
|
||||
1 file changed, 23 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/file.c b/file.c
|
||||
index 93abfae..5c942b8 100644
|
||||
--- a/file.c
|
||||
+++ b/file.c
|
||||
@@ -607,7 +607,7 @@ static const char *uci_escape(struct uci_context *ctx, const char *str)
|
||||
/*
|
||||
* export a single config package to a file stream
|
||||
*/
|
||||
-static void uci_export_package(struct uci_package *p, FILE *stream, bool header)
|
||||
+static int uci_export_package(struct uci_package *p, FILE *stream, bool header)
|
||||
{
|
||||
struct uci_context *ctx = p->ctx;
|
||||
struct uci_element *s, *o, *i;
|
||||
@@ -639,7 +639,8 @@ static void uci_export_package(struct uci_package *p, FILE *stream, bool header)
|
||||
}
|
||||
}
|
||||
}
|
||||
- fprintf(stream, "\n");
|
||||
+ /* return last fprintf to check 'No space left on device' error */
|
||||
+ return fprintf(stream, "\n");
|
||||
}
|
||||
|
||||
int uci_export(struct uci_context *ctx, FILE *stream, struct uci_package *package, bool header)
|
||||
@@ -649,11 +650,15 @@ int uci_export(struct uci_context *ctx, FILE *stream, struct uci_package *packag
|
||||
UCI_HANDLE_ERR(ctx);
|
||||
UCI_ASSERT(ctx, stream != NULL);
|
||||
|
||||
- if (package)
|
||||
- uci_export_package(package, stream, header);
|
||||
- else {
|
||||
+ if (package) {
|
||||
+ if (uci_export_package(package, stream, header) < 0) {
|
||||
+ return UCI_ERR_IO;
|
||||
+ }
|
||||
+ } else {
|
||||
uci_foreach_element(&ctx->root, e) {
|
||||
- uci_export_package(uci_to_package(e), stream, header);
|
||||
+ if (uci_export_package(uci_to_package(e), stream, header) < 0) {
|
||||
+ return UCI_ERR_IO;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,6 +744,7 @@ static void uci_file_commit(struct uci_context *ctx, struct uci_package **packag
|
||||
char *filename = NULL;
|
||||
struct stat statbuf;
|
||||
volatile bool do_rename = false;
|
||||
+ volatile bool clean_temp = false;
|
||||
int fd, sz;
|
||||
|
||||
if (!p->path) {
|
||||
@@ -800,14 +806,19 @@ static void uci_file_commit(struct uci_context *ctx, struct uci_package **packag
|
||||
if (!f2)
|
||||
UCI_THROW(ctx, UCI_ERR_IO);
|
||||
|
||||
- uci_export(ctx, f2, p, false);
|
||||
+ clean_temp = true;
|
||||
+ if (uci_export(ctx, f2, p, false))
|
||||
+ goto no_space;
|
||||
|
||||
- fflush(f2);
|
||||
+ if (fflush(f2))
|
||||
+ goto no_space;
|
||||
fsync(fileno(f2));
|
||||
- uci_close_stream(f2);
|
||||
|
||||
do_rename = true;
|
||||
|
||||
+no_space:
|
||||
+ uci_close_stream(f2);
|
||||
+
|
||||
UCI_TRAP_RESTORE(ctx);
|
||||
|
||||
done:
|
||||
@@ -821,6 +832,9 @@ done:
|
||||
UCI_THROW(ctx, UCI_ERR_IO);
|
||||
}
|
||||
free(path);
|
||||
+ } else if (clean_temp) {
|
||||
+ unlink(filename);
|
||||
+ UCI_THROW(ctx, UCI_ERR_IO);
|
||||
}
|
||||
if (ctx->err)
|
||||
UCI_THROW(ctx, ctx->err);
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
From 17586039934498210dc0a10bbe5a21cc042cdcd2 Mon Sep 17 00:00:00 2001
|
||||
From: Liangbin Lian <jjm2473@gmail.com>
|
||||
Date: Thu, 6 Jun 2024 15:42:46 +0800
|
||||
Subject: [PATCH] file: flush delta only after successful save
|
||||
|
||||
Signed-off-by: Liangbin Lian <jjm2473@gmail.com>
|
||||
---
|
||||
file.c | 15 +++++++++++++--
|
||||
1 file changed, 13 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/file.c b/file.c
|
||||
index 5c942b8..a6f30fe 100644
|
||||
--- a/file.c
|
||||
+++ b/file.c
|
||||
@@ -787,8 +787,8 @@ static void uci_file_commit(struct uci_context *ctx, struct uci_package **packag
|
||||
path = NULL;
|
||||
}
|
||||
|
||||
- /* flush delta */
|
||||
- if (!uci_load_delta(ctx, p, true))
|
||||
+ /* flush delta after successful save */
|
||||
+ if (!uci_load_delta(ctx, p, false))
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -830,6 +830,17 @@ done:
|
||||
if (!path || stat(path, &statbuf) || chmod(filename, statbuf.st_mode) || rename(filename, path)) {
|
||||
unlink(filename);
|
||||
UCI_THROW(ctx, UCI_ERR_IO);
|
||||
+ } else if (p->has_delta) {
|
||||
+ /* flush delta */
|
||||
+ filename = NULL;
|
||||
+ if ((asprintf(&filename, "%s/%s", ctx->savedir, p->e.name) < 0) || !filename)
|
||||
+ UCI_THROW(ctx, UCI_ERR_MEM);
|
||||
+ f1 = uci_open_stream(ctx, filename, NULL, SEEK_SET, true, false);
|
||||
+ if (f1) {
|
||||
+ ftruncate(fileno(f1), 0);
|
||||
+ uci_close_stream(f1);
|
||||
+ }
|
||||
+ free(filename);
|
||||
}
|
||||
free(path);
|
||||
} else if (clean_temp) {
|
||||
--
|
||||
2.41.0
|
||||
|
||||
@ -93,3 +93,15 @@ platform_do_upgrade() {
|
||||
echo "Writing new UUID to /dev/$diskdev..."
|
||||
get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
|
||||
}
|
||||
|
||||
platform_copy_config() {
|
||||
local partdev
|
||||
|
||||
if export_partdevice partdev 1; then
|
||||
mkdir -p /boot
|
||||
[ -f /boot/kernel.img ] || mount -t vfat -o rw,noatime "/dev/$partdev" /boot
|
||||
tar -C / -zxvf "$UPGRADE_BACKUP" boot/cmdline.txt boot/config.txt
|
||||
sync
|
||||
umount /boot
|
||||
fi
|
||||
}
|
||||
|
||||
@ -670,8 +670,6 @@ CONFIG_OLD_SIGSUSPEND3=y
|
||||
CONFIG_OPTEE=y
|
||||
CONFIG_OPTEE_SHM_NUM_PRIV_PAGES=1
|
||||
# CONFIG_OPTIMIZE_INLINING is not set
|
||||
CONFIG_OVERLAY_FS_INDEX=y
|
||||
CONFIG_OVERLAY_FS_NFS_EXPORT=y
|
||||
# CONFIG_PANIC_ON_OOPS is not set
|
||||
CONFIG_PANIC_ON_OOPS_VALUE=0
|
||||
CONFIG_PANIC_TIMEOUT=0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user