Update libdevq to 0.0.4

This commit is contained in:
Baptiste Daroussin 2017-01-16 22:52:16 +00:00
parent 6dbfad2eb0
commit 2acd3223a3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=431707
4 changed files with 11 additions and 131 deletions

View file

@ -2,19 +2,22 @@
# $FreeBSD$
PORTNAME= libdevq
PORTVERSION= 0.0.2
PORTREVISION= 1
PORTVERSION= 0.0.4
CATEGORIES= devel
MASTER_SITES= http://rainbow-runner.nl/freebsd/
MASTER_SITES= https://github.com/freebsd/${PORTNAME}/releases/download/${PORTVERSION}/
MAINTAINER= x11@FreeBSD.org
COMMENT= Generic Device Query and Monitor interface
LICENSE= BSD2CLAUSE
GNU_CONFIGURE= yes
USES= libtool pathfix tar:xz
USES= autoreconf libtool pathfix tar:xz
USE_LDCONFIG= yes
INSTALL_TARGET= install-strip
PATHFIX_MAKEFILEIN= Makefile.am
OPTIONS_DEFINE= PROGRAMS
OPTIONS_SUB= yes
PROGRAMS_DESC= Build diagnostic programs

View file

@ -1,2 +1,3 @@
SHA256 (libdevq-0.0.2.tar.xz) = 138ce3a0023ade78b36232343da0f589302db406216e39ea8ffb586ea2417305
SIZE (libdevq-0.0.2.tar.xz) = 210960
TIMESTAMP = 1479746328
SHA256 (libdevq-0.0.4.tar.xz) = 147b13a9667c16f4384eb25d463f80a567cc9ea4dc3f7e8a3ff588d4e4fc2325
SIZE (libdevq-0.0.4.tar.xz) = 225268

View file

@ -1,125 +0,0 @@
From 7b48b8726b85eac66c1b164fab87d154be5aa068 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= <dumbbell@FreeBSD.org>
Date: Fri, 13 Feb 2015 19:46:37 +0100
Subject: [PATCH] Support dev.$driver.$n.%location from FreeBSD 11.x
The format changed from:
slot=1 function=0
to:
pci0:2:0:0 handle=\_SB_.PCI0.PEG3.MXM3
Now devq_device_get_pciid_from_fd() supports both formats.
---
src/device.c | 89 ++++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 60 insertions(+), 29 deletions(-)
diff --git a/src/device.c b/src/device.c
index 9aadc2b..77df580 100644
--- src/device.c
+++ src/device.c
@@ -188,6 +188,58 @@ devq_device_get_devpath_from_fd(int fd,
#endif /* defined(HAVE_LIBPROCSTAT_H) */
}
+static int
+devq_compare_vgapci_busaddr(int i, int *domain, int *bus, int *slot,
+ int *function)
+{
+ int ret;
+ char sysctl_name[32], sysctl_value[128];
+ size_t sysctl_value_len;
+
+ sprintf(sysctl_name, "dev.vgapci.%d.%%location", i);
+
+ sysctl_value_len = sizeof(sysctl_value);
+ memset(sysctl_value, 0, sysctl_value_len);
+ ret = sysctlbyname(sysctl_name, sysctl_value,
+ &sysctl_value_len, NULL, 0);
+ if (ret != 0)
+ return (-1);
+
+ /*
+ * dev.vgapci.$m.%location can have two formats:
+ * o "pci0:2:0:0 handle=\_SB_.PCI0.PEG3.MXM3" (FreeBSD 11+)
+ * o "slot=1 function=0" (up-to FreeBSD 10)
+ */
+
+ ret = sscanf(sysctl_value, "pci%d:%d:%d:%d %*s",
+ domain, bus, slot, function);
+ if (ret == 4)
+ return (0);
+
+ ret = sscanf(sysctl_value, "slot=%d function=%d %*s",
+ slot, function);
+ if (ret != 2)
+ return (-1);
+
+ sprintf(sysctl_name, "dev.vgapci.%d.%%parent", i);
+
+ sysctl_value_len = sizeof(sysctl_value);
+ memset(sysctl_value, 0, sysctl_value_len);
+ ret = sysctlbyname(sysctl_name, sysctl_value,
+ &sysctl_value_len, NULL, 0);
+ if (ret != 0)
+ return (-1);
+
+ ret = sscanf(sysctl_value, "pci%d", bus);
+ if (ret != 1)
+ return (-1);
+
+ /* FIXME: What domain to assume? */
+ *domain = 0;
+
+ return (0);
+}
+
int
devq_device_get_pciid_from_fd(int fd,
int *vendor_id, int *device_id)
@@ -253,38 +305,17 @@ devq_device_get_pciid_from_fd(int fd,
* o dev.vgapci.$m.%parent
*/
for (i = 0; i < DEVQ_MAX_DEVS; ++i) {
- sprintf(sysctl_name, "dev.vgapci.%d.%%location", i);
-
- sysctl_value_len = sizeof(sysctl_value);
- memset(sysctl_value, 0, sysctl_value_len);
- ret = sysctlbyname(sysctl_name, sysctl_value,
- &sysctl_value_len, NULL, 0);
- if (ret != 0)
- continue;
+ int tmp_domain, tmp_bus, tmp_slot, tmp_function;
- int tmp_slot, tmp_function;
- ret = sscanf(sysctl_value, "slot=%d function=%d %*s",
+ ret = devq_compare_vgapci_busaddr(i, &tmp_domain, &tmp_bus,
&tmp_slot, &tmp_function);
- if (ret != 2 ||
- tmp_slot != slot || tmp_function != function)
- continue;
-
- sprintf(sysctl_name, "dev.vgapci.%d.%%parent", i);
-
- sysctl_value_len = sizeof(sysctl_value);
- memset(sysctl_value, 0, sysctl_value_len);
- ret = sysctlbyname(sysctl_name, sysctl_value,
- &sysctl_value_len, NULL, 0);
- if (ret != 0)
- continue;
-
- int tmp_bus;
- ret = sscanf(sysctl_value, "pci%d",
- &tmp_bus);
- if (ret != 1 || tmp_bus != bus)
- continue;
- break;
+ if (ret == 0 &&
+ tmp_domain == domain &&
+ tmp_bus == bus &&
+ tmp_slot == slot &&
+ tmp_function == function)
+ break;
}
if (i == DEVQ_MAX_DEVS) {

View file

@ -5,3 +5,4 @@ lib/libdevq.so
lib/libdevq.so.0
lib/libdevq.so.0.0.0
libdata/pkgconfig/libdevq-1.0.pc
man/man3/libdevq.3.gz