Skip to content

Commit

Permalink
sd-device: remove debug log message when dirs are missing
Browse files Browse the repository at this point in the history
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 a68c97a54527cacaeeac0c117493639fc455ef5e)
(cherry picked from commit 8aa9e60f89f84a90fb364ee66cf62432a6b877ba)
  • Loading branch information
poettering authored and bluca committed Jul 24, 2024
1 parent 0537c8b commit a321caf
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions src/libsystemd/sd-device/device-enumerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,11 @@ static int enumerator_scan_dir_and_add_devices(

dir = opendir(path);
if (!dir) {
bool ignore = errno == ENOENT;
/* This is necessarily racey, so ignore missing directories */
if (errno == ENOENT)
return 0;

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

FOREACH_DIRENT_ALL(de, dir, return -errno) {
Expand Down Expand Up @@ -773,12 +771,10 @@ static int enumerator_scan_dir(

dir = opendir(path);
if (!dir) {
bool ignore = errno == ENOENT;
if (errno == ENOENT)
return 0;

log_debug_errno(errno,
"sd-device-enumerator: Failed to open directory %s%s: %m",
path, ignore ? ", ignoring" : "");
return ignore ? 0 : -errno;
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
}

FOREACH_DIRENT_ALL(de, dir, return -errno) {
Expand Down Expand Up @@ -810,12 +806,10 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c

dir = opendir(path);
if (!dir) {
bool ignore = errno == ENOENT;
if (errno == ENOENT)
return 0;

log_debug_errno(errno,
"sd-device-enumerator: Failed to open directory %s%s: %m",
path, ignore ? ", ignoring" : "");
return ignore ? 0 : -errno;
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
}

/* TODO: filter away subsystems? */
Expand Down Expand Up @@ -898,12 +892,10 @@ static int parent_crawl_children(sd_device_enumerator *enumerator, const char *p

dir = opendir(path);
if (!dir) {
bool ignore = errno == ENOENT;
if (errno == ENOENT)
return 0;

log_debug_errno(errno,
"sd-device-enumerator: Failed to open directory %s%s: %m",
path, ignore ? ", ignoring" : "");
return ignore ? 0 : -errno;
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
}

FOREACH_DIRENT_ALL(de, dir, return -errno) {
Expand Down

0 comments on commit a321caf

Please sign in to comment.