1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
'\" te
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH DI_DEVLINK_WALK 3DEVINFO "May 15, 2008"
.SH NAME
di_devlink_walk \- walk through links in a devlink snapshot
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-ldevinfo\fR [ \fIlibrary\fR... ]
#include <libdevinfo.h>
\fBint\fR \fBdi_devlink_walk\fR(\fBdi_devlink_handle_t\fR \fIhdl\fR,\fBconst char *\fR\fIre\fR,
\fBconst char *\fR\fImpath\fR, \fBuint_t\fR \fIflags\fR, \fBvoid *\fR\fIarg\fR,
\fBint\fR (*\fIdevlink_callback\fR)(\fBdi_devlink_t\fR \fIdevlink\fR, \fBvoid *\fR\fIarg\fR));
.fi
.SH PARAMETERS
.sp
.ne 2
.na
\fB\fIhdl\fR\fR
.ad
.RS 11n
A handle to a snapshot of devlinks in "\fB/dev\fR".
.RE
.sp
.ne 2
.na
\fB\fIre\fR\fR
.ad
.RS 11n
An extended regular expression as specified in \fBregex\fR(5) describing the
paths of devlinks to visit. A null value matches all devlinks. The expression
should not involve the "\fB/dev\fR" prefix. For example, the "^\fBdsk/\fR" will
invoke \fIdevlink_callback\fR() for all "\fB/dev/dsk/\fR" links.
.RE
.sp
.ne 2
.na
\fB\fImpath\fR\fR
.ad
.RS 11n
A path to a minor node below "\fB/devices\fR" for which "\fB/dev\fR" links are
to be looked up. A null value selects all devlinks. This path should not have
a "\fB/devices\fR" prefix.
.RE
.sp
.ne 2
.na
\fB\fIflags\fR\fR
.ad
.RS 11n
Specify the type of devlinks to be selected. If \fBDI_PRIMARY_LINK\fR is used,
only primary links (for instance, links which point only to "\fB/devices\fR"
entries) are selected. If \fBDI_SECONDARY_LINK\fR is specified, only secondary
links (for instance, devlinks which point to other devlinks) are selected. If
neither flag is specified, all devlinks are selected.
.RE
.sp
.ne 2
.na
\fB\fIarg\fR\fR
.ad
.RS 11n
A pointer to caller private data.
.RE
.sp
.ne 2
.na
\fB\fIdevlink\fR\fR
.ad
.RS 11n
The devlink being visited.
.RE
.SH DESCRIPTION
.sp
.LP
The \fBdi_devlink_walk()\fR function visits every link in the snapshot that
meets the criteria specified by the caller. For each such devlink, the
caller-supplied function \fIdevlink_callback\fR() is invoked. The return value
of \fIdevlink_callback\fR() determines subsequent walk behavior.
.SH RETURN VALUES
.sp
.LP
Upon success, the \fBdi_devlink_walk()\fR function returns 0. Otherwise, -1 is
returned and \fBerrno\fR is set to indicate the error.
.sp
.LP
The \fIdevlink_callback\fR() function can return the following values:
.sp
.ne 2
.na
\fB\fBDI_WALK_CONTINUE\fR\fR
.ad
.RS 21n
Continue walking.
.RE
.sp
.ne 2
.na
\fB\fBDI_WALK_TERMINATE\fR\fR
.ad
.RS 21n
Terminate the walk immediately.
.RE
.SH ERRORS
.sp
.LP
The \fBdevlink_callback()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
One or more arguments is invalid.
.RE
.sp
.ne 2
.na
\fB\fBENOMEM\fR\fR
.ad
.RS 10n
Insufficient memory is available.
.RE
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
_
MT-Level Safe
.TE
.SH SEE ALSO
.sp
.LP
\fBdi_devlink_init\fR(3DEVINFO), \fBdi_devlink_path\fR(3DEVINFO),
\fBlibdevinfo\fR(3LIB), \fBmalloc\fR(3C), \fBattributes\fR(5), \fBregex\fR(5)
|