/* * 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); }
/* * 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); }
/* * 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); } }
/* * 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); }
/* * 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); }
/* * Called by di_walk_node() to walk the list of device nodes and * force all nodes of type "network" to be loaded. * * Returns: DI_WALK_CONTINUE */ static int process_node(di_node_t node, void *arg) { di_prom_handle_t ph = (di_prom_handle_t)arg; char *pdevtype; int ret; /* * Only want to process nodes whose device_type is "network". */ ret = di_prom_prop_lookup_strings(ph, node, "device_type", &pdevtype); if ((ret <= 0) || (strcmp(pdevtype, "network") != 0)) { return (DI_WALK_CONTINUE); } /* * If the instance is '-1', then the driver for the device * has not been loaded - so force it to be loaded. Ignore * errors loading the driver. */ if (di_instance(node) == -1) { node = di_init_driver(di_driver_name(node), 0); if (node != DI_NODE_NIL) { di_fini(node); } } return (DI_WALK_CONTINUE); }
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); }
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); }
/* * 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); }
/* * 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); }
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; }
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); }
int sunos_get_device_list(struct libusb_context * ctx, struct discovered_devs **discdevs) { di_node_t root_node; struct node_args args; di_devlink_handle_t devlink_hdl; args.ctx = ctx; args.discdevs = discdevs; args.last_ugenpath = NULL; if ((root_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) { usbi_dbg("di_int() failed: %s", strerror(errno)); return (LIBUSB_ERROR_IO); } if ((devlink_hdl = di_devlink_init(NULL, 0)) == NULL) { di_fini(root_node); usbi_dbg("di_devlink_init() failed: %s", strerror(errno)); return (LIBUSB_ERROR_IO); } args.dlink_hdl = devlink_hdl; /* walk each node to find USB devices */ if (di_walk_node(root_node, DI_WALK_SIBFIRST, &args, sunos_walk_minor_node_link) == -1) { usbi_dbg("di_walk_node() failed: %s", strerror(errno)); di_fini(root_node); return (LIBUSB_ERROR_IO); } di_fini(root_node); di_devlink_fini(&devlink_hdl); usbi_dbg("%d devices", (*discdevs)->len); return ((*discdevs)->len); }
/* * 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); }
/* * Deallocate devinfo stuff. */ static void destroy_snapshot(void) { if (phdl != DI_PROM_HANDLE_NIL) { di_prom_fini(phdl); } phdl = DI_PROM_HANDLE_NIL; if (root_node != DI_NODE_NIL) { di_fini(root_node); } root_node = DI_NODE_NIL; }
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); }
static int getpath(char *path, int instance, char *name, int pathlen) { di_node_t node; struct walk_arg warg; warg.instance = instance; (void) strncpy(warg.name, name, MAXPATHLEN); warg.path = path; warg.pathlen = pathlen; warg.found = 0; if ((node = di_init("/", DINFOSUBTREE)) == DI_NODE_NIL) return (-1); if (di_walk_node(node, DI_WALK_CLDFIRST, &warg, walk_callback) == -1) { di_fini(node); return (-1); } if (warg.found == 0) { di_fini(node); return (-1); } di_fini(node); return (0); }
static int device_tree_to_md(mmd_t *mdp, md_node_t *top) { di_node_t node; di_node_t root; di_prom_handle_t ph; int rv = 0; root = di_init("/", DINFOSUBTREE | DINFOPROP); if (root == DI_NODE_NIL) { LDMA_ERR("di_init cannot find device tree root node."); return (errno); } ph = di_prom_init(); if (ph == DI_PROM_HANDLE_NIL) { LDMA_ERR("di_prom_init failed."); di_fini(root); return (errno); } node = di_child_node(root); while (node != NULL) { if (is_root_complex(ph, node)) { rv = create_children(mdp, ph, top, node); if (rv != 0) break; } node = di_sibling_node(node); } di_prom_fini(ph); di_fini(root); return (rv); }
/* * 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); }
/* * 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); }
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); }
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); }
/*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); }
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); }
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); }
/* * Don't use devfs if stat() in /devices fails. Use libdevinfo instead. * Retired devices don't show up in devfs. * * Returns: * 1 - minor exists and is of type BLK * 0 - minor does not exist or is not of type BLK. */ static int is_devinfo_blk(char *minor_path) { char *minor_portion; struct chk_dev chk_dev; di_node_t node; int rv; /* * prune minor path for di_init() - no /devices prefix and no minor name */ if (strncmp(minor_path, "/devices/", strlen("/devices/")) != 0) return (0); minor_portion = strrchr(minor_path, *MINOR_SEP); if (minor_portion == NULL) return (0); *minor_portion = 0; node = di_init(minor_path + strlen("/devices"), DINFOMINOR); *minor_portion = *MINOR_SEP; if (node == DI_NODE_NIL) return (0); chk_dev.c_isblk = 0; chk_dev.c_minor = minor_portion + 1; rv = di_walk_minor(node, NULL, 0, &chk_dev, chk_dev_fcn); di_fini(node); if (rv == 0 && chk_dev.c_isblk) return (1); else return (0); }
int main() { di_node_t root_node; int fd; if ((fd = open("/tmp/bootparams", O_RDONLY)) != -1) { /* If this file exists it acts as a replacement for the normal data */ raw_cat(fd); close(fd); } else { /* We didn't have or couldn't open the file, so just get actual params */ root_node = di_init("/", (DINFOSUBTREE | DINFOPROP)); if (root_node == DI_NODE_NIL) { fprintf(stderr, "di_init() failed\n"); exit(1); } di_walk_node(root_node, DI_WALK_CLDFIRST, NULL, prt_node); di_fini(root_node); } exit(EXIT_SUCCESS); }
static void drvctl_lofi_add(gchar *devfs_path, gchar *name) { di_node_t node; const char *parent_udi; HalDevice *d, *parent; HAL_INFO (("lofi_add: %s %s", name, devfs_path)); if ((d = hal_device_store_match_key_value_string (hald_get_gdl (), "solaris.devfs_path", devfs_path)) == NULL) { HAL_INFO (("device not found in GDL %s", devfs_path)); return; } parent_udi = hal_device_property_get_string (d, "info.parent"); if ((parent_udi == NULL) || (strlen(parent_udi) == 0)) { HAL_INFO (("parent not found in GDL %s", parent_udi)); return; } if ((parent = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", parent_udi)) == NULL) { HAL_INFO (("parent not found in GDL %s", parent_udi)); return; } if ((node = di_init (devfs_path, DINFOCPYALL)) == DI_NODE_NIL) { HAL_INFO (("device not found in devinfo %s", devfs_path)); return; } HAL_INFO (("device %s parent %s", hal_device_get_udi (d), parent_udi)); devinfo_lofi_add_major (parent, node, devfs_path, NULL, TRUE, d); di_fini (node); hotplug_event_process_queue (); }