summaryrefslogtreecommitdiffstats
path: root/src/udev/udev-builtin-net_id.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-27 09:13:51 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-07-29 15:14:24 +0200
commit80cd18080736431fac5e9fdd35100ea7971c4385 (patch)
tree1b9eebd5577551099d322f2f0de722ff4e81fa9c /src/udev/udev-builtin-net_id.c
parentudev-builtin-net_id: make dev_devicetree_onboard() self-contained (diff)
downloadsystemd-80cd18080736431fac5e9fdd35100ea7971c4385.tar.xz
systemd-80cd18080736431fac5e9fdd35100ea7971c4385.zip
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.
Diffstat (limited to 'src/udev/udev-builtin-net_id.c')
-rw-r--r--src/udev/udev-builtin-net_id.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index ea8fa439e3..a1e6af9df5 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -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) {