base-files: board_detect: make resilient against power-cuts
authorAndreas Gnau <[email protected]>
Wed, 8 Oct 2025 21:00:44 +0000 (23:00 +0200)
committerHauke Mehrtens <[email protected]>
Tue, 25 Nov 2025 20:51:25 +0000 (21:51 +0100)
commit26ba9b609b95886dd7028fbd343ad079a1ef4445
tree62506f336bf112826883df0cd8f163f3b297f235
parentcac609aca8f309c6081f90d6d4475e57c738e315
base-files: board_detect: make resilient against power-cuts

If board_detect is interrupted by cutting power on first boot,
board.json might only be half-way written and the file will not be
written again correctly on subsequent boots.

Write to a temporary file first, then rename. Since a rename on the same
file system is an atomic operation, it ensures that either
/etc/board.json does not exist or that the complete file exists.

Signed-off-by: Andreas Gnau <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/20831
Signed-off-by: Hauke Mehrtens <[email protected]>
package/base-files/files/bin/board_detect