udev-builtin-net_id.c revision bf81e792f3c0aed54edf004c1c95cc6f6d81d0ee
along with systemd; If not, see <http://www.gnu.org/licenses/>.
* - firmware/bios-provided index numbers for on-board devices
* - physical/geographical location of the hardware
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "udev.h"
#include "fileio.h"
enum netname_type{
struct netnames {
bool mac_valid;
const char *pci_onboard_label;
const char *index;
int idx;
if (!index)
if (!index)
return -ENOENT;
if (idx <= 0)
return -EINVAL;
bool multi = false;
goto out;
goto out;
multi = true;
out:
fclose(f);
return multi;
size_t l;
const char *attr;
if (sscanf(udev_device_get_sysname(names->pcidev), "%x:%x:%x.%u", &domain, &bus, &slot, &func) != 4)
return -ENOENT;
if (attr)
if (domain > 0)
if (dev_id > 0)
if (!pci) {
goto out;
if (!dir) {
goto out;
char *rest;
char *address;
hotplug_slot = i;
if (hotplug_slot > 0)
if (hotplug_slot > 0) {
if (domain > 0)
if (dev_id > 0)
out:
return err;
if (!parent)
return -ENOENT;
return -ENOENT;
char *ports;
char *config;
char *interf;
size_t l;
if (!usbdev)
return -ENOENT;
return -EINVAL;
return -EINVAL;
return -EINVAL;
s = ports;
return -ENAMETOOLONG;
unsigned int core;
if (!bcmadev)
return -ENOENT;
return -EINVAL;
if (core > 0)
const char *bus_id;
int rc;
if (!cdev)
return -ENOENT;
return -ENOENT;
if (!bus_id)
return -ENOENT;
return -EINVAL;
return EXIT_FAILURE;
return -ENOENT;
return -EINVAL;
return -EINVAL;
return -ENOENT;
return -EINVAL;
const char *devtype;
int err;
return EXIT_FAILURE;
return EXIT_FAILURE;
return EXIT_FAILURE;
if (!streq(s, p))
if (devtype) {
goto out;
if (err < 0)
goto out;
goto out;
if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_path, names.usb_ports) < (int)sizeof(str))
if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.usb_ports) < (int)sizeof(str))
goto out;
if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_path, names.bcma_core) < (int)sizeof(str))
if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.bcma_core) < (int)sizeof(str))
goto out;
out:
return EXIT_SUCCESS;