/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <ftw.h>
#include <string.h>
#include <thread.h>
#include <synch.h>
#include <fcntl.h>
#include <strings.h>
#include <libdevinfo.h>
#include "libdevid.h"
/*
* Get Device Id from an open file descriptor
*/
int
{
int len = 0;
return (-1);
/* If not char or block device, then error */
return (-1);
/* Get the device id size */
return (-1);
/* Allocate space to return device id */
return (-1);
/* Get the device id */
return (-1);
}
/* Return the device id copy */
return (0);
}
/*
* Get the minor name
*/
int
{
int len = 0;
int spectype;
char *myminor_name;
return (-1);
/* If not a char or block device, then return an error */
return (-1);
/* Get the minor name size */
return (-1);
/* Allocate space for the minor name */
return (-1);
/* Get the minor name */
return (-1);
}
/* return the minor name copy */
return (0);
}
/* list element of devid_nmlist_t information */
struct nmlist {
char *nl_devname;
};
/* add list element to end of nmlist headed by *nlhp */
struct nmlist *
{
/* stat and get the devt for char or block */
else
/* find the end of the list */
;
/* allocate and initialize new entry */
return (NULL);
return (NULL);
}
/* link new entry at end */
return (nl);
}
/* information needed by devlink_callback to call nmlist_add */
struct devlink_cbinfo {
char *cbi_search_path;
int cbi_error;
};
/* di_devlink callback to add a /dev entry to nmlist */
static int
{
return (DI_WALK_TERMINATE);
}
}
return (DI_WALK_CONTINUE);
}
/*
* Resolve /dev names to DI_PRIMARY_LINK, DI_SECONDARY_LINK, or both.
* The default is to resolve to just the DI_PRIMARY_LINK.
*/
/*
* Options for the devid_deviceid_to_nmlist implementation:
*
* DEVICEID_NMLIST_SLINK - reduce overhead by reuse the previous
* di_devlink_init.
*/
int devid_deviceid_to_nmlist_flg = 0;
/*
* Convert the specified devid/minor_name into a devid_nmlist_t array
* with names that resolve into /devices or /dev depending on search_path.
*
* The man page indicates that:
*
* This function traverses the file tree, starting at search_path.
*
* This is not true, we reverse engineer the paths relative to
* the specified search path to avoid attaching all devices.
*/
int
char *search_path,
char *minor_name,
{
char *cp;
int dev;
char *path;
int lens;
int nret;
int nagain = 0;
int err = 0;
/* verify valid search path starts with "/devices" or "/dev" */
dev = 0;
dev = 1;
else {
return (-1);
}
/* translate devid/minor_name to /devices paths */
goto out;
goto out;
goto again;
}
goto out;
}
/*
* initialize for /devices path to /dev path translation. To reduce
* overhead we reuse the last snapshot if DEVICEID_NMLIST_SLINK is set.
*/
if (dev) {
if (dlh &&
(void) di_devlink_fini(&dlh);
}
goto out;
}
/*
* iterate over all the devtspectype resolutions of the devid and
* convert them into the appropriate path form and add items to return
* to the nmlist list;
*/
if (dev) {
/* add /dev entries */
(void *)&cbi, devlink_callback);
goto out;
} else {
/* add /devices entry */
strlen(search_path)) == 0) {
goto out;
}
}
}
}
/* convert from nmlist to retlist array */
nret++;
if (nret == 0) {
goto out;
}
goto out;
}
}
ret = 0;
out:
}
if (paths)
if (dlh) {
if ((ret == 0) &&
else
(void) di_devlink_fini(&dlh);
}
return (ret);
}
/*
* Free Device Id Name List
*/
void
{
devid_nmlist_t *p = list;
return;
/* Free all the device names */
p++;
}
/* Free the array */
}