diff options
author | Damjan Marion <damarion@cisco.com> | 2023-08-07 01:07:09 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-08-07 18:00:10 +0000 |
commit | 40f481037ef98442b061e310a04ee5e110120f72 (patch) | |
tree | 20ecc6d1c7bcc701417b5bbbfd51cd2d1eadfa24 /src/vlib/linux/pci.c | |
parent | 993735913c6764d7a66c8fae4196a61206611186 (diff) |
vppinfra: add clib_file_get_resolved_basename
more generic version of clib_sysfs_link_to_name with support for
format strings...
Type: improvement
Change-Id: I0cb263748970378c661415196eb7e08450370677
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/linux/pci.c')
-rw-r--r-- | src/vlib/linux/pci.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c index e94fee1bcbd..9661827ea0d 100644 --- a/src/vlib/linux/pci.c +++ b/src/vlib/linux/pci.c @@ -293,16 +293,13 @@ vlib_pci_get_device_info (vlib_main_t * vm, vlib_pci_addr_t * addr, goto error; di->revision = tmp; - vec_reset_length (f); - f = format (f, "%v/driver%c", dev_dir_name, 0); - di->driver_name = clib_sysfs_link_to_name ((char *) f); + di->driver_name = + clib_file_get_resolved_basename ("%v/driver", dev_dir_name); if (!di->driver_name) di->driver_name = format (0, "<NONE>%c", 0); di->iommu_group = -1; - vec_reset_length (f); - f = format (f, "%v/iommu_group%c", dev_dir_name, 0); - tmpstr = clib_sysfs_link_to_name ((char *) f); + tmpstr = clib_file_get_resolved_basename ("%v/iommu_group", dev_dir_name); if (tmpstr) { di->iommu_group = atoi ((char *) tmpstr); @@ -506,9 +503,7 @@ vlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr, } } - s = format (s, "%v/driver%c", dev_dir_name, 0); - driver_name = clib_sysfs_link_to_name ((char *) s); - vec_reset_length (s); + driver_name = clib_file_get_resolved_basename ("%v/driver", dev_dir_name); if (driver_name && ((strcmp ("vfio-pci", (char *) driver_name) == 0) || |