Commit 24f3afc
committed
base-files: board_detect: Make robust 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 boards.
Write to a temporary file first, then rename. Since a rename on the same
file system is an atomic operation, it ensures that either no
/etc/board.json or a complete /etc/board.json exists.
Signed-off-by: Andreas Gnau <andreas.gnau@iopsys.eu>1 parent 45739ba commit 24f3afc
1 file changed
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments