View | Details | Raw Unified | Return to bug 214706 | Differences between
and this patch

Collapse All | Expand All

(-)devel/libdevq/Makefile (-4 / +5 lines)
Lines 2-20 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	libdevq
4
PORTNAME=	libdevq
5
PORTVERSION=	0.0.2
5
PORTVERSION=	0.0.4
6
PORTREVISION=	1
7
CATEGORIES=	devel
6
CATEGORIES=	devel
8
MASTER_SITES=	http://rainbow-runner.nl/freebsd/
7
MASTER_SITES=	https://github.com/freebsd/${PORTNAME}/releases/download/${PORTVERSION}/
9
8
10
MAINTAINER=	x11@FreeBSD.org
9
MAINTAINER=	x11@FreeBSD.org
11
COMMENT=	Generic Device Query and Monitor interface
10
COMMENT=	Generic Device Query and Monitor interface
12
11
13
GNU_CONFIGURE=	yes
12
GNU_CONFIGURE=	yes
14
USES=		libtool pathfix tar:xz
13
USES=		autoreconf libtool pathfix tar:xz
15
USE_LDCONFIG=	yes
14
USE_LDCONFIG=	yes
16
INSTALL_TARGET=	install-strip
15
INSTALL_TARGET=	install-strip
17
16
17
PATHFIX_MAKEFILEIN=	Makefile.am
18
18
OPTIONS_DEFINE=	PROGRAMS
19
OPTIONS_DEFINE=	PROGRAMS
19
OPTIONS_SUB=	yes
20
OPTIONS_SUB=	yes
20
PROGRAMS_DESC=	Build diagnostic programs
21
PROGRAMS_DESC=	Build diagnostic programs
(-)devel/libdevq/distinfo (-2 / +3 lines)
Lines 1-2 Link Here
1
SHA256 (libdevq-0.0.2.tar.xz) = 138ce3a0023ade78b36232343da0f589302db406216e39ea8ffb586ea2417305
1
TIMESTAMP = 1479746328
2
SIZE (libdevq-0.0.2.tar.xz) = 210960
2
SHA256 (libdevq-0.0.4.tar.xz) = 147b13a9667c16f4384eb25d463f80a567cc9ea4dc3f7e8a3ff588d4e4fc2325
3
SIZE (libdevq-0.0.4.tar.xz) = 225268
(-)devel/libdevq/files/patch-src_device.c (-125 lines)
Lines 1-125 Link Here
1
From 7b48b8726b85eac66c1b164fab87d154be5aa068 Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= <dumbbell@FreeBSD.org>
3
Date: Fri, 13 Feb 2015 19:46:37 +0100
4
Subject: [PATCH] Support dev.$driver.$n.%location from FreeBSD 11.x
5
6
The format changed from:
7
    slot=1 function=0
8
to:
9
    pci0:2:0:0 handle=\_SB_.PCI0.PEG3.MXM3
10
11
Now devq_device_get_pciid_from_fd() supports both formats.
12
---
13
 src/device.c | 89 ++++++++++++++++++++++++++++++++++++++++--------------------
14
 1 file changed, 60 insertions(+), 29 deletions(-)
15
16
diff --git a/src/device.c b/src/device.c
17
index 9aadc2b..77df580 100644
18
--- src/device.c
19
+++ src/device.c
20
@@ -188,6 +188,58 @@ devq_device_get_devpath_from_fd(int fd,
21
 #endif /* defined(HAVE_LIBPROCSTAT_H) */
22
 }
23
 
24
+static int
25
+devq_compare_vgapci_busaddr(int i, int *domain, int *bus, int *slot,
26
+    int *function)
27
+{
28
+	int ret;
29
+	char sysctl_name[32], sysctl_value[128];
30
+	size_t sysctl_value_len;
31
+
32
+	sprintf(sysctl_name, "dev.vgapci.%d.%%location", i);
33
+
34
+	sysctl_value_len = sizeof(sysctl_value);
35
+	memset(sysctl_value, 0, sysctl_value_len);
36
+	ret = sysctlbyname(sysctl_name, sysctl_value,
37
+	    &sysctl_value_len, NULL, 0);
38
+	if (ret != 0)
39
+		return (-1);
40
+
41
+	/*
42
+	 * dev.vgapci.$m.%location can have two formats:
43
+	 *     o  "pci0:2:0:0 handle=\_SB_.PCI0.PEG3.MXM3" (FreeBSD 11+)
44
+	 *     o  "slot=1 function=0" (up-to FreeBSD 10)
45
+	 */
46
+
47
+	ret = sscanf(sysctl_value, "pci%d:%d:%d:%d %*s",
48
+	    domain, bus, slot, function);
49
+	if (ret == 4)
50
+		return (0);
51
+
52
+	ret = sscanf(sysctl_value, "slot=%d function=%d %*s",
53
+	    slot, function);
54
+	if (ret != 2)
55
+		return (-1);
56
+
57
+	sprintf(sysctl_name, "dev.vgapci.%d.%%parent", i);
58
+
59
+	sysctl_value_len = sizeof(sysctl_value);
60
+	memset(sysctl_value, 0, sysctl_value_len);
61
+	ret = sysctlbyname(sysctl_name, sysctl_value,
62
+	    &sysctl_value_len, NULL, 0);
63
+	if (ret != 0)
64
+		return (-1);
65
+
66
+	ret = sscanf(sysctl_value, "pci%d", bus);
67
+	if (ret != 1)
68
+		return (-1);
69
+
70
+	/* FIXME: What domain to assume? */
71
+	*domain = 0;
72
+
73
+	return (0);
74
+}
75
+
76
 int
77
 devq_device_get_pciid_from_fd(int fd,
78
     int *vendor_id, int *device_id)
79
@@ -253,38 +305,17 @@ devq_device_get_pciid_from_fd(int fd,
80
 	 *     o  dev.vgapci.$m.%parent
81
 	 */
82
 	for (i = 0; i < DEVQ_MAX_DEVS; ++i) {
83
-		sprintf(sysctl_name, "dev.vgapci.%d.%%location", i);
84
-
85
-		sysctl_value_len = sizeof(sysctl_value);
86
-		memset(sysctl_value, 0, sysctl_value_len);
87
-		ret = sysctlbyname(sysctl_name, sysctl_value,
88
-		    &sysctl_value_len, NULL, 0);
89
-		if (ret != 0)
90
-			continue;
91
+		int tmp_domain, tmp_bus, tmp_slot, tmp_function;
92
 
93
-		int tmp_slot, tmp_function;
94
-		ret = sscanf(sysctl_value, "slot=%d function=%d %*s",
95
+		ret = devq_compare_vgapci_busaddr(i, &tmp_domain, &tmp_bus,
96
 		    &tmp_slot, &tmp_function);
97
-		if (ret != 2 ||
98
-		    tmp_slot != slot || tmp_function != function)
99
-			continue;
100
-
101
-		sprintf(sysctl_name, "dev.vgapci.%d.%%parent", i);
102
-
103
-		sysctl_value_len = sizeof(sysctl_value);
104
-		memset(sysctl_value, 0, sysctl_value_len);
105
-		ret = sysctlbyname(sysctl_name, sysctl_value,
106
-		    &sysctl_value_len, NULL, 0);
107
-		if (ret != 0)
108
-			continue;
109
-
110
-		int tmp_bus;
111
-		ret = sscanf(sysctl_value, "pci%d",
112
-		    &tmp_bus);
113
-		if (ret != 1 || tmp_bus != bus)
114
-			continue;
115
 
116
-		break;
117
+		if (ret == 0 &&
118
+		    tmp_domain == domain &&
119
+		    tmp_bus == bus &&
120
+		    tmp_slot == slot &&
121
+		    tmp_function == function)
122
+			break;
123
 	}
124
 
125
 	if (i == DEVQ_MAX_DEVS) {
(-)devel/libdevq/pkg-plist (+1 lines)
Lines 5-7 Link Here
5
lib/libdevq.so.0
5
lib/libdevq.so.0
6
lib/libdevq.so.0.0.0
6
lib/libdevq.so.0.0.0
7
libdata/pkgconfig/libdevq-1.0.pc
7
libdata/pkgconfig/libdevq-1.0.pc
8
man/man3/libdevq.3.gz

Return to bug 214706