Hello community, here is the log from the commit of package hwinfo for openSUSE:Factory checked in at 2020-11-23 16:39:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/hwinfo (Old) and /work/SRC/openSUSE:Factory/.hwinfo.new.5913 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "hwinfo" Mon Nov 23 16:39:43 2020 rev:175 rq:849708 version:21.71 Changes: -------- --- /work/SRC/openSUSE:Factory/hwinfo/hwinfo.changes 2020-04-25 20:12:17.736039028 +0200 +++ /work/SRC/openSUSE:Factory/.hwinfo.new.5913/hwinfo.changes 2020-11-23 18:45:38.033067134 +0100 @@ -1,0 +2,8 @@ +Fri Nov 20 16:22:55 UTC 2020 - wfe...@opensuse.org + +- merge gh#openSUSE/hwinfo#89 +- rework network device detection on aarch64 (bsc#1177600, + bsc#1177261) +- 21.71 + +-------------------------------------------------------------------- Old: ---- hwinfo-21.70.tar.xz New: ---- hwinfo-21.71.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ hwinfo.spec ++++++ --- /var/tmp/diff_new_pack.sNA72J/_old 2020-11-23 18:45:38.649067775 +0100 +++ /var/tmp/diff_new_pack.sNA72J/_new 2020-11-23 18:45:38.653067779 +0100 @@ -37,7 +37,7 @@ License: GPL-2.0-or-later Group: Hardware/Other Url: http://gitorious.org/opensuse/hwinfo -Version: 21.70 +Version: 21.71 Release: 0 Source: %{name}-%{version}.tar.xz BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ hwinfo-21.70.tar.xz -> hwinfo-21.71.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hwinfo-21.70/VERSION new/hwinfo-21.71/VERSION --- old/hwinfo-21.70/VERSION 2020-04-21 09:01:31.000000000 +0200 +++ new/hwinfo-21.71/VERSION 2020-11-20 17:22:55.000000000 +0100 @@ -1 +1 @@ -21.70 +21.71 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hwinfo-21.70/changelog new/hwinfo-21.71/changelog --- old/hwinfo-21.70/changelog 2020-04-21 09:01:31.000000000 +0200 +++ new/hwinfo-21.71/changelog 2020-11-20 17:22:55.000000000 +0100 @@ -1,3 +1,8 @@ +2020-11-20: 21.71 + - merge gh#openSUSE/hwinfo#89 + - rework network device detection on aarch64 (bsc#1177600, + bsc#1177261) + 2020-04-21: 21.70 - merge gh#openSUSE/hwinfo#86 - update pci and usb ids (bsc#1169682) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hwinfo-21.70/src/hd/hd.c new/hwinfo-21.71/src/hd/hd.c --- old/hwinfo-21.70/src/hd/hd.c 2020-04-21 09:01:31.000000000 +0200 +++ new/hwinfo-21.71/src/hd/hd.c 2020-11-20 17:22:55.000000000 +0100 @@ -2633,6 +2633,28 @@ } +/* + * Read directory, return a list of canonicalized entries with file type 'type'. + * + * The difference to read_dir() is that symlinks are resolved and the + * canonical path within sysfs is returned. + */ +str_list_t *read_dir_canonical(char *dir_name, int type) +{ + str_list_t *list = read_dir(dir_name, type); + + if(!list) return list; + + for(str_list_t *sl = list; sl; sl = sl->next) { + char *tmp = new_str(hd_read_sysfs_link(dir_name, sl->str)); + free_mem(sl->str); + sl->str = tmp; + } + + return list; +} + + char *hd_read_sysfs_link(char *base_dir, char *link_name) { char *s = NULL; @@ -2651,6 +2673,53 @@ } +/* + * Return list with all elements in list that are subcomponents of comp. + * + * If max > 0 at most max elements are returned. + * + * Note: it must really be a subdirectory or attribute below comp. A + * component is *not* a subcomponent of itself. + * IOW: the path in list must really be longer than comp to qualify. + */ +str_list_t *subcomponent_list(str_list_t *list, char *comp, int max) +{ + str_list_t *sub_list = NULL; + + if(!list || !comp) return sub_list; + + size_t comp_len = strlen(comp); + + for(str_list_t *sl = list; sl; sl = sl->next) { + if( + !strncmp(sl->str, comp, comp_len) && + sl->str[comp_len] == '/' + ) { + add_str_list(&sub_list, sl->str); + if(!--max) return sub_list; + } + } + + return sub_list; +} + + +/* + * Check if list contains a subcomponent of comp. + * + * Returns 0 (no) or 1 (yes). + */ +int has_subcomponent(str_list_t *list, char *comp) +{ + str_list_t *sl = subcomponent_list(list, comp, 1); + if(!sl) return 0; + + free_str_list(sl); + + return 1; +} + + /* * Log the hardware detection progress. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hwinfo-21.70/src/hd/hd_int.h new/hwinfo-21.71/src/hd/hd_int.h --- old/hwinfo-21.70/src/hd/hd_int.h 2020-04-21 09:01:31.000000000 +0200 +++ new/hwinfo-21.71/src/hd/hd_int.h 2020-11-20 17:22:55.000000000 +0100 @@ -120,7 +120,10 @@ str_list_t *reverse_str_list(str_list_t *list); str_list_t *read_file(char *file_name, unsigned start_line, unsigned lines); str_list_t *read_dir(char *dir_name, int type); +str_list_t *read_dir_canonical(char *dir_name, int type); char *hd_read_sysfs_link(char *base_dir, char *link_name); +str_list_t *subcomponent_list(str_list_t *list, char *comp, int max); +int has_subcomponent(str_list_t *list, char *comp); void progress(hd_data_t *hd_data, unsigned pos, unsigned count, char *msg); void remove_hd_entries(hd_data_t *hd_data); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hwinfo-21.70/src/hd/pci.c new/hwinfo-21.71/src/hd/pci.c --- old/hwinfo-21.70/src/hd/pci.c 2020-04-21 09:01:31.000000000 +0200 +++ new/hwinfo-21.71/src/hd/pci.c 2020-11-20 17:22:55.000000000 +0100 @@ -939,21 +939,26 @@ void hd_read_platform(hd_data_t *hd_data) { char *s, *platform_type, *device_type, *driver; - str_list_t *sf_bus, *sf_bus_e, *sf_eth_dev = NULL; - char *sf_dev, *sf_eth_net; + str_list_t *sf_bus, *sf_bus_e, *sf_bus_canonical, *sf_eth_dev = NULL; + char *sf_dev; int mv643xx_eth_seen = 0; int is_net, is_storage, is_usb, is_xhci, is_ehci; hd_t *hd; + char *sysfs_device_dir = "/sys/bus/platform/devices"; - sf_bus = read_dir("/sys/bus/platform/devices", 'l'); + sf_bus = read_dir(sysfs_device_dir, 'l'); + sf_bus_canonical = read_dir_canonical(sysfs_device_dir, 'l'); if(!sf_bus) { ADD2LOG("sysfs: no such bus: platform\n"); return; } + /* list of network interfaces */ + str_list_t *net_list = read_dir_canonical("/sys/class/net", 'l'); + for(sf_bus_e = sf_bus; sf_bus_e; sf_bus_e = sf_bus_e->next) { - sf_dev = new_str(hd_read_sysfs_link("/sys/bus/platform/devices", sf_bus_e->str)); + sf_dev = new_str(hd_read_sysfs_link(sysfs_device_dir, sf_bus_e->str)); ADD2LOG( " platform device: name = %s\n path = %s\n", @@ -977,10 +982,14 @@ driver = hd_sysfs_find_driver(hd_data, hd_sysfs_id(sf_dev), 1); if(!driver) driver = ""; ADD2LOG(" type = \"%s\", modalias = \"%s\", driver = \"%s\"\n", device_type, platform_type, driver); + /* + * it's a network device if + * - there's a link to a network interface in a subdir *AND* + * - there's no other device that is actually a subdevice of this one + */ is_net = 0; - sf_eth_net = new_str(hd_read_sysfs_link(sf_dev, "net")); - sf_eth_dev = read_dir(sf_eth_net, 'd'); - is_net = sf_eth_net && sf_eth_dev; + sf_eth_dev = subcomponent_list(net_list, sf_dev, 0); + is_net = !!sf_eth_dev && !has_subcomponent(sf_bus_canonical, sf_dev); is_storage = !strcmp(device_type, "sata") || !strcmp(platform_type, "acpi:HISI0161:") || @@ -998,13 +1007,15 @@ strstr(driver, "xhci-") ); is_ehci = !!strstr(driver, "ehci-"); - if(is_net) ADD2LOG(" is net: sf_eth_net = %s\n", sf_eth_net); + if(is_net) { + for(str_list_t *sl = sf_eth_dev; sl; sl = sl->next) { + ADD2LOG(" is net: interface = %s\n", sl->str); + } + } if(is_storage) ADD2LOG(" is storage\n"); if(is_usb) ADD2LOG(" is usb\n"); if(is_xhci) ADD2LOG(" is xhci\n"); if(is_ehci) ADD2LOG(" is ehci\n"); - free_mem(sf_eth_net); - free_str_list(sf_eth_dev); if( /* there is 'mv643xx_eth.0', 'mv643xx_eth.1' and 'mv643xx_eth_shared.' */ is_net && @@ -1014,15 +1025,37 @@ add_mv643xx_eth(hd_data, sf_bus_e->str, platform_type); } else if(is_net) { - hd = add_hd_entry(hd_data, __LINE__, 0); - hd->base_class.id = bc_network; - hd->sub_class.id = 0; - str_printf(&hd->device.name, 0, "ARM Ethernet controller"); - hd->modalias = new_str(platform_type); - hd->sysfs_id = new_str(hd_sysfs_id(sf_dev)); - hd->sysfs_bus_id = new_str(sf_bus_e->str); - s = hd_sysfs_find_driver(hd_data, hd->sysfs_id, 1); - if(s) add_str_list(&hd->drivers, s); + /* note there might be more than one interface per device - hence this is a list */ + for(str_list_t *sl = sf_eth_dev; sl; sl = sl->next) { + hd = add_hd_entry(hd_data, __LINE__, 0); + hd->base_class.id = bc_network; + hd->sub_class.id = 0; + str_printf(&hd->device.name, 0, "ARM Ethernet controller"); + hd->modalias = new_str(platform_type); + /* + * the interface link ends with 'net' + interface, e.g. .../net/ethX + * -> strip these two parts to form the sysfs id + */ + char *tmp = new_str(hd_sysfs_id(sl->str)); + char *slash = strrchr(tmp, '/'); + if(slash) *slash = 0, slash = strrchr(tmp, '/'); + if(slash) *slash = 0; + hd->sysfs_id = new_str(tmp); + free_mem(tmp); + /* + * the bus id is the last part of the sysfs id - if that fails for + * some reason fall back to device link name + */ + tmp = strrchr(hd->sysfs_id, '/'); + if(tmp) { + hd->sysfs_bus_id = new_str(tmp + 1); + } + else { + hd->sysfs_bus_id = new_str(sf_bus_e->str); + } + s = hd_sysfs_find_driver(hd_data, hd->sysfs_id, 1); + if(s) add_str_list(&hd->drivers, s); + } } else if(is_storage) { hd = add_hd_entry(hd_data, __LINE__, 0); @@ -1064,6 +1097,7 @@ s = hd_sysfs_find_driver(hd_data, hd->sysfs_id, 1); if(s) add_str_list(&hd->drivers, s); } + free_str_list(sf_eth_dev); free_mem(device_type); free_mem(platform_type); } @@ -1071,6 +1105,8 @@ free_mem(sf_dev); } + free_str_list(net_list); + free_str_list(sf_bus); } _______________________________________________ openSUSE Commits mailing list -- commit@lists.opensuse.org To unsubscribe, email commit-le...@lists.opensuse.org List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette List Archives: https://lists.opensuse.org/archives/list/commit@lists.opensuse.org