From 552772d2a90fdf3536647518aea853df0c820cd1 Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Fri, 30 Jun 2023 16:56:11 +0200 Subject: [PATCH] zdev: fix unexpected warning due to non-existent interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using option --by-interface with a non-existent network interface name results in an unexpected duplicate warning message: $ lszdev --by-interface xx Could not open directory /sys/class/net/xx: No such file or directory Could not open directory /sys/class/net/xx: No such file or directory lszdev: Could not determine device that provides xx (xx) Fix this by checking for the existence of the associated /sys/class/net directory before initiating the associated directory traversal. Reviewed-by: Vineeth Vijayan Signed-off-by: Peter Oberparleiter Signed-off-by: Jan Höppner --- zdev/src/net.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zdev/src/net.c b/zdev/src/net.c index deee3fd4..c92c7d72 100644 --- a/zdev/src/net.c +++ b/zdev/src/net.c @@ -11,6 +11,8 @@ #include #include +#include "lib/util_path.h" + #include "devnode.h" #include "misc.h" #include "net.h" @@ -55,7 +57,8 @@ static bool add_devnodes_from_link(struct util_list *list, cb_data.prefix_len = strlen(prefix); cb_data.result = false; path = path_get_sys_class("net", devnode->name); - path_for_each(path, add_linked_cb, &cb_data); + if (util_path_exists(path)) + path_for_each(path, add_linked_cb, &cb_data); free(path); return cb_data.result;