udev-builtin-net_id: make names_ccw() self-contained
It is not necessary to store its partial result in NetNames. No functional changes, just refactoring.
This commit is contained in:
@@ -48,7 +48,6 @@ typedef enum NetNameType {
|
||||
NET_PCI,
|
||||
NET_USB,
|
||||
NET_BCMA,
|
||||
NET_CCW,
|
||||
NET_VIO,
|
||||
NET_XENVIF,
|
||||
NET_PLATFORM,
|
||||
@@ -66,7 +65,6 @@ typedef struct NetNames {
|
||||
|
||||
char usb_ports[ALTIFNAMSIZ];
|
||||
char bcma_core[ALTIFNAMSIZ];
|
||||
char ccw_busid[ALTIFNAMSIZ];
|
||||
char vio_slot[ALTIFNAMSIZ];
|
||||
char xen_slot[ALTIFNAMSIZ];
|
||||
char platform_path[ALTIFNAMSIZ];
|
||||
@@ -866,14 +864,16 @@ static int names_bcma(sd_device *dev, NetNames *names) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int names_ccw(sd_device *dev, NetNames *names) {
|
||||
static int names_ccw(sd_device *dev, const char *prefix, bool test) {
|
||||
sd_device *cdev;
|
||||
const char *bus_id, *subsys;
|
||||
size_t bus_id_start, bus_id_len;
|
||||
int r;
|
||||
|
||||
assert(dev);
|
||||
assert(names);
|
||||
assert(prefix);
|
||||
|
||||
/* get path names for Linux on System z network devices */
|
||||
|
||||
/* Retrieve the associated CCW device */
|
||||
r = sd_device_get_parent(dev, &cdev);
|
||||
@@ -918,13 +918,12 @@ static int names_ccw(sd_device *dev, NetNames *names) {
|
||||
bus_id_start = strspn(bus_id, ".0");
|
||||
bus_id += bus_id_start < bus_id_len ? bus_id_start : bus_id_len - 1;
|
||||
|
||||
/* Store the CCW bus-ID for use as network device name */
|
||||
if (!snprintf_ok(names->ccw_busid, sizeof(names->ccw_busid), "c%s", bus_id))
|
||||
return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ENAMETOOLONG),
|
||||
"Generated CCW name would be too long.");
|
||||
names->type = NET_CCW;
|
||||
/* Use the CCW bus-ID as network device name */
|
||||
char str[ALTIFNAMSIZ];
|
||||
if (snprintf_ok(str, sizeof str, "%sc%s", prefix, bus_id))
|
||||
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
|
||||
log_device_debug(dev, "CCW identifier: ccw_busid=%s %s \"%s\"",
|
||||
bus_id, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), names->ccw_busid);
|
||||
bus_id, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), str + strlen(prefix));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1192,15 +1191,7 @@ static int builtin_net_id(UdevEvent *event, int argc, char *argv[], bool test) {
|
||||
|
||||
(void) names_mac(dev, prefix, test);
|
||||
(void) names_devicetree(dev, prefix, test);
|
||||
|
||||
/* get path names for Linux on System z network devices */
|
||||
if (names_ccw(dev, &names) >= 0 && names.type == NET_CCW) {
|
||||
char str[ALTIFNAMSIZ];
|
||||
|
||||
if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.ccw_busid))
|
||||
udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str);
|
||||
return 0;
|
||||
}
|
||||
(void) names_ccw(dev, prefix, test);
|
||||
|
||||
/* get ibmveth/ibmvnic slot-based names. */
|
||||
if (names_vio(dev, &names) >= 0 && names.type == NET_VIO) {
|
||||
|
||||
Reference in New Issue
Block a user