/* * 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; }
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; }