mirror of
https://github.com/systemd/systemd.git
synced 2026-08-10 17:14:31 +00:00
udevadm info --cleanup-db cleaned links and tags by comparing them against /run/udev/data, but asserted when that data directory was missing. Treat a missing data directory as an empty database, so stale link and tag entries can be removed without aborting. Add a database test that runs cleanup-db with links and tags present but no data directory. Reproducer: $ sudo unshare --mount --propagation private sh -c ' mount -t tmpfs tmpfs /run/udev mkdir -p /run/udev/links/foo udevadm info --cleanup-db ' Assertion 'datadir' failed at src/udev/udevadm-info.c:676, function cleanup_dirs_after_db_cleanup(). Aborting. Aborted (core dumped) The command should handle a missing /run/udev/data directory instead of aborting.
30 lines
803 B
Bash
Executable File
30 lines
803 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
set -ex
|
|
set -o pipefail
|
|
|
|
IFNAME=test-udev-aaa
|
|
ip link add "$IFNAME" type dummy
|
|
IFINDEX=$(ip -json link show "$IFNAME" | jq '.[].ifindex')
|
|
udevadm wait --timeout=10 "/sys/class/net/$IFNAME"
|
|
# Check if the database file is created.
|
|
[[ -e "/run/udev/data/n$IFINDEX" ]]
|
|
|
|
ip link del "$IFNAME"
|
|
udevadm wait --timeout=10 --removed --settle "/sys/class/net/$IFNAME"
|
|
# CHeck if the database file is removed.
|
|
[[ ! -e "/run/udev/data/n$IFINDEX" ]]
|
|
|
|
unshare --mount --propagation private bash -eux <<'EOF'
|
|
mount -t tmpfs tmpfs /run/udev
|
|
mkdir -p /run/udev/links/test /run/udev/tags/test
|
|
touch /run/udev/links/test/stale /run/udev/tags/test/stale
|
|
|
|
udevadm info --cleanup-db
|
|
|
|
[[ ! -e /run/udev/links/test ]]
|
|
[[ ! -e /run/udev/tags/test ]]
|
|
EOF
|
|
|
|
exit 0
|