summaryrefslogtreecommitdiff
path: root/usr/src/cmd/devfsadm/devfsadm.c
diff options
context:
space:
mode:
authorpjha <none@none>2006-08-21 20:11:18 -0700
committerpjha <none@none>2006-08-21 20:11:18 -0700
commit3c4226f98775d47a05fa88f9f72479f1a250eaa5 (patch)
tree2268348f795a468ab405cce9cd8121f280ba5a7b /usr/src/cmd/devfsadm/devfsadm.c
parent3247dfed200428da80007948dc664da0d2b81bac (diff)
downloadillumos-joyent-3c4226f98775d47a05fa88f9f72479f1a250eaa5.tar.gz
6425514 Invalid slot number message on FF2 could be hardware programming issue
6436776 Link Up/Down events should be expected events during Oberon hotplug operations 6439953 Identical Slot names in different segments can cause a breakage in ApId scheme 6460150 Booting OPL system with build 46 panics w/ MONDO 62 for DMC/PEC 6460200 OPL Hotplug should use existing PCI Cap Library 6460204 PCI Cap Library should avoid name space collision for pci_config_size_t
Diffstat (limited to 'usr/src/cmd/devfsadm/devfsadm.c')
-rw-r--r--usr/src/cmd/devfsadm/devfsadm.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/usr/src/cmd/devfsadm/devfsadm.c b/usr/src/cmd/devfsadm/devfsadm.c
index 9b719ac04c..67a46fad15 100644
--- a/usr/src/cmd/devfsadm/devfsadm.c
+++ b/usr/src/cmd/devfsadm/devfsadm.c
@@ -6931,6 +6931,60 @@ devfsadm_root_path(void)
}
}
+void
+devfsadm_free_dev_names(char **dev_names, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ free(dev_names[i]);
+ free(dev_names);
+}
+
+/*
+ * Return all devlinks corresponding to phys_path as an array of strings.
+ * The number of entries in the array is returned through lenp.
+ * devfsadm_free_dev_names() is used to free the returned array.
+ * NULL is returned on failure or when there are no matching devlinks.
+ *
+ * re is an extended regular expression in regex(5) format used to further
+ * match devlinks pointing to phys_path; it may be NULL to match all
+ */
+char **
+devfsadm_lookup_dev_names(char *phys_path, char *re, int *lenp)
+{
+ struct devlink_cb_arg cb_arg;
+ char **dev_names = NULL;
+ int i;
+
+ *lenp = 0;
+ cb_arg.count = 0;
+ cb_arg.rv = 0;
+ (void) di_devlink_cache_walk(devlink_cache, re, phys_path,
+ DI_PRIMARY_LINK, &cb_arg, devlink_cb);
+
+ if (cb_arg.rv == -1 || cb_arg.count <= 0)
+ return (NULL);
+
+ dev_names = s_malloc(cb_arg.count * sizeof (char *));
+ if (dev_names == NULL)
+ goto out;
+
+ for (i = 0; i < cb_arg.count; i++) {
+ dev_names[i] = s_strdup(cb_arg.dev_names[i]);
+ if (dev_names[i] == NULL) {
+ devfsadm_free_dev_names(dev_names, i);
+ dev_names = NULL;
+ goto out;
+ }
+ }
+ *lenp = cb_arg.count;
+
+out:
+ free_dev_names(&cb_arg);
+ return (dev_names);
+}
+
/* common exit function which ensures releasing locks */
static void
devfsadm_exit(int status)