int show_pkg_info_from_metadir(struct xbps_handle *xhp, const char *pkgname, const char *option) { prop_dictionary_t d, pkgdb_d; const char *instdate, *pname; bool autoinst; d = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGPROPS); if (d == NULL) return EINVAL; prop_dictionary_get_cstring_nocopy(d, "pkgname", &pname); pkgdb_d = xbps_pkgdb_get_pkgd(xhp, pname, false); if (pkgdb_d == NULL) { prop_object_release(d); return EINVAL; } if (prop_dictionary_get_cstring_nocopy(pkgdb_d, "install-date", &instdate)) prop_dictionary_set_cstring_nocopy(d, "install-date", instdate); if (prop_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst)) prop_dictionary_set_bool(d, "automatic-install", autoinst); if (option == NULL) show_pkg_info(d); else show_pkg_info_one(d, option); prop_object_release(d); return 0; }
/* * Set only flag to suggest that device is suspended. This call is * not supported in NetBSD. * */ int dm_dev_suspend_ioctl(prop_dictionary_t dm_dict) { dm_dev_t *dmv; const char *name, *uuid; uint32_t flags, minor; name = NULL; uuid = NULL; flags = 0; prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } atomic_set_int(&dmv->flags, DM_SUSPEND_FLAG); dm_dbg_print_flags(dmv->flags); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_FLAGS, dmv->flags); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); dm_dev_unbusy(dmv); /* Add flags to dictionary flag after dmv -> dict copy */ DM_ADD_FLAG(flags, DM_EXISTS_FLAG); return 0; }
/* * Remove inactive table from device. Routines which work's with inactive tables * doesn't need to synchronise with dmstrategy. They can synchronise themselves with mutex?. * */ int dm_table_clear_ioctl(prop_dictionary_t dm_dict) { dm_dev_t *dmv; const char *name, *uuid; uint32_t flags, minor; dmv = NULL; name = NULL; uuid = NULL; flags = 0; minor = 0; prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); aprint_debug("Clearing inactive table from device: %s--%s\n", name, uuid); if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } /* Select unused table */ dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE); atomic_clear_int(&dmv->flags, DM_INACTIVE_PRESENT_FLAG); dm_dev_unbusy(dmv); return 0; }
/* * Get list of physical devices for active table. * Get dev_t from pdev vnode and insert it into cmd_array. * * XXX. This function is called from lvm2tools to get information * about physical devices, too e.g. during vgcreate. */ int dm_table_deps_ioctl(prop_dictionary_t dm_dict) { dm_dev_t *dmv; dm_table_t *tbl; dm_table_entry_t *table_en; prop_array_t cmd_array; const char *name, *uuid; uint32_t flags, minor; int table_type; name = NULL; uuid = NULL; dmv = NULL; flags = 0; prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); /* create array for dev_t's */ cmd_array = prop_array_create(); if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); prop_dictionary_set_cstring(dm_dict, DM_IOCTL_NAME, dmv->name); prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid); aprint_debug("Getting table deps for device: %s\n", dmv->name); /* * if DM_QUERY_INACTIVE_TABLE_FLAG is passed we need to query * INACTIVE TABLE */ if (flags & DM_QUERY_INACTIVE_TABLE_FLAG) table_type = DM_TABLE_INACTIVE; else table_type = DM_TABLE_ACTIVE; tbl = dm_table_get_entry(&dmv->table_head, table_type); SLIST_FOREACH(table_en, tbl, next) table_en->target->deps(table_en, cmd_array); dm_table_release(&dmv->table_head, table_type); dm_dev_unbusy(dmv); prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array); prop_object_release(cmd_array); return 0; }
/* * Rename selected devices old name is in struct dm_ioctl. * newname is taken from dictionary * * <key>cmd_data</key> * <array> * <string>...</string> * </array> */ int dm_dev_rename_ioctl(prop_dictionary_t dm_dict) { #if 0 prop_array_t cmd_array; dm_dev_t *dmv; const char *name, *uuid, *n_name; uint32_t flags, minor; name = NULL; uuid = NULL; minor = 0; /* Get needed values from dictionary. */ prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); dm_dbg_print_flags(flags); cmd_array = prop_dictionary_get(dm_dict, DM_IOCTL_CMD_DATA); prop_array_get_cstring_nocopy(cmd_array, 0, &n_name); if (strlen(n_name) + 1 > DM_NAME_LEN) return EINVAL; if ((dmv = dm_dev_rem(NULL, name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } /* change device name */ /* * XXX How to deal with this change, name only used in * dm_dev_routines, should I add dm_dev_change_name which will run * under the dm_dev_list mutex ? */ strlcpy(dmv->name, n_name, DM_NAME_LEN); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid); dm_dev_insert(dmv); #endif /* * XXX: the rename is not yet implemented. The main complication * here is devfs. We'd probably need a new function, rename_dev() * that would trigger a node rename in devfs. */ kprintf("dm_dev_rename_ioctl called, but not implemented!\n"); return 0; }
/* * Return actual state of device to libdevmapper. */ int dm_dev_status_ioctl(prop_dictionary_t dm_dict) { dm_dev_t *dmv; const char *name, *uuid; uint32_t flags, j, minor; name = NULL; uuid = NULL; flags = 0; j = 0; prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } dm_dbg_print_flags(dmv->flags); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid); if (dmv->flags & DM_SUSPEND_FLAG) DM_ADD_FLAG(flags, DM_SUSPEND_FLAG); /* * Add status flags for tables I have to check both active and * inactive tables. */ if ((j = dm_table_get_target_count(&dmv->table_head, DM_TABLE_ACTIVE))) { DM_ADD_FLAG(flags, DM_ACTIVE_PRESENT_FLAG); } else DM_REMOVE_FLAG(flags, DM_ACTIVE_PRESENT_FLAG); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_TARGET_COUNT, j); if (dm_table_get_target_count(&dmv->table_head, DM_TABLE_INACTIVE)) DM_ADD_FLAG(flags, DM_INACTIVE_PRESENT_FLAG); else DM_REMOVE_FLAG(flags, DM_INACTIVE_PRESENT_FLAG); dm_dev_unbusy(dmv); return 0; }
void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod) { prop_array_t pkg_cflicts, trans_cflicts; prop_dictionary_t pkgd; const char *cfpkg, *repopkgver, *pkgver; char *buf; size_t i; pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts"); if (pkg_cflicts == NULL || prop_array_count(pkg_cflicts) == 0) return; trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts"); prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); for (i = 0; i < prop_array_count(pkg_cflicts); i++) { prop_array_get_cstring_nocopy(pkg_cflicts, i, &cfpkg); /* * Check if current pkg conflicts with an installed package. */ if ((pkgd = xbps_pkgdb_get_pkgd(xhp, cfpkg, true))) { prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); buf = xbps_xasprintf("%s conflicts with " "installed pkg %s", repopkgver, pkgver); assert(buf != NULL); prop_array_add_cstring(trans_cflicts, buf); free(buf); continue; } /* * Check if current pkg conflicts with any pkg in transaction. */ pkgd = xbps_find_pkg_in_dict_by_pattern(xhp, xhp->transd, "unsorted_deps", cfpkg); if (pkgd != NULL) { prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); buf = xbps_xasprintf("%s conflicts with " "%s in transaction", repopkgver, pkgver); assert(buf != NULL); prop_array_add_cstring(trans_cflicts, buf); free(buf); continue; } } }
/* * Rename selected devices old name is in struct dm_ioctl. * newname is taken from dictionary * * <key>cmd_data</key> * <array> * <string>...</string> * </array> */ int dm_dev_rename_ioctl(prop_dictionary_t dm_dict) { prop_array_t cmd_array; dm_dev_t *dmv; const char *name, *uuid, *n_name; uint32_t flags, minor; name = NULL; uuid = NULL; minor = 0; /* Get needed values from dictionary. */ prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); dm_dbg_print_flags(flags); cmd_array = prop_dictionary_get(dm_dict, DM_IOCTL_CMD_DATA); prop_array_get_cstring_nocopy(cmd_array, 0, &n_name); if (strlen(n_name) + 1 > DM_NAME_LEN) return EINVAL; if ((dmv = dm_dev_rem(name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } /* change device name */ /* * XXX How to deal with this change, name only used in * dm_dev_routines, should I add dm_dev_change_name which will run * under the dm_dev_list mutex ? */ strlcpy(dmv->name, n_name, DM_NAME_LEN); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid); dm_dev_insert(dmv); return 0; }
static npf_rproc_t * npf_mk_rproc(prop_array_t rprocs, const char *rpname) { prop_object_iterator_t it; prop_dictionary_t rpdict; npf_rproc_t *rp; uint64_t rpval; it = prop_array_iterator(rprocs); while ((rpdict = prop_object_iterator_next(it)) != NULL) { const char *iname; prop_dictionary_get_cstring_nocopy(rpdict, "name", &iname); KASSERT(iname != NULL); if (strcmp(rpname, iname) == 0) break; } prop_object_iterator_release(it); if (rpdict == NULL) { return NULL; } CTASSERT(sizeof(uintptr_t) <= sizeof(uint64_t)); if (!prop_dictionary_get_uint64(rpdict, "rproc-ptr", &rpval)) { rp = npf_rproc_create(rpdict); rpval = (uint64_t)(uintptr_t)rp; prop_dictionary_set_uint64(rpdict, "rproc-ptr", rpval); } else { rp = (npf_rproc_t *)(uintptr_t)rpval; } return rp; }
const char * getifname(prop_dictionary_t env) { const char *s; return prop_dictionary_get_cstring_nocopy(env, "if", &s) ? s : NULL; }
static npf_rproc_t * npf_mk_singlerproc(prop_dictionary_t rpdict) { prop_object_iterator_t it; prop_dictionary_t extdict; prop_array_t extlist; npf_rproc_t *rp; extlist = prop_dictionary_get(rpdict, "extcalls"); if (prop_object_type(extlist) != PROP_TYPE_ARRAY) { return NULL; } rp = npf_rproc_create(rpdict); if (rp == NULL) { return NULL; } it = prop_array_iterator(extlist); while ((extdict = prop_object_iterator_next(it)) != NULL) { const char *name; if (!prop_dictionary_get_cstring_nocopy(extdict, "name", &name) || npf_ext_construct(name, rp, extdict)) { npf_rproc_release(rp); rp = NULL; break; } } prop_object_iterator_release(it); return rp; }
static int quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, prop_dictionary_t cmddict, int type, prop_array_t datas) { prop_dictionary_t data; struct ufsmount *ump = VFSTOUFS(mp); int error; const char *qfile; if ((ump->um_flags & UFS_QUOTA2) != 0) return EBUSY; if (prop_array_count(datas) != 1) return EINVAL; data = prop_array_get(datas, 0); if (data == NULL) return ENOMEM; if (!prop_dictionary_get_cstring_nocopy(data, "quotafile", &qfile)) return EINVAL; error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL); if (error != 0) { return error; } #ifdef QUOTA error = quota1_handle_cmd_quotaon(l, ump, type, qfile); #else error = EOPNOTSUPP; #endif return error; }
/* * Simulate Linux behaviour better and switch tables here and not in * dm_table_load_ioctl. */ int dm_dev_resume_ioctl(prop_dictionary_t dm_dict) { dm_dev_t *dmv; const char *name, *uuid; uint32_t flags, minor; name = NULL; uuid = NULL; flags = 0; /* * char *xml; xml = prop_dictionary_externalize(dm_dict); * printf("%s\n",xml); */ prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); /* Remove device from global device list */ if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } atomic_clear_int(&dmv->flags, (DM_SUSPEND_FLAG | DM_INACTIVE_PRESENT_FLAG)); atomic_set_int(&dmv->flags, DM_ACTIVE_PRESENT_FLAG); dm_table_switch_tables(&dmv->table_head); DM_ADD_FLAG(flags, DM_EXISTS_FLAG); dmsetdiskinfo(dmv->diskp, &dmv->table_head); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_FLAGS, flags); prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); dm_dev_unbusy(dmv); /* Destroy inactive table after resume. */ dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE); return 0; }
const char * npf_rproc_getname(nl_rproc_t *rp) { prop_dictionary_t rpdict = rp->nrp_dict; const char *rpname = NULL; prop_dictionary_get_cstring_nocopy(rpdict, "name", &rpname); return rpname; }
const char * npf_rule_getproc(nl_rule_t *rl) { prop_dictionary_t rldict = rl->nrl_dict; const char *rpname = NULL; prop_dictionary_get_cstring_nocopy(rldict, "rproc", &rpname); return rpname; }
const char * npf_rule_getinterface(nl_rule_t *rl) { prop_dictionary_t rldict = rl->nrl_dict; const char *ifname = NULL; prop_dictionary_get_cstring_nocopy(rldict, "interface", &ifname); return ifname; }
const char * npf_table_getname(nl_table_t *tl) { prop_dictionary_t tldict = tl->ntl_dict; const char *tname = NULL; prop_dictionary_get_cstring_nocopy(tldict, "name", &tname); return tname; }
static int __noinline npf_mk_singlerule(prop_dictionary_t rldict, npf_rprocset_t *rpset, npf_rule_t **rlret, prop_dictionary_t errdict) { npf_rule_t *rl; const char *rname; prop_object_t obj; int p, error = 0; /* Rule - dictionary. */ if (prop_object_type(rldict) != PROP_TYPE_DICTIONARY) { NPF_ERR_DEBUG(errdict); return EINVAL; } if ((rl = npf_rule_alloc(rldict)) == NULL) { NPF_ERR_DEBUG(errdict); return EINVAL; } /* Assign rule procedure, if any. */ if (prop_dictionary_get_cstring_nocopy(rldict, "rproc", &rname)) { npf_rproc_t *rp; if (rpset == NULL) { error = EINVAL; goto err; } if ((rp = npf_rprocset_lookup(rpset, rname)) == NULL) { NPF_ERR_DEBUG(errdict); error = EINVAL; goto err; } npf_rule_setrproc(rl, rp); } /* Filter code (binary data). */ if ((obj = prop_dictionary_get(rldict, "code")) != NULL) { int type; size_t len; void *code; prop_dictionary_get_int32(rldict, "code-type", &type); error = npf_mk_code(obj, type, &code, &len, errdict); if (error) { goto err; } npf_rule_setcode(rl, type, code, len); } *rlret = rl; return 0; err: npf_rule_free(rl); prop_dictionary_get_int32(rldict, "prio", &p); /* XXX */ prop_dictionary_set_int32(errdict, "id", p); return error; }
static npf_alg_t * npf_mk_singlealg(prop_dictionary_t aldict) { const char *name; if (!prop_dictionary_get_cstring_nocopy(aldict, "name", &name)) return NULL; return npf_alg_construct(name); }
static int repo_find_best_pkg_cb(struct xbps_handle *xhp, struct xbps_rpool_index *rpi, void *arg, bool *done) { struct repo_pool_fpkg *rpf = arg; const char *repopkgver; prop_dictionary_t pkgd; (void)done; (void)xhp; if (rpf->bypattern) { pkgd = xbps_find_pkg_in_array_by_pattern(xhp, rpi->repo, rpf->pattern, NULL); } else { pkgd = xbps_find_pkg_in_array_by_name(xhp, rpi->repo, rpf->pattern, NULL); } if (pkgd == NULL) { if (errno && errno != ENOENT) return errno; xbps_dbg_printf(xhp, "[rpool] Package '%s' not found in repository " "'%s'.\n", rpf->pattern, rpi->uri); return 0; } prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &repopkgver); if (rpf->bestpkgver == NULL) { xbps_dbg_printf(xhp, "[rpool] Found best match '%s' (%s).\n", repopkgver, rpi->uri); rpf->pkgd = pkgd; prop_dictionary_set_cstring_nocopy(rpf->pkgd, "repository", rpi->uri); rpf->bestpkgver = repopkgver; return 0; } /* * Compare current stored version against new * version from current package in repository. */ if (xbps_cmpver(repopkgver, rpf->bestpkgver) == 1) { xbps_dbg_printf(xhp, "[rpool] Found best match '%s' (%s).\n", repopkgver, rpi->uri); rpf->pkgd = pkgd; prop_dictionary_set_cstring_nocopy(rpf->pkgd, "repository", rpi->uri); rpf->bestpkgver = repopkgver; } return 0; }
const char * testcase_get_stderr_buf(prop_dictionary_t testcase) { const char *str = ""; prop_dictionary_t dict = testcase_get_result_dict(testcase); prop_dictionary_get_cstring_nocopy(dict, "stderr_buf", &str); return str; }
static int __noinline npf_mk_singlerule(prop_dictionary_t rldict, prop_array_t rps, npf_rule_t **rl, prop_dictionary_t errdict) { const char *rnm; npf_rproc_t *rp; prop_object_t obj; size_t nc_size; void *nc; int p, error; /* Rule - dictionary. */ if (prop_object_type(rldict) != PROP_TYPE_DICTIONARY) { NPF_ERR_DEBUG(errdict); return EINVAL; } error = 0; obj = prop_dictionary_get(rldict, "ncode"); if (obj) { /* N-code (binary data). */ error = npf_mk_ncode(obj, &nc, &nc_size, errdict); if (error) { goto err; } } else { /* No n-code. */ nc = NULL; nc_size = 0; } /* Check for rule procedure. */ if (rps && prop_dictionary_get_cstring_nocopy(rldict, "rproc", &rnm)) { rp = npf_mk_rproc(rps, rnm); if (rp == NULL) { if (nc) { npf_ncode_free(nc, nc_size); /* XXX */ } NPF_ERR_DEBUG(errdict); error = EINVAL; goto err; } } else { rp = NULL; } /* Finally, allocate and return the rule. */ *rl = npf_rule_alloc(rldict, rp, nc, nc_size); KASSERT(*rl != NULL); return 0; err: prop_dictionary_get_int32(rldict, "priority", &p); /* XXX */ prop_dictionary_set_int32(errdict, "id", p); return error; }
const char * testcase_get_name(prop_dictionary_t testcase) { const char *str; int r; r = prop_dictionary_get_cstring_nocopy(testcase, "name", &str); if (r == 0) err(1, "prop_dictionary operation failed"); return str; }
const char * testcase_get_make_cmd(prop_dictionary_t testcase) { const char *str; int r; r = prop_dictionary_get_cstring_nocopy( prop_dictionary_get(testcase, "opts"), "make_cmd", &str); if (r == 0) err(1, "prop_dictionary operation failed"); return str; }
static int hdaudioctl_list(int fd) { prop_dictionary_t request, response; prop_dictionary_t dict; prop_object_iterator_t iter; prop_object_t obj; prop_array_t array; uint16_t nid, codecid; uint16_t vendor, product; uint32_t subsystem; const char *device = NULL; int error; request = prop_dictionary_create(); if (request == NULL) { fprintf(stderr, "out of memory\n"); return ENOMEM; } error = prop_dictionary_sendrecv_ioctl(request, fd, HDAUDIO_FGRP_INFO, &response); if (error != 0) { perror("HDAUDIO_FGRP_INFO failed"); return error; } array = prop_dictionary_get(response, "function-group-info"); iter = prop_array_iterator(array); prop_object_iterator_reset(iter); while ((obj = prop_object_iterator_next(iter)) != NULL) { dict = (prop_dictionary_t)obj; prop_dictionary_get_uint16(dict, "codecid", &codecid); prop_dictionary_get_uint16(dict, "nid", &nid); prop_dictionary_get_uint16(dict, "vendor-id", &vendor); prop_dictionary_get_uint16(dict, "product-id", &product); prop_dictionary_get_uint32(dict, "subsystem-id", &subsystem); prop_dictionary_get_cstring_nocopy(dict, "device", &device); printf("codecid 0x%02X nid 0x%02X vendor 0x%04X " "product 0x%04X subsystem 0x%08X device %s\n", codecid, nid, vendor, product, subsystem, device ? device : "<none>"); } prop_object_release(array); prop_object_release(response); prop_object_release(request); return 0; }
static gboolean drvctl_iochannel_data (GIOChannel *source, GIOCondition condition, gpointer user_data) { prop_dictionary_t ev; const char *event, *device; int res; HAL_INFO (("drvctl_iochannel_data")); res = prop_dictionary_recv_ioctl (drvctl_fd, DRVGETEVENT, &ev); if (res) { HAL_WARNING (("DRVGETEVENT failed: %s", strerror(errno))); return FALSE; } if (!prop_dictionary_get_cstring_nocopy (ev, "event", &event)) { HAL_WARNING (("DRVGETEVENT missing \"event\" parameter")); goto done; } if (!prop_dictionary_get_cstring_nocopy (ev, "device", &device)) { HAL_WARNING (("DRVGETEVENT missing \"device\" parameter")); goto done; } HAL_INFO (("DRVGETEVENT event=%s device=%s", event, device)); if (strcmp (event, "device-attach") == 0) { drvctl_dev_add (device); } else { drvctl_dev_remove (device); } done: prop_object_release(ev); return TRUE; }
/* * Remove device from global list I have to remove active * and inactive tables first. */ int dm_dev_remove_ioctl(prop_dictionary_t dm_dict) { dm_dev_t *dmv; const char *name, *uuid; uint32_t flags, minor; device_t devt; flags = 0; name = NULL; uuid = NULL; /* Get needed values from dictionary. */ prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); dm_dbg_print_flags(flags); /* * This seems as hack to me, probably use routine dm_dev_get_devt to * atomicaly get devt from device. */ if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } devt = dmv->devt; dm_dev_unbusy(dmv); /* * This will call dm_detach routine which will actually removes * device. */ return config_detach(devt, DETACH_QUIET); }
/* * Remove device */ int dm_dev_remove_ioctl(prop_dictionary_t dm_dict) { dm_dev_t *dmv; const char *name, *uuid; uint32_t flags, minor, is_open; flags = 0; name = NULL; uuid = NULL; /* Get needed values from dictionary. */ prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor); dm_dbg_print_flags(flags); if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) { DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG); return ENOENT; } is_open = dmv->is_open; dm_dev_unbusy(dmv); if (is_open) return EBUSY; /* * This will call dm_detach routine which will actually remove * device. */ return dm_dev_remove(dmv); }
int npf_rproc_insert(nl_config_t *ncf, nl_rproc_t *rp) { prop_dictionary_t rpdict = rp->nrp_dict; const char *name; if (!prop_dictionary_get_cstring_nocopy(rpdict, "name", &name)) { return EINVAL; } if (npf_rproc_exists_p(ncf, name)) { return EEXIST; } prop_array_add(ncf->ncf_rproc_list, rpdict); return 0; }
/* * Create in-kernel entry for device. Device attributes such as name, uuid are * taken from proplib dictionary. * */ int dm_dev_create_ioctl(prop_dictionary_t dm_dict) { dm_dev_t *dmv; const char *name, *uuid; int r, flags; r = 0; flags = 0; name = NULL; uuid = NULL; /* Get needed values from dictionary. */ prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name); prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid); prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags); dm_dbg_print_flags(flags); /* Lookup name and uuid if device already exist quit. */ if ((dmv = dm_dev_lookup(name, uuid, -1)) != NULL) { DM_ADD_FLAG(flags, DM_EXISTS_FLAG); /* Device already exists */ dm_dev_unbusy(dmv); return EEXIST; } r = dm_dev_create(&dmv, name, uuid, flags); if (r == 0) { prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor); DM_ADD_FLAG(flags, DM_EXISTS_FLAG); DM_REMOVE_FLAG(flags, DM_INACTIVE_PRESENT_FLAG); } return r; }