chiark / gitweb /
systemctl: try to reload daemon after enable/disable only when not running in a chroot
[elogind.git] / src / udev / udev-builtin-net_id.c
index 312a54a6c1368e91954bdec6c3cabf1800897a42..fbacb45877e99c4cbfc6ff9a0df68f15e645a477 100644 (file)
@@ -24,6 +24,8 @@
  *  - physical/geographical location of the hardware
  *  - the interface's MAC address
  *
+ * http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames
+ *
  * Two character prefixes based on the type of interface:
  *   en -- ethernet
  *   wl -- wlan
@@ -89,6 +91,7 @@
 #include <linux/pci_regs.h>
 
 #include "udev.h"
+#include "fileio.h"
 
 enum netname_type{
         NET_UNDEF,
@@ -221,7 +224,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
                 snprintf(str, sizeof(str), "%s/%s/address", slots, dent->d_name);
                 if (read_one_line_file(str, &address) >= 0) {
                         /* match slot address with device by stripping the function */
-                        if (strncmp(address, udev_device_get_sysname(names->pcidev), strlen(address)) == 0)
+                        if (strneq(address, udev_device_get_sysname(names->pcidev), strlen(address)))
                                 hotplug_slot = i;
                         free(address);
                 }
@@ -327,10 +330,13 @@ static int names_bcma(struct udev_device *dev, struct netnames *names) {
         if (!bcmadev)
                 return -ENOENT;
 
-        /* bus numcore num */
+        /* bus num:core num */
         if (sscanf(udev_device_get_sysname(bcmadev), "bcma%*d:%d", &core) != 1)
                 return -EINVAL;
-        snprintf(names->bcma_core, sizeof(names->bcma_core), "b%d", core);
+        /* suppress the common core == 0 */
+        if (core > 0)
+                snprintf(names->bcma_core, sizeof(names->bcma_core), "b%d", core);
+
         names->type = NET_BCMA;
         return 0;
 }
@@ -408,7 +414,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
         p = udev_device_get_sysattr_value(dev, "iflink");
         if (!p)
                 return EXIT_FAILURE;
-        if (strcmp(s, p) != 0)
+        if (!streq(s, p))
                 return 0;
 
         devtype = udev_device_get_devtype(dev);