'\" 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 \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(7) 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(7) 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 .BR malloc (3C), .BR di_devlink_init (3DEVINFO), .BR di_devlink_path (3DEVINFO), .BR libdevinfo (3LIB), .BR attributes (7), .BR regex (7)