/* * The functions in this file do a dev tree walk to build up a model of the * disks, controllers and paths on the system. This model is returned in the * args->disk_listp and args->controller_listp members of the args param. * There is no global data for this file so it is thread safe. It is up to * the caller to merge the resulting model with any existing model that is * cached. The caller must also free the memory for this model when it is * no longer needed. */ void findevs(struct search_args *args) { di_node_t di_root; args->bus_listp = NULL; args->controller_listp = NULL; args->disk_listp = NULL; args->dev_walk_status = 0; args->handle = di_devlink_init(NULL, 0); /* * Have to make several passes at this with the new devfs caching. * First, we find non-mpxio devices. Then we find mpxio/multipath * devices. */ di_root = di_init("/", DINFOCACHE); args->ph = di_prom_init(); (void) di_walk_minor(di_root, NULL, 0, args, add_devs); di_fini(di_root); di_root = di_init("/", DINFOCPYALL|DINFOPATH); (void) di_walk_minor(di_root, NULL, 0, args, add_devs); di_fini(di_root); (void) di_devlink_fini(&(args->handle)); clean_paths(args); }
/* * Primary function for DI APSP. */ void di_apsp(int n, float* dist, float* graph, int* p, int* q, std::vector<int>* L, std::vector<int>* R, std::list<int>* bucket_heap, int* b_num, std::list<int>::iterator* iters) { // Initialize di_init(n, dist, graph, p, q, L, R, bucket_heap, b_num, iters); int u, v, pair; //Main loop while (1) { // Get min (u,v) pair from the heap. // Break the loop if heap was empty. pair = heap_extract(bucket_heap, b_num, n, iters); if (pair < 0) break; u = pair/n; v = pair%n; // Add to relevant lists L[p[u*n + v]*n + v].push_back(u); R[u*n + q[u*n + v]].push_back(v); // Examine through the lists. di_lists(n, u, v, dist, graph, p, q, L, R, bucket_heap, b_num, iters); } }
/* * Handle DR events. Only supports cpu add and remove. */ int update_devices(char *dev, int op) { di_node_t di_root; if ((di_root = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) return (PICL_FAILURE); if ((ph = di_prom_init()) == NULL) return (PICL_FAILURE); if (op == DEV_ADD) { if (strcmp(dev, OBP_CPU) == 0) add_cpus(di_root); } if (op == DEV_REMOVE) { if (strcmp(dev, OBP_CPU) == 0) remove_cpus(di_root); } di_fini(di_root); di_prom_fini(ph); return (PICL_SUCCESS); }
void mouse_init() { // Initialize queue if ( mouse_inited ) return; mouse_inited = 1; InitializeCriticalSection( &mouse_lock ); ENTER_CRITICAL_SECTION(&mouse_lock); mouse_flags = 0; Mouse_x = gr_screen.max_w / 2; Mouse_y = gr_screen.max_h / 2; #ifdef USE_DIRECTINPUT if (!di_init()) Mouse_mode = MOUSE_MODE_WIN; #else Mouse_mode = MOUSE_MODE_WIN; #endif LEAVE_CRITICAL_SECTION(&mouse_lock); atexit( mouse_close ); }
/* * The following boot properties can be used to configure a network * interface in the case of a diskless boot. * host-ip, subnet-mask, server-path, server-name, server-ip. * * XXX non-diskless case requires "network-interface"? */ static boolean_t boot_properties_present() { /* XXX should use sys/bootprops.h, but it's not delivered */ const char *required_properties[] = { "host-ip", "subnet-mask", "server-path", "server-name", "server-ip", NULL, }; const char **prop = required_properties; char *prop_value; di_node_t dn; if ((dn = di_init("/", DINFOPROP)) == DI_NODE_NIL) { (void) fprintf(stderr, "%s: di_init: %s\n", program, strerror(errno)); di_fini(dn); return (B_FALSE); } while (*prop != NULL) { if (di_prop_lookup_strings(DDI_DEV_T_ANY, dn, *prop, &prop_value) != 1) { di_fini(dn); return (B_FALSE); } prop++; } di_fini(dn); return (B_TRUE); }
static int destroy_console_devs(zlog_t *zlogp) { char conspath[MAXPATHLEN]; di_node_t root; struct cb_data cb; int masterfd; int slavefd; /* * Signal the master side to release its handle on the slave side by * issuing a ZC_RELEASESLAVE ioctl. */ (void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s", zone_name, ZCONS_MASTER_NAME); if ((masterfd = open(conspath, O_RDWR | O_NOCTTY)) != -1) { (void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s", zone_name, ZCONS_SLAVE_NAME); if ((slavefd = open(conspath, O_RDWR | O_NOCTTY)) != -1) { if (ioctl(masterfd, ZC_RELEASESLAVE, (caddr_t)(intptr_t)slavefd) != 0) zerror(zlogp, B_TRUE, "WARNING: error while " "releasing slave handle of zone console for" " %s", zone_name); (void) close(slavefd); } else { zerror(zlogp, B_TRUE, "WARNING: could not open slave " "side of zone console for %s to release slave " "handle", zone_name); } (void) close(masterfd); } else { zerror(zlogp, B_TRUE, "WARNING: could not open master side of " "zone console for %s to release slave handle", zone_name); } bzero(&cb, sizeof (cb)); cb.zlogp = zlogp; if ((root = di_init(ZCONSNEX_DEVTREEPATH, DINFOCPYALL)) == DI_NODE_NIL) { zerror(zlogp, B_TRUE, "%s failed", "di_init"); return (-1); } (void) di_walk_node(root, DI_WALK_CLDFIRST, (void *)&cb, destroy_cb); if (cb.found > 1) { zerror(zlogp, B_FALSE, "WARNING: multiple zone console " "instances detected for zone '%s'; %d of %d " "successfully removed.", zone_name, cb.killed, cb.found); } di_fini(root); return (0); }
void devinfo_add(HalDevice *parent, gchar *path) { di_node_t root; if (strcmp (path, "/") == 0) { if ((root = di_init(path, DINFOCACHE)) == DI_NODE_NIL) { HAL_INFO (("di_init() failed %d", errno)); return; } } else { if ((root = di_init(path, DINFOCPYALL)) == DI_NODE_NIL) { HAL_INFO (("di_init() failed %d", errno)); return; } } devinfo_add_subtree(parent, root, TRUE); di_fini (root); }
PUSBDEVICE USBProxyServiceSolaris::getDevices(void) { USBDEVICELIST DevList; DevList.pHead = NULL; DevList.pTail = NULL; di_node_t RootNode = di_init("/", DINFOCPYALL); if (RootNode != DI_NODE_NIL) di_walk_node(RootNode, DI_WALK_CLDFIRST, &DevList, solarisWalkDeviceNode); di_fini(RootNode); return DevList.pHead; }
/* * Walk all "service" device nodes to find the one with the * matching glvc minor name */ static char * svc_name_to_glvc_dev_path(char *service) { di_node_t root_node, service_node; char *glvc_path; char *minor_name; di_minor_t minor; char *dev_path = NULL; if (service == NULL) return (NULL); /* Get device node */ root_node = di_init("/", DINFOCPYALL); if (root_node == DI_NODE_NIL) { return (dev_path); } service_node = di_drv_first_node("glvc", root_node); while (service_node != DI_NODE_NIL) { /* Make sure node name matches service name */ if (strcmp(service, di_node_name(service_node)) == 0) { /* Walk minor nodes */ minor = di_minor_next(service_node, DI_NODE_NIL); while (minor != DI_NODE_NIL) { glvc_path = di_devfs_minor_path(minor); minor_name = di_minor_name(minor); if (strcmp(minor_name, "glvc") == 0) { dev_path = malloc(strlen(glvc_path) + strlen(DEVICES_DIR) + 1); (void) strcpy(dev_path, DEVICES_DIR); (void) strcat(dev_path, glvc_path); di_devfs_path_free(glvc_path); break; } di_devfs_path_free(glvc_path); minor = di_minor_next(service_node, minor); } } if (dev_path != NULL) break; service_node = di_drv_next_node(service_node); } di_fini(root_node); return (dev_path); }
/* * The rule for scsi disks uses this to determine if the /devices * entry corresponds to a cdrom drive. Use libdevinfo to walk * the device tree: * calling find_cd_nodes() for each minor node of type DDI_NT_CD. * calling find_sd_nodes() for each minor node of type DDI_NT_BLOCK_CHAN. */ static void find_cdsd(void) { di_node_t root_node; root_node = di_init("/", DINFOSUBTREE|DINFOMINOR); if (root_node == DI_NODE_NIL) { return; } di_walk_minor(root_node, DDI_NT_CD, 0, NULL, find_cd_nodes); di_walk_minor(root_node, DDI_NT_BLOCK_CHAN, 0, NULL, find_sd_nodes); di_fini(root_node); }
/* * checks if a fru is present under location using pdev-path and busaddr */ boolean_t is_fru_present_under_location(frutree_locnode_t *locp) { di_node_t rnode; frutree_devinfo_t *devinfo = NULL; char probe_path[PICL_PROPNAMELEN_MAX]; if (locp == NULL) { return (B_FALSE); } if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_PROBE_PATH, probe_path, sizeof (probe_path)) != PICL_SUCCESS) { if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_DEVFS_PATH, probe_path, sizeof (probe_path)) != PICL_SUCCESS) { return (B_FALSE); } } rnode = di_init(probe_path, DINFOSUBTREE); if (rnode == DI_NODE_NIL) { di_fini(rnode); return (B_FALSE); } devinfo = (frutree_devinfo_t *)malloc(sizeof (frutree_devinfo_t)); if (devinfo == NULL) { di_fini(rnode); return (B_FALSE); } devinfo->rnode = rnode; devinfo->arg = (frutree_locnode_t **)&locp; devinfo->retval = PICL_FAILURE; if (di_walk_node(rnode, DI_WALK_SIBFIRST, &devinfo, find_fru_node) != 0) { di_fini(rnode); free(devinfo); return (B_FALSE); } di_fini(rnode); if (devinfo->retval == PICL_SUCCESS) { free(devinfo); return (B_TRUE); } else { free(devinfo); return (B_FALSE); } }
static void read_nodedesc() { int i; if ((di_rootnode = di_init("/", DINFOCPYALL | DINFOFORCE)) == DI_NODE_NIL) { IBERROR("read_nodedesc di_init failure"); return; } for (i = 0; ib_hca_driver_list[i]; i++) do_driver_read_ioctl(ib_hca_driver_list[i]); di_fini(di_rootnode); }
/* * Attempt to access PCI subsystem using Solaris's devfs interface. * Solaris version */ _pci_hidden int pci_system_solx_devfs_create( void ) { int err = 0; di_node_t di_node; probe_info_t pinfo; struct pci_device_private *devices; if (nexus_list != NULL) { return 0; } if ((di_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) { err = errno; (void) fprintf(stderr, "di_init() failed: %s\n", strerror(errno)); return (err); } if ((devices = calloc(INITIAL_NUM_DEVICES, sizeof (struct pci_device_private))) == NULL) { err = errno; di_fini(di_node); return (err); } #ifdef __sparc if ((di_phdl = di_prom_init()) == DI_PROM_HANDLE_NIL) (void) fprintf(stderr, "di_prom_init failed: %s\n", strerror(errno)); #endif pinfo.num_allocated_elems = INITIAL_NUM_DEVICES; pinfo.num_devices = 0; pinfo.devices = devices; (void) di_walk_minor(di_node, DDI_NT_REGACC, 0, &pinfo, probe_nexus_node); di_fini(di_node); if ((pci_sys = calloc(1, sizeof (struct pci_system))) == NULL) { err = errno; free(devices); return (err); } pci_sys->methods = &solx_devfs_methods; pci_sys->devices = pinfo.devices; pci_sys->num_devices = pinfo.num_devices; return (err); }
/* * During each register callback: totally rebuild the group list from a new * libdevinfo snapshot, and then update the registrants. */ static int mpxio_register(rcm_handle_t *hdl) { int nclients = 0; di_node_t devroot; rcm_log_message(RCM_TRACE1, "MPXIO: register()\n"); (void) mutex_lock(&mpxio_lock); /* Destroy the previous group list */ free_grouplist(); /* Get a current libdevinfo snapshot */ if ((devroot = di_init("/", DINFOCPYALL | DINFOPATH)) == DI_NODE_NIL) { rcm_log_message(RCM_ERROR, "MPXIO: libdevinfo initialization failed (%s).\n", strerror(errno)); (void) mutex_unlock(&mpxio_lock); return (RCM_FAILURE); } /* * First count the total number of clients. This'll be a useful * upper bound when allocating client arrays within each group. */ (void) di_walk_node(devroot, DI_WALK_CLDFIRST, &nclients, get_nclients); rcm_log_message(RCM_TRACE2, gettext("MPXIO: found %d clients.\n"), nclients); /* * Then walk the libdevinfo snapshot, building up the new group list * along the way. Pass in the total number of clients (from above) to * assist in group construction. */ (void) di_walk_node(devroot, DI_WALK_CLDFIRST, &nclients, build_groups); /* Now with a new group list constructed, refresh the registrants */ refresh_regs(hdl); /* Free the libdevinfo snapshot */ di_fini(devroot); (void) mutex_unlock(&mpxio_lock); return (0); }
void key_init() { // Initialize queue if (key_inited) return; key_inited = 1; INITIALIZE_CRITICAL_SECTION(key_lock); ENTER_CRITICAL_SECTION(key_lock); #ifdef SCP_UNIX FillSDLArray(); #endif keyd_time_when_last_pressed = timer_get_milliseconds(); keyd_buffer_type = 1; keyd_repeat = 1; // Clear the keyboard array key_flush(); // Clear key filter key_clear_filter(); LEAVE_CRITICAL_SECTION(key_lock); #ifdef _WIN32 #ifdef USE_DIRECTINPUT di_init(); #endif OSVERSIONINFO ver; ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&ver); if ( ver.dwPlatformId == VER_PLATFORM_WIN32_NT ) { Key_running_NT = 1; } else { Key_running_NT = 0; if ( key_numlock_is_on() ) { Key_numlock_was_on = 1; key_turn_off_numlock(); } } #endif atexit(key_close); }
/* * Take a snapshot of the device tree, i.e. get a devinfo handle and * a PROM handle. */ static boolean_t snapshot_devtree(void) { /* * Deallocate any existing devinfo stuff first. */ destroy_snapshot(); if ((root_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL || (phdl = di_prom_init()) == DI_PROM_HANDLE_NIL) { destroy_snapshot(); return (B_FALSE); } return (B_TRUE); }
int rtc_get(struct rtc_time *tmp) { unsigned long now; int rc = 0; if (!data.init_done) { rc = di_init(); if (rc) goto err; } now = __raw_readl(&data.regs->dtcmr); rtc_to_tm(now, tmp); err: return rc; }
static int getnameinst(char *path, int *instance, char *name, int namelen) { di_node_t node; char *driver_name; if ((node = di_init(&path[8], DINFOSUBTREE)) == DI_NODE_NIL) return (-1); if ((driver_name = di_driver_name(node)) == NULL) { di_fini(node); return (-1); } *instance = di_instance(node); (void) strncpy(name, driver_name, namelen); di_fini(node); return (0); }
/* * cycles through the global list of plugins to find * each flashable device, which is added to fw_devices * * Each plugin's identify routine must allocated storage * as required. * * Each plugin's identify routine must return * FWFLASH_FAILURE if it cannot find any devices * which it handles. */ static int flash_device_list() { int rv = FWFLASH_FAILURE; int startidx = 0; int sumrv = 0; struct pluginlist *plugins; /* we open rootnode here, and close it in fwflash_intr */ if ((rootnode = di_init("/", DINFOCPYALL|DINFOFORCE)) == DI_NODE_NIL) { logmsg(MSG_ERROR, gettext("Unable to take device tree snapshot: %s\n"), strerror(errno)); return (rv); } if ((fw_devices = calloc(1, sizeof (struct devicelist))) == NULL) { logmsg(MSG_ERROR, gettext("Unable to malloc %d bytes while " "trying to find devices: %s\n"), sizeof (struct devicelist), strerror(errno)); return (FWFLASH_FAILURE); } /* CONSTCOND */ TAILQ_INIT(fw_devices); TAILQ_FOREACH(plugins, fw_pluginlist, nextplugin) { self = plugins->plugin; rv = plugins->plugin->fw_identify(startidx); logmsg(MSG_INFO, gettext("fwflash:flash_device_list() got %d from " "identify routine\n"), rv); /* only bump startidx if we've found at least one device */ if (rv == FWFLASH_SUCCESS) { startidx += 100; sumrv++; } else { logmsg(MSG_INFO, gettext("No flashable devices attached with " "the %s driver in this system\n"), plugins->drvname); } }
/* * Walk all vldc device nodes to find the one with the * matching minor name */ static char * svc_name_to_vldc_dev_path(char *service) { di_node_t root_node, vldc_node; char *vldc_path; char *minor_name; di_minor_t minor; char *dev_path = NULL; /* Get device node */ root_node = di_init("/", DINFOCPYALL); if (root_node == DI_NODE_NIL) { return (dev_path); } vldc_node = di_drv_first_node("vldc", root_node); while (vldc_node != DI_NODE_NIL) { /* Walk minor nodes */ minor = di_minor_next(vldc_node, DI_NODE_NIL); while (minor != DI_NODE_NIL) { vldc_path = di_devfs_minor_path(minor); minor_name = di_minor_name(minor); if (strcmp(minor_name, service) == 0) { dev_path = malloc(strlen(vldc_path) + strlen(DEVICES_DIR) + 1); (void) strcpy(dev_path, DEVICES_DIR); (void) strcat(dev_path, vldc_path); di_devfs_path_free(vldc_path); break; } di_devfs_path_free(vldc_path); minor = di_minor_next(vldc_node, minor); } if (dev_path != NULL) break; vldc_node = di_drv_next_node(vldc_node); } di_fini(root_node); return (dev_path); }
static int count_zfd_devs(zlog_t *zlogp) { di_node_t root; struct cb_data cb; bzero(&cb, sizeof (cb)); cb.zlogp = zlogp; if ((root = di_init(ZFDNEX_DEVTREEPATH, DINFOCPYALL)) == DI_NODE_NIL) { zerror(zlogp, B_TRUE, "di_init failed"); return (-1); } (void) di_walk_node(root, DI_WALK_CLDFIRST, (void *)&cb, count_cb); di_fini(root); return (cb.found); }
int sunos_get_active_config_descriptor(struct libusb_device *dev, uint8_t *buf, size_t len, int *host_endian) { sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv; struct libusb_config_descriptor *cfg; int proplen; di_node_t node; uint8_t *rdata; /* * Keep raw configuration descriptors updated, in case config * has ever been changed through setCfg. */ if ((node = di_init(dpriv->phypath, DINFOCPYALL)) == DI_NODE_NIL) { usbi_dbg("di_int() failed: %s", strerror(errno)); return (LIBUSB_ERROR_IO); } proplen = di_prop_lookup_bytes(DDI_DEV_T_ANY, node, "usb-raw-cfg-descriptors", &rdata); if (proplen <= 0) { usbi_dbg("can't find raw config descriptors"); return (LIBUSB_ERROR_IO); } dpriv->raw_cfgdescr = realloc(dpriv->raw_cfgdescr, proplen); if (dpriv->raw_cfgdescr == NULL) { return (LIBUSB_ERROR_NO_MEM); } else { bcopy(rdata, dpriv->raw_cfgdescr, proplen); dpriv->cfgvalue = ((struct libusb_config_descriptor *) rdata)->bConfigurationValue; } di_fini(node); cfg = (struct libusb_config_descriptor *)dpriv->raw_cfgdescr; len = MIN(len, libusb_le16_to_cpu(cfg->wTotalLength)); memcpy(buf, dpriv->raw_cfgdescr, len); *host_endian = 0; usbi_dbg("path:%s len %d", dpriv->phypath, len); return (len); }
static void get_phci_driver_name(char *phci_path, char **driver_name) { di_node_t phci_node = DI_NODE_NIL; char *tmp = NULL; phci_node = di_init(phci_path, DINFOCPYONE); if (phci_node == DI_NODE_NIL) { logmsg(MSG_ERROR, gettext("Unable to take phci snapshot " "(%s: %d)\n"), strerror(errno), errno); return; } tmp = di_driver_name(phci_node); if (tmp != NULL) { (void) strncpy(*driver_name, tmp, 10); } di_fini(phci_node); }
/* * Force all "network" drivers to be loaded. * * Returns: ICFG_SUCCESS or ICFG_FAILURE. In the case of * ICFG_FAILURE, syserr will contain the errno. */ static int nic_load_drivers(int *syserr) { di_node_t root_node; di_prom_handle_t ph; int ret; root_node = di_init(NIC_DEVTREE_ROOT, DINFOCPYALL); if (root_node == DI_NODE_NIL) { *syserr = errno; return (ICFG_FAILURE); } /* * Create handle to PROM */ if ((ph = di_prom_init()) == DI_PROM_HANDLE_NIL) { *syserr = errno; di_fini(root_node); return (ICFG_FAILURE); } /* * Walk nodes and make sure all network devices have * drivers loaded so that devinfo has accurate data. */ ret = di_walk_node(root_node, DI_WALK_CLDFIRST, ph, process_node); if (ret != 0) { *syserr = errno; di_prom_fini(ph); di_fini(root_node); return (ICFG_FAILURE); } /* * Clean up handles */ di_prom_fini(ph); di_fini(root_node); return (ICFG_SUCCESS); }
void mouse_init() { // Initialize queue if ( mouse_inited ) return; mouse_inited = 1; INITIALIZE_CRITICAL_SECTION( mouse_lock ); ENTER_CRITICAL_SECTION( mouse_lock ); mouse_flags = 0; Mouse_x = gr_screen.max_w / 2; Mouse_y = gr_screen.max_h / 2; #ifdef WIN32 if (Cmdline_no_di_mouse) { Mouse_mode = MOUSE_MODE_WIN; } else { if (!di_init() || Cmdline_window || Cmdline_fullscreen_window) Mouse_mode = MOUSE_MODE_WIN; else Mouse_mode = MOUSE_MODE_DI; } #else Mouse_mode = MOUSE_MODE_WIN; #endif #ifdef SCP_UNIX // we poll for mouse motion events so be sure to skip those in normal event polling SDL_EventState( SDL_MOUSEMOTION, SDL_IGNORE ); // we do want to make sure that button presses go through event polling though // (should be on by default already, just here as a reminder) SDL_EventState( SDL_MOUSEBUTTONDOWN, SDL_ENABLE ); SDL_EventState( SDL_MOUSEBUTTONUP, SDL_ENABLE ); #endif LEAVE_CRITICAL_SECTION( mouse_lock ); atexit( mouse_close ); }
/*ARGSUSED*/ static void * attach_devices(void *arg) { di_node_t root_node; sleep(60); /* let booting finish first */ if ((root_node = di_init("/", DINFOFORCE)) == DI_NODE_NIL) { logerror("Failed to attach devices."); return (NULL); } di_fini(root_node); /* * Unload all the modules. */ (void) modctl(MODUNLOAD, 0); return (NULL); }
int rtc_set(struct rtc_time *tmp) { unsigned long now; int rc; if (!data.init_done) { rc = di_init(); if (rc) goto err; } now = rtc_mktime(tmp); /* zero the fractional part first */ rc = DI_WRITE_WAIT(0, dtclr); if (rc == 0) rc = DI_WRITE_WAIT(now, dtcmr); err: return rc; }
static int chk_minors(led_dtls_t *dtls) { /* * sets disk_ready flags for disks with minor devices (attached) * returns 1 if any flags have changed else 0 */ int err = 0; int r = 0; di_node_t tree = di_init("/", DINFOCPYALL); if (tree == DI_NODE_NIL) { err = errno; SYSLOG(LOG_ERR, EM_DI_INIT_FAIL, mystrerror(err)); } if (err == 0) r = walk_disks(tree, dtls); if (tree != DI_NODE_NIL) di_fini(tree); return (r); }
/* * Drives the walk of the network minor device nodes to * build the niclist. * * Returns: ICFG_SUCCESS or ICFG_FAILURE. In the case of * ICFG_FAILURE, syserr will contain the errno. */ static int nic_build_list(niclist_t **niclist, int *numif, int *syserr) { wlkreq_t request; di_node_t root_node; int err = ICFG_SUCCESS; int ret; root_node = di_init(NIC_DEVTREE_ROOT, DINFOSUBTREE | DINFOMINOR); if (root_node == DI_NODE_NIL) { *syserr = errno; return (ICFG_FAILURE); } /* * di_walk_minor() only allows one arg to be passed to walker. */ request.wr_niclist = niclist; request.wr_numif = numif; request.wr_syserr = syserr; request.wr_err = &err; ret = di_walk_minor(root_node, DDI_NT_NET, DI_CHECK_ALIAS, &request, nic_process_minor_nodes); if (ret != 0) { *syserr = errno; di_fini(root_node); return (ICFG_FAILURE); } /* * On error, free the partially formed list. */ if (err != ICFG_SUCCESS) { nic_free_list(*niclist); *numif = 0; } di_fini(root_node); return (err); }
static picl_errno_t load_drivers(char *path) { di_node_t rnode; if (path == NULL) { return (PICL_INVALIDARG); } rnode = di_init(path, DINFOSUBTREE|DINFOMINOR); if (rnode == DI_NODE_NIL) { return (PICL_FAILURE); } if (di_walk_node(rnode, DI_WALK_CLDFIRST, NULL, load_driver) != 0) { di_fini(rnode); return (PICL_FAILURE); } di_fini(rnode); return (PICL_SUCCESS); }