Skip to content

fix: avoid the by-label link race after formatting - #473

Merged
otavio merged 4 commits into
masterfrom
fix/wait-udev-after-mkfs
Nov 21, 2026
Merged

otavio merged 4 commits into
masterfrom
fix/wait-udev-after-mkfs

Conversation

@otavio

@otavio otavio commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Formatting a target reached through /dev/disk/by-label/* could fail right after mkfs: the new label makes udev drop and recreate the link, and the mount through it found "No such file or directory". It failed 2 of 3 times on one board; the update stopped before switching sets.

  • fix(target): resolve device links to their device node: get_target resolves a device path to its node once, so format and both mounts use the node instead of the link.
  • fix(target): report device targets that cannot be resolved: a missing link fails as DeviceDoesNotExist naming the configured path; other errors (symlink loop, EACCES) are propagated instead of being reported as missing. The resolved node is traced.
  • fix(raw): check and write the resolved target: raw and raw-delta validated the node but read and wrote through the link; they now use the node throughout.
  • fix(fs): wait for udev after formatting a device: a later object may still reach the device through the link, so udevadm settle --timeout=30 runs after formatting when available. Skipped for JFFS2/UBIFS; a failure is only logged.

Argument quoting for the commands these paths reach is in the stacked PR on top of this one.

Testing

  • cargo clippy -p updatehub --all-targets -- -D warnings and cargo test -p updatehub --lib pass on every commit (142 passed, 29 ignored at the tip).
  • New tests: link resolution, dangling link and symlink loop errors, and the udev wait (call, MTD skip, failing settle) with the tools replaced by scripts on PATH.
  • Not run: root/loop-device tests, and the mkfs/mount race on a board.

@otavio
otavio force-pushed the fix/wait-udev-after-mkfs branch from 1d5650a to ad1e7ee Compare November 19, 2026 20:36
- Canonicalize device targets such as /dev/disk/by-label/* to the node they point at
- Formatting rewrites the label, so udev recreates the link and a mount right after mkfs can find it missing; the node itself is stable
- Keep unresolvable paths as given so validation still reports them as missing
- Add a test for link resolution
@otavio
otavio force-pushed the fix/wait-udev-after-mkfs branch from c24841a to f7c9a82 Compare November 21, 2026 13:33
- A missing link now fails as DeviceDoesNotExist naming the configured path, instead of falling
  back to the link and failing later at mount with ENOENT
- Other resolution errors, such as a symlink loop or EACCES, are propagated instead of being
  reported as a missing device
- Trace which node a target resolves to, since errors now name the node rather than the link
- Raw and raw-delta validated the resolved node but ran their space check, install-if-different
  read and write through the configured link
- Use the resolved target throughout, like the other installers, so a link udev is recreating
  cannot be reached mid-install
- mkfs rewrites the label, so udev recreates /dev/disk/by-label/* while a later object in the same
  update may already be resolving that link
- Run `udevadm settle --timeout=30` after formatting when it is available: the queue is global, so
  unrelated events must not hold the update for the 120 s default
- Skip it for JFFS2 and UBIFS, whose MTD devices have no /dev/disk links; boards without udev keep
  working and a settle failure is only logged
- Tests replace the tools with scripts on PATH to confirm the call, the MTD skip and that a
  failing settle does not fail the format
@otavio
otavio force-pushed the fix/wait-udev-after-mkfs branch from f7c9a82 to 0d9980e Compare November 21, 2026 13:50
@otavio otavio changed the title fix(target): resolve device links to their device node fix: avoid the by-label link race after formatting Nov 21, 2026
@otavio
otavio added this pull request to stack #476 November 21, 2026 13:54
@otavio
otavio merged commit 0abdd3c into master Nov 21, 2026
3 checks passed
@otavio
otavio deleted the fix/wait-udev-after-mkfs branch November 21, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant