mirror of
https://github.com/systemd/systemd
synced 2026-04-26 17:04:50 +02:00
Compare commits
No commits in common. "5662811e34a4c553ec4c5684d66061192427a1b3" and "70e723c000e46e2304e54f8063572d7fa0cdad46" have entirely different histories.
5662811e34
...
70e723c000
@ -17,7 +17,6 @@ struct state {
|
|||||||
int rcode;
|
int rcode;
|
||||||
const char *error_message;
|
const char *error_message;
|
||||||
const char *success_message;
|
const char *success_message;
|
||||||
const char *eexist_message;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int generic_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
static int generic_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||||
@ -31,9 +30,7 @@ static int generic_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userda
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
|
|
||||||
r = sd_netlink_message_get_errno(m);
|
r = sd_netlink_message_get_errno(m);
|
||||||
if (r == -EEXIST && s->eexist_message)
|
if (r < 0)
|
||||||
log_debug_errno(r, "%s", s->eexist_message);
|
|
||||||
else if (r < 0)
|
|
||||||
log_debug_errno(r, "%s: %m", s->error_message);
|
log_debug_errno(r, "%s: %m", s->error_message);
|
||||||
else
|
else
|
||||||
log_debug("%s", s->success_message);
|
log_debug("%s", s->success_message);
|
||||||
@ -160,11 +157,9 @@ int loopback_setup(void) {
|
|||||||
struct state state_4 = {
|
struct state state_4 = {
|
||||||
.error_message = "Failed to add address 127.0.0.1 to loopback interface",
|
.error_message = "Failed to add address 127.0.0.1 to loopback interface",
|
||||||
.success_message = "Successfully added address 127.0.0.1 to loopback interface",
|
.success_message = "Successfully added address 127.0.0.1 to loopback interface",
|
||||||
.eexist_message = "127.0.0.1 has already been added to loopback interface",
|
|
||||||
}, state_6 = {
|
}, state_6 = {
|
||||||
.error_message = "Failed to add address ::1 to loopback interface",
|
.error_message = "Failed to add address ::1 to loopback interface",
|
||||||
.success_message = "Successfully added address ::1 to loopback interface",
|
.success_message = "Successfully added address ::1 to loopback interface",
|
||||||
.eexist_message = "::1 has already been added to loopback interface",
|
|
||||||
}, state_up = {
|
}, state_up = {
|
||||||
.error_message = "Failed to bring loopback interface up",
|
.error_message = "Failed to bring loopback interface up",
|
||||||
.success_message = "Successfully brought loopback interface up",
|
.success_message = "Successfully brought loopback interface up",
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
#include "device-util.h"
|
#include "device-util.h"
|
||||||
#include "errno-util.h"
|
#include "errno-util.h"
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "fs-util.h"
|
|
||||||
#include "inotify-util.h"
|
#include "inotify-util.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
@ -49,25 +48,22 @@ static int check_device(const char *path) {
|
|||||||
|
|
||||||
assert(path);
|
assert(path);
|
||||||
|
|
||||||
if (arg_wait_until == WAIT_UNTIL_REMOVED) {
|
|
||||||
r = laccess(path, F_OK);
|
|
||||||
if (r == -ENOENT)
|
|
||||||
return true;
|
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = sd_device_new_from_path(&dev, path);
|
r = sd_device_new_from_path(&dev, path);
|
||||||
if (r == -ENODEV)
|
if (r == -ENODEV)
|
||||||
return false;
|
return arg_wait_until == WAIT_UNTIL_REMOVED;
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (arg_wait_until == WAIT_UNTIL_INITIALIZED)
|
switch (arg_wait_until) {
|
||||||
|
case WAIT_UNTIL_INITIALIZED:
|
||||||
return sd_device_get_is_initialized(dev);
|
return sd_device_get_is_initialized(dev);
|
||||||
|
case WAIT_UNTIL_ADDED:
|
||||||
return true;
|
return true;
|
||||||
|
case WAIT_UNTIL_REMOVED:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
assert_not_reached();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check(void) {
|
static bool check(void) {
|
||||||
|
|||||||
@ -489,7 +489,7 @@ testcase_iscsi_lvm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testcase_long_sysfs_path() {
|
testcase_long_sysfs_path() {
|
||||||
local cursor link logfile mpoint
|
local link logfile mpoint
|
||||||
local expected_symlinks=(
|
local expected_symlinks=(
|
||||||
"/dev/disk/by-label/data_vol"
|
"/dev/disk/by-label/data_vol"
|
||||||
"/dev/disk/by-label/swap_vol"
|
"/dev/disk/by-label/swap_vol"
|
||||||
@ -500,12 +500,6 @@ testcase_long_sysfs_path() {
|
|||||||
"/dev/disk/by-uuid/deadbeef-dead-dead-beef-222222222222"
|
"/dev/disk/by-uuid/deadbeef-dead-dead-beef-222222222222"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create a cursor file to skip messages generated by udevd in initrd, as it
|
|
||||||
# might not be the same up-to-date version as we currently run (hence generating
|
|
||||||
# messages we check for later and making the test fail)
|
|
||||||
cursor="$(mktemp)"
|
|
||||||
journalctl --cursor-file="${cursor:?}" -n0 -q
|
|
||||||
|
|
||||||
# Make sure the test device is connected and show its "wonderful" path
|
# Make sure the test device is connected and show its "wonderful" path
|
||||||
stat /sys/block/vda
|
stat /sys/block/vda
|
||||||
readlink -f /sys/block/vda/dev
|
readlink -f /sys/block/vda/dev
|
||||||
@ -532,20 +526,13 @@ testcase_long_sysfs_path() {
|
|||||||
udevadm settle
|
udevadm settle
|
||||||
|
|
||||||
logfile="$(mktemp)"
|
logfile="$(mktemp)"
|
||||||
# Check state of affairs after https://github.com/systemd/systemd/pull/22759
|
[[ "$(journalctl -b -q --no-pager -o short-monotonic -p info --grep "Device path.*vda.?' too long to fit into unit name" | wc -l)" -eq 0 ]]
|
||||||
# Note: can't use `--cursor-file` here, since we don't want to update the cursor
|
|
||||||
# after using it
|
|
||||||
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic -p info --grep "Device path.*vda.?' too long to fit into unit name" | wc -l)" -eq 0 ]]
|
|
||||||
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic --grep "Unit name .*vda.?\.device\" too long, falling back to hashed unit name" | wc -l)" -gt 0 ]]
|
|
||||||
# Check if the respective "hashed" units exist and are active (plugged)
|
|
||||||
systemctl status --no-pager "$(readlink -f /sys/block/vda/vda1)"
|
|
||||||
systemctl status --no-pager "$(readlink -f /sys/block/vda/vda2)"
|
|
||||||
# Make sure we don't unnecessarily spam the log
|
# Make sure we don't unnecessarily spam the log
|
||||||
{ journalctl -b -q --no-pager -o short-monotonic -p info --grep "/sys/devices/.+/vda[0-9]?" _PID=1 + UNIT=systemd-udevd.service || :;} | tee "$logfile"
|
{ journalctl -b -q --no-pager -o short-monotonic -p info --grep "/sys/devices/.+/vda[0-9]?" _PID=1 + UNIT=systemd-udevd.service || :;} | tee "$logfile"
|
||||||
[[ "$(wc -l <"$logfile")" -lt 10 ]]
|
[[ "$(wc -l <"$logfile")" -lt 10 ]]
|
||||||
|
|
||||||
: >/etc/fstab
|
: >/etc/fstab
|
||||||
rm -fr "${cursor:?}" "${logfile:?}" "${mpoint:?}"
|
rm -fr "${logfile:?}" "${mpoint:?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
testcase_mdadm_basic() {
|
testcase_mdadm_basic() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user