system: return ubus error when sysupgrade_exec_upgraded() has failed When sysupgrade_exec_upgraded() is successful, it will replace procd with upgraded, so it won't ever return (making the ubus call hang forever, which is fine as stage2 will kill all processes anyways). Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
watchdog: add support for starting/stopping kernel watchdog Extend the ubus watchdog cmd with the parameter magicclose; when set and in case the stopped parameter is enabled the kernel watchdog will be stopped by first sending the magic character 'V' followed by a close of the watchdog fd. In case stopped is set to disabled the watchdog fd will be created again. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Acked-by: John Crispin <john@phrozen.org>
system: introduce new attribute board_name Instead of modifying the already defined 'model' attribute rather introduce a new attribute board_name to return either /tmp/sysinfo/board_name or /proc/device-tree/compatible. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
system: return legacy board name The system board call returns the verbose model string instead of the board name. Unfortunately we have not yet estabkushed clear convention regarding device-tree 'compatible' or 'model' property and sysupgrade image name (same accounts for scraping /proc/cpuinfo on legacy targets). This is odd as the idea was to return information needed to identify the right sysupgrade image. On most targets we got a large shell-script which translates either /proc/cpuinfo or the 'model' property back into the board name used here. Hence /tmp/sysinfo/board_name should be returned instead of /tmp/sysinfo/model for the board ubus call as well. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
init: add support for sysupgrades triggered from preinit This will allow to add support for sysupgrades via upgraded from failsafe mode. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Remove code that has become unnecessary after sysupgrade changes Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
upgraded: add support for passing a "command" argument to stage2 This allows us to make use of upgraded in "snapshot convert" as well. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
upgraded: link dynamically, chroot during exec The chroot ensures we don't reference anything on the rootfs and is reverted after the upgraded exec. While we're at it, also improve error handling a bit. This change also required changes to sysupgrade, as the dynamically linked version is expected at a different location, and libraries need to be made available. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
system: always support staged sysupgrade In preparation for switching all targets to the staged sysupgrade mechanism, upgraded is always built, and the "nandupgrade" ubus method is renamed to "sysupgrade". To make the migration easier, support for the old name "nandupgrade" and the "upgrade" method that will become unused with the staged sysupgrade is retained for now. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
system: add reboot method to system ubus object Sometimes, for various reasons, user may want to reboot a device. This is a common task and it makes sense to support it with something common like a procd. Right now both: LuCI and LuCI2 implement this feature on their own with luci-rpc-luci2-system reboot and luci-rpc-sys reboot. This leads to code duplication and situation may become even worse with more software controlling system with ubus. Othen than that procd already has support for rebooting so one may consider this ubus method even cleaner. Once we get this patch in place we may consider switching LuCI and LuCI2 to this new method. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
system: fix localtime value in ubus info method output Function mktime respects current time zone and calling it results in converting time back to the UTC. It means we were never returning a time for local zone but GMT one. The easiest solution is to use tm_gmtoff from struct tm. Unfortunately this isn't part of POSIX but it seems to be the best idea anyway. Alternative (worse?) solutions: 1) Use timegm that is nonstandard GNU extension 2) Work with TZ env (getenv & (un)setenv) that is not thread-safe 3) Use timegm (next to localtime) and implement function comparing two struct tm. This is what glibc does internally (tm_diff) when compiled without HAVE_TM_GMTOFF. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
add ifdefs to make system.c compile on non-linux systems Signed-off-by: Felix Fietkau <nbd@openwrt.org>
system: fix undefined behavior in wdt offline check watchdog_fd() is returning a char* and not a int. checking against < 0 could lead in undefined behaviour. Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Attempt to deal gracefully with allocation failures. These should probably not happen in practice, but having an explicit error message may make debugging out-of-memory situations easier.
system: increase memory field sizes to 64bit On an Alix APU board with 4GB of available ram, the total memory is reported as "-179417088" bytes. Increase the ubus field sizes to 64bit integers in order to avoid overflows. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
system: attempt to parse /proc/device-tree/model Fallback to /proc/device-tree/model if /tmp/sysinfo/model is not available. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
system: improve system name detection Skip entries like "Processor: 0" which are common on x86, otherwise an "ubus call system board" will just return "system: 0". Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
system.c: parse quoted version info from /etc/openwrt_release Signed-off-by: Felix Fietkau <nbd@openwrt.org>
rename the folder option to path Signed-off-by: John Crispin <blogic@openwrt.org>
only add the nandupgrade method when /sbin/upgraded exists Signed-off-by: John Crispin <blogic@openwrt.org>