/* LINT - not static as fwcadm uses it */ static int disable_one_sv(char *path) { int setnumber; int rc; sv_get_maxdevs(); sv_check_cluster(path); sv_cfg_open(CFG_WRLOCK); create_cfg_hash(); if ((setnumber = find_in_hash(path)) != -1) { /* remove from kernel */ if ((rc = disable_dev(path)) == 0) { /* remove the cfgline */ remove_from_cfgfile(path, setnumber); } else if (errno == SV_ENODEV) { remove_from_cfgfile(path, setnumber); } } else { /* warn the user that we didn't find it in cfg file */ warn(NULL, gettext("%s was not found in the config storage"), path); /* still attempt to remove */ (void) disable_dev(path); rc = 1; } destroy_hashtable(); sv_cfg_close(); return (rc); }
static void parse_devicetree(struct FSP_S_CONFIG *silconfig) { struct device *dev = NB_DEV_ROOT; if (!dev) { printk(BIOS_ERR, "Could not find root device\n"); return; } /* Only disable bus 0 devices. */ for (dev = dev->bus->children; dev; dev = dev->sibling) { if (!dev->enabled) disable_dev(dev, silconfig); } }
/* LINT - not static as fwcadm uses it */ static void compare_sv(char *conf_file) { sv_name_t *svn_config; /* Devices in config file */ sv_name_t *svn_system; /* Devices in system */ sv_name_t *enable; /* Devices that need enabled */ sv_list_t svl_system; int config_cnt; int sys_cnt = 0; int setnumber, i, j; int index = 0; /* Index in enable[] */ int found; int fd0; svn_config = sv_alloc_svnames(); svn_system = sv_alloc_svnames(); enable = sv_alloc_svnames(); bzero(svn_system, sizeof (svn_system)); bzero(&svl_system, sizeof (svl_system)); bzero(enable, sizeof (enable)); /* * Read the configuration file * The return value is the number of entries */ config_cnt = read_config_file(conf_file, svn_config); if ((fd0 = open(sv_rpath, O_RDONLY)) < 0) error(NULL, gettext("unable to open %s: %s"), sv_rpath, strerror(errno)); /* Grab the system list from the driver */ svl_system.svl_count = sv_max_devices; svl_system.svl_names = &svn_system[0]; svl_system.svl_error = spcs_s_ucreate(); if (ioctl(fd0, SVIOC_LIST, &svl_system) < 0) { error(&svl_system.svl_error, gettext("unable to get list")); } spcs_s_ufree(&svl_system.svl_error); (void) close(fd0); /* * Count the number of devices in the system. * The last entry in the array has '\0' for a path name. */ for (j = 0; j < sv_max_devices; j++) { if (svn_system[j].svn_path[0] != '\0') { sys_cnt++; } else { break; } } /* * Compare the configuration array with the system array. * Mark any differences and disable conflicting devices. */ for (i = 0; i < config_cnt; i++) { found = 0; for (j = 0; j < sys_cnt; j++) { if (svn_system[j].svn_path[0] == '\0' || svn_system[j].svn_mode == 0) continue; /* Check to see if path matches */ if (strcmp(svn_system[j].svn_path, svn_config[i].svn_path) == 0) { /* Found a match */ svn_system[j].svn_path[0] = '\0'; found++; break; } } if (!found) { /* Minor number not in system = > enable device */ enable[index].svn_mode = svn_config[i].svn_mode; (void) strcpy(enable[index].svn_path, svn_config[i].svn_path); index++; } } /* Disable any devices that weren't in the config file */ for (j = 0; j < sys_cnt; j++) { sv_check_cluster(NULL); sv_cfg_open(CFG_WRLOCK); create_cfg_hash(); if (svn_system[j].svn_path[0] != '\0' && svn_system[j].svn_mode != 0) { (void) printf(gettext("%s: disabling sv: %s\n"), program, svn_system[j].svn_path); if (disable_dev(svn_system[j].svn_path) == 0) { setnumber = find_in_hash(svn_system[j].svn_path); if (setnumber != -1) { /* the volume was found in cfg store */ remove_from_cfgfile( svn_system[j].svn_path, setnumber); } } } sv_cfg_close(); destroy_hashtable(); } while (index) { /* * Config file doesn't match system => enable the devices * in enable[] */ index--; (void) printf(gettext("%s: enabling new sv: %s\n"), program, enable[index].svn_path); (void) enable_dev(&enable[index]); } /* * Search for entries where the cluster tag has changed. */ sv_check_cluster(NULL); sv_cfg_open(CFG_WRLOCK); for (i = 0; i < sv_max_devices; i++) { if (svn_config[i].svn_path[0] == '\0') break; compare_tag(svn_config[i].svn_path); } sv_cfg_close(); }
/* LINT - not static as fwcadm uses it */ static int disable_sv(char *conf_file) { sv_name_t *svn, *svn_system; /* Devices in system */ sv_list_t svl_system; int fd, i, setnumber; int rc, ret; svn_system = sv_alloc_svnames(); rc = ret = 0; if (conf_file == NULL) { if ((fd = open(sv_rpath, O_RDONLY)) < 0) { (void) printf(gettext("unable to open %s: %s"), sv_rpath, strerror(errno)); return (1); } /* Grab the system list from the driver */ svl_system.svl_count = sv_max_devices; svl_system.svl_names = &svn_system[0]; svl_system.svl_error = spcs_s_ucreate(); if (ioctl(fd, SVIOC_LIST, &svl_system) < 0) { error(&(svl_system.svl_error), gettext("unable to get list")); } spcs_s_ufree(&(svl_system.svl_error)); (void) close(fd); } else { svl_system.svl_count = read_config_file(conf_file, svn_system); } for (i = 0; i < svl_system.svl_count; i++) { if (*svn_system[i].svn_path == '\0') break; svn = &svn_system[i]; sv_check_cluster(svn->svn_path); sv_cfg_open(CFG_WRLOCK); create_cfg_hash(); rc = 0; if ((setnumber = find_in_hash(svn->svn_path)) != -1) { if ((rc = disable_dev(svn->svn_path)) != -1) { remove_from_cfgfile(svn->svn_path, setnumber); } else if (errno == SV_ENODEV) { remove_from_cfgfile(svn->svn_path, setnumber); } } else { /* warn the user that we didn't find it in cfg file */ warn(NULL, gettext( "%s was not found in the config storage"), svn->svn_path); /* try to disable anyway */ (void) disable_dev(svn->svn_path); rc = 1; } sv_cfg_close(); destroy_hashtable(); if (rc && !ret) ret = rc; } return (ret); }