Skip to content

Commit e4d44bc

Browse files
poetteringbluca
authored andcommitted
sd-device: remove debug log message when dirs are missing
This is a common case, and nothing noteworthy at all. For example, if we establish an enumerator for listing all devices tagged by some tag, then the per-tag dir is not going to exist if there are currently no devices tagged that way, but that's a really common case, and doesn't really deserve any mention, not even at debug level. (cherry picked from commit a68c97a) (cherry picked from commit 8aa9e60) (cherry picked from commit a321caf) (cherry picked from commit 32a3200) (cherry picked from commit 9988e09)
1 parent 17712d3 commit e4d44bc

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

src/libsystemd/sd-device/device-enumerator.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,11 @@ static int enumerator_scan_dir_and_add_devices(
688688

689689
dir = opendir(path);
690690
if (!dir) {
691-
bool ignore = errno == ENOENT;
691+
/* This is necessarily racey, so ignore missing directories */
692+
if (errno == ENOENT)
693+
return 0;
692694

693-
/* this is necessarily racey, so ignore missing directories */
694-
log_debug_errno(errno,
695-
"sd-device-enumerator: Failed to open directory %s%s: %m",
696-
path, ignore ? ", ignoring" : "");
697-
return ignore ? 0 : -errno;
695+
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
698696
}
699697

700698
FOREACH_DIRENT_ALL(de, dir, return -errno) {
@@ -754,12 +752,10 @@ static int enumerator_scan_dir(
754752

755753
dir = opendir(path);
756754
if (!dir) {
757-
bool ignore = errno == ENOENT;
755+
if (errno == ENOENT)
756+
return 0;
758757

759-
log_debug_errno(errno,
760-
"sd-device-enumerator: Failed to open directory %s%s: %m",
761-
path, ignore ? ", ignoring" : "");
762-
return ignore ? 0 : -errno;
758+
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
763759
}
764760

765761
FOREACH_DIRENT_ALL(de, dir, return -errno) {
@@ -791,12 +787,10 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c
791787

792788
dir = opendir(path);
793789
if (!dir) {
794-
bool ignore = errno == ENOENT;
790+
if (errno == ENOENT)
791+
return 0;
795792

796-
log_debug_errno(errno,
797-
"sd-device-enumerator: Failed to open directory %s%s: %m",
798-
path, ignore ? ", ignoring" : "");
799-
return ignore ? 0 : -errno;
793+
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
800794
}
801795

802796
/* TODO: filter away subsystems? */
@@ -879,12 +873,10 @@ static int parent_crawl_children(sd_device_enumerator *enumerator, const char *p
879873

880874
dir = opendir(path);
881875
if (!dir) {
882-
bool ignore = errno == ENOENT;
876+
if (errno == ENOENT)
877+
return 0;
883878

884-
log_debug_errno(errno,
885-
"sd-device-enumerator: Failed to open directory %s%s: %m",
886-
path, ignore ? ", ignoring" : "");
887-
return ignore ? 0 : -errno;
879+
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
888880
}
889881

890882
FOREACH_DIRENT_ALL(de, dir, return -errno) {

0 commit comments

Comments
 (0)