static void write_sects(void) { struct sctstr *sct; int c, x, y, total; for (y = 0; y < WORLD_Y; y++) { for (x = y % 2; x < WORLD_X; x += 2) { sct = getsectp(x, y); total = elev[x][y]; if (total < LANDMIN) { sct->sct_type = SCT_WATER; } else if (total < HILLMIN) sct->sct_type = SCT_RURAL; else if (total < PLATMIN) sct->sct_type = SCT_MOUNT; else if (total < HIGHMIN) sct->sct_type = SCT_RURAL; else sct->sct_type = SCT_MOUNT; sct->sct_elev = total; sct->sct_newtype = sct->sct_type; sct->sct_dterr = own[sct->sct_x][y] + 1; if (ORE) add_resources(sct); } } if (AIRPORT_MARKER) for (c = 0; c < nc; ++c) { sct = getsectp(capx[c], capy[c]); sct->sct_type = SCT_AIRPT; sct->sct_newtype = SCT_AIRPT; } set_coastal_flags(); }
int sa_zfs_set_sharesmb(sa_group_t group, char *path, int on) { int ret = SA_NOT_IMPLEMENTED; char *command; sa_share_t share; /* In case SMB not enabled */ if (sa_get_optionset(group, "smb") == NULL) return (SA_NOT_SUPPORTED); command = malloc(ZFS_MAXPROPLEN * 2); if (command != NULL) { char *opts = NULL; char *dataset = NULL; FILE *pfile; sa_handle_impl_t impl_handle; if (on) { char *newopt; share = sa_get_share(group, NULL); opts = sa_proto_legacy_format("smb", share, 1); if (opts != NULL && strlen(opts) == 0) { free(opts); opts = strdup("on"); } newopt = add_resources(opts, share); free(opts); opts = newopt; } impl_handle = (sa_handle_impl_t)sa_find_group_handle(group); assert(impl_handle != NULL); if (impl_handle != NULL) dataset = get_zfs_dataset(impl_handle, path, B_FALSE); else ret = SA_SYSTEM_ERR; if (dataset != NULL) { (void) snprintf(command, ZFS_MAXPROPLEN * 2, "echo %s set sharesmb=\"%s\" %s", COMMAND, opts != NULL ? opts : "off", dataset); pfile = popen(command, "r"); if (pfile != NULL) { ret = pclose(pfile); if (ret != 0) ret = SA_SYSTEM_ERR; } } if (opts != NULL) free(opts); if (dataset != NULL) free(dataset); free(command); } return (ret); }
static void get_current_resources(struct acpi_device *device, int busnum, int domain, struct pci_bus *bus) { struct pci_root_info info; size_t size; if (pci_use_crs) pci_bus_remove_resources(bus); info.bridge = device; info.bus = bus; info.res_num = 0; acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, &info); if (!info.res_num) return; size = sizeof(*info.res) * info.res_num; info.res = kmalloc(size, GFP_KERNEL); if (!info.res) goto res_alloc_fail; info.name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum); if (!info.name) goto name_alloc_fail; info.res_num = 0; acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, &info); add_resources(&info); return; name_alloc_fail: kfree(info.res); res_alloc_fail: return; }
struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) { struct acpi_device *device = root->device; struct pci_root_info *info = NULL; int domain = root->segment; int busnum = root->secondary.start; LIST_HEAD(resources); struct pci_bus *bus = NULL; struct pci_sysdata *sd; int node; #ifdef CONFIG_ACPI_NUMA int pxm; #endif if (pci_ignore_seg) domain = 0; if (domain && !pci_domains_supported) { printk(KERN_WARNING "pci_bus %04x:%02x: " "ignored (multiple domains not supported)\n", domain, busnum); return NULL; } node = -1; #ifdef CONFIG_ACPI_NUMA pxm = acpi_get_pxm(device->handle); if (pxm >= 0) node = pxm_to_node(pxm); if (node != -1) set_mp_bus_to_node(busnum, node); else #endif node = get_mp_bus_to_node(busnum); if (node != -1 && !node_online(node)) node = -1; info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) { printk(KERN_WARNING "pci_bus %04x:%02x: " "ignored (out of memory)\n", domain, busnum); return NULL; } sd = &info->sd; sd->domain = domain; sd->node = node; sd->companion = device; /* * Maybe the desired pci bus has been already scanned. In such case * it is unnecessary to scan the pci bus with the given domain,busnum. */ bus = pci_find_bus(domain, busnum); if (bus) { /* * If the desired bus exits, the content of bus->sysdata will * be replaced by sd. */ memcpy(bus->sysdata, sd, sizeof(*sd)); kfree(info); } else { probe_pci_root_info(info, device, busnum, domain); /* insert busn res at first */ pci_add_resource(&resources, &root->secondary); /* * _CRS with no apertures is normal, so only fall back to * defaults or native bridge info if we're ignoring _CRS. */ if (pci_use_crs) add_resources(info, &resources); else { free_pci_root_info_res(info); x86_pci_root_bus_resources(busnum, &resources); } if (!setup_mcfg_map(info, domain, (u8)root->secondary.start, (u8)root->secondary.end, root->mcfg_addr)) bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd, &resources); if (bus) { pci_scan_child_bus(bus); pci_set_host_bridge_release( to_pci_host_bridge(bus->bridge), release_pci_root_info, info); } else { pci_free_resource_list(&resources); __release_pci_root_info(info); } } /* After the PCI-E bus has been walked and all devices discovered, * configure any settings of the fabric that might be necessary. */ if (bus) { struct pci_bus *child; list_for_each_entry(child, &bus->children, node) pcie_bus_configure_settings(child); } if (bus && node != -1) { #ifdef CONFIG_ACPI_NUMA if (pxm >= 0) dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d (pxm %d)\n", node, pxm); #else dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node); #endif } return bus; }
void PLAYER::subtract_resources(int n) { add_resources(-1*n); }