chiark / gitweb /
treewide: auto-convert the simple cases to log_*_errno()
[elogind.git] / src / network / networkctl.c
index 43258bb942538be3568eb6efd59f4ae2bd77666d..3e21d9acb8b23dfc61025080371abb3b4f901661 100644 (file)
@@ -191,7 +191,7 @@ static int list_links(char **args, unsigned n) {
 
         r = sd_rtnl_open(&rtnl, 0);
         if (r < 0) {
-                log_error("Failed to connect to netlink: %s", strerror(-r));
+                log_error_errno(-r, "Failed to connect to netlink: %m");
                 return r;
         }
 
@@ -211,7 +211,7 @@ static int list_links(char **args, unsigned n) {
 
         r = sd_rtnl_call(rtnl, req, 0, &reply);
         if (r < 0) {
-                log_error("Failed to enumerate links: %s", strerror(-r));
+                log_error_errno(-r, "Failed to enumerate links: %m");
                 return r;
         }
 
@@ -295,7 +295,7 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
         _cleanup_udev_device_unref_ struct udev_device *d = NULL;
         char devid[2 + DECIMAL_STR_MAX(int)];
         _cleanup_free_ char *t = NULL, *network = NULL;
-        const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL;
+        const char *driver = NULL, *path = NULL, *vendor = NULL, *model = NULL, *link = NULL;
         const char *on_color_operational, *off_color_operational,
                    *on_color_setup, *off_color_setup;
         struct ether_addr e;
@@ -323,7 +323,7 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
 
         r = sd_rtnl_call(rtnl, req, 0, &reply);
         if (r < 0) {
-                log_error("Failed to query link: %s", strerror(-r));
+                log_error_errno(-r, "Failed to query link: %m");
                 return r;
         }
 
@@ -384,6 +384,7 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
         link_get_type_string(iftype, d, &t);
 
         if (d) {
+                link = udev_device_get_property_value(d, "ID_NET_LINK_FILE");
                 driver = udev_device_get_property_value(d, "ID_NET_DRIVER");
                 path = udev_device_get_property_value(d, "ID_PATH");
 
@@ -400,9 +401,11 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) {
 
         printf("%s%s%s %i: %s\n", on_color_operational, draw_special_char(DRAW_BLACK_CIRCLE), off_color_operational, ifindex, name);
 
-        printf("Network File: %s\n"
+        printf("   Link File: %s\n"
+               "Network File: %s\n"
                "        Type: %s\n"
                "       State: %s%s%s (%s%s%s)\n",
+               strna(link),
                strna(network),
                strna(t),
                on_color_operational, strna(operational_state), off_color_operational,
@@ -445,7 +448,7 @@ static int link_status(char **args, unsigned n) {
 
         r = sd_rtnl_open(&rtnl, 0);
         if (r < 0) {
-                log_error("Failed to connect to netlink: %s", strerror(-r));
+                log_error_errno(-r, "Failed to connect to netlink: %m");
                 return r;
         }
 
@@ -511,7 +514,7 @@ static int link_status(char **args, unsigned n) {
 
                 r = sd_rtnl_call(rtnl, req, 0, &reply);
                 if (r < 0) {
-                        log_error("Failed to enumerate links: %s", strerror(-r));
+                        log_error_errno(-r, "Failed to enumerate links: %m");
                         return r;
                 }