X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-net_id.c;h=fbacb45877e99c4cbfc6ff9a0df68f15e645a477;hb=7962afbba9016ea03d9f2987fee341443fcde39d;hp=312a54a6c1368e91954bdec6c3cabf1800897a42;hpb=984c4348ff14d29c526d3d372daa82e278eeb5b4;p=elogind.git diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 312a54a6c..fbacb4587 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -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 #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 num, core 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);