Lines Matching refs:param
426 static struct mapped_device *dm_hash_rename(struct dm_ioctl *param, in dm_hash_rename() argument
433 unsigned int change_uuid = (param->flags & DM_UUID_FLAG) ? 1 : 0; in dm_hash_rename()
456 param->name, new); in dm_hash_rename()
466 hc = __get_name_cell(param->name); in dm_hash_rename()
469 param->name, change_uuid ? "uuid " : "", new); in dm_hash_rename()
481 param->name, new, hc->uuid); in dm_hash_rename()
501 if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr, false)) in dm_hash_rename()
502 param->flags |= DM_UEVENT_GENERATED_FLAG; in dm_hash_rename()
528 typedef int (*ioctl_fn)(struct file *filp, struct dm_ioctl *param, size_t param_size);
530 static int remove_all(struct file *filp, struct dm_ioctl *param, size_t param_size) in remove_all() argument
532 dm_hash_remove_all(true, !!(param->flags & DM_DEFERRED_REMOVE), false); in remove_all()
533 param->data_size = 0; in remove_all()
554 static void *get_result_buffer(struct dm_ioctl *param, size_t param_size, in get_result_buffer() argument
557 param->data_start = align_ptr(param + 1) - (void *) param; in get_result_buffer()
559 if (param->data_start < param_size) in get_result_buffer()
560 *len = param_size - param->data_start; in get_result_buffer()
564 return ((void *) param) + param->data_start; in get_result_buffer()
591 static int list_devices(struct file *filp, struct dm_ioctl *param, size_t param_size) in list_devices() argument
608 if (!filter_device(hc, param->name, param->uuid)) in list_devices()
612 if (param->flags & DM_UUID_FLAG && hc->uuid) in list_devices()
619 nl = orig_nl = get_result_buffer(param, param_size, &len); in list_devices()
621 param->flags |= DM_BUFFER_FULL_FLAG; in list_devices()
624 param->data_size = param->data_start + needed; in list_devices()
635 if (!filter_device(hc, param->name, param->uuid)) in list_devices()
650 if (param->flags & DM_UUID_FLAG) { in list_devices()
681 static void list_version_get_info(struct target_type *tt, void *param) in list_version_get_info() argument
683 struct vers_iter *info = param; in list_version_get_info()
704 static int __list_versions(struct dm_ioctl *param, size_t param_size, const char *name) in __list_versions() argument
729 vers = get_result_buffer(param, param_size, &len); in __list_versions()
731 param->flags |= DM_BUFFER_FULL_FLAG; in __list_versions()
734 param->data_size = param->data_start + needed; in __list_versions()
749 param->flags |= iter_info.flags; in __list_versions()
757 static int list_versions(struct file *filp, struct dm_ioctl *param, size_t param_size) in list_versions() argument
759 return __list_versions(param, param_size, NULL); in list_versions()
762 static int get_target_version(struct file *filp, struct dm_ioctl *param, size_t param_size) in get_target_version() argument
764 return __list_versions(param, param_size, param->name); in get_target_version()
813 struct dm_ioctl *param, in dm_get_live_or_inactive_table() argument
816 return (param->flags & DM_QUERY_INACTIVE_TABLE_FLAG) ? in dm_get_live_or_inactive_table()
824 static void __dev_status(struct mapped_device *md, struct dm_ioctl *param) in __dev_status() argument
830 param->flags &= ~(DM_SUSPEND_FLAG | DM_READONLY_FLAG | in __dev_status()
834 param->flags |= DM_SUSPEND_FLAG; in __dev_status()
837 param->flags |= DM_INTERNAL_SUSPEND_FLAG; in __dev_status()
840 param->flags |= DM_DEFERRED_REMOVE; in __dev_status()
842 param->dev = huge_encode_dev(disk_devt(disk)); in __dev_status()
849 param->open_count = dm_open_count(md); in __dev_status()
851 param->event_nr = dm_get_event_nr(md); in __dev_status()
852 param->target_count = 0; in __dev_status()
856 if (!(param->flags & DM_QUERY_INACTIVE_TABLE_FLAG)) { in __dev_status()
858 param->flags |= DM_READONLY_FLAG; in __dev_status()
859 param->target_count = table->num_targets; in __dev_status()
862 param->flags |= DM_ACTIVE_PRESENT_FLAG; in __dev_status()
866 if (param->flags & DM_QUERY_INACTIVE_TABLE_FLAG) { in __dev_status()
872 param->flags |= DM_READONLY_FLAG; in __dev_status()
873 param->target_count = table->num_targets; in __dev_status()
879 static int dev_create(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_create() argument
884 r = check_name(param->name); in dev_create()
888 if (param->flags & DM_PERSISTENT_DEV_FLAG) in dev_create()
889 m = MINOR(huge_decode_dev(param->dev)); in dev_create()
895 r = dm_hash_insert(param->name, *param->uuid ? param->uuid : NULL, md); in dev_create()
902 param->flags &= ~DM_INACTIVE_PRESENT_FLAG; in dev_create()
904 __dev_status(md, param); in dev_create()
914 static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param) in __find_device_hash_cell() argument
918 if (*param->uuid) { in __find_device_hash_cell()
919 if (*param->name || param->dev) { in __find_device_hash_cell()
921 param->uuid, param->name, (unsigned long long)param->dev); in __find_device_hash_cell()
925 hc = __get_uuid_cell(param->uuid); in __find_device_hash_cell()
928 } else if (*param->name) { in __find_device_hash_cell()
929 if (param->dev) { in __find_device_hash_cell()
931 param->name, (unsigned long long)param->dev); in __find_device_hash_cell()
935 hc = __get_name_cell(param->name); in __find_device_hash_cell()
938 } else if (param->dev) { in __find_device_hash_cell()
939 hc = __get_dev_cell(param->dev); in __find_device_hash_cell()
949 strscpy(param->name, hc->name, sizeof(param->name)); in __find_device_hash_cell()
951 strscpy(param->uuid, hc->uuid, sizeof(param->uuid)); in __find_device_hash_cell()
953 param->uuid[0] = '\0'; in __find_device_hash_cell()
956 param->flags |= DM_INACTIVE_PRESENT_FLAG; in __find_device_hash_cell()
958 param->flags &= ~DM_INACTIVE_PRESENT_FLAG; in __find_device_hash_cell()
963 static struct mapped_device *find_device(struct dm_ioctl *param) in find_device() argument
969 hc = __find_device_hash_cell(param); in find_device()
977 static int dev_remove(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_remove() argument
985 hc = __find_device_hash_cell(param); in dev_remove()
998 r = dm_lock_for_deletion(md, !!(param->flags & DM_DEFERRED_REMOVE), false); in dev_remove()
1000 if (r == -EBUSY && param->flags & DM_DEFERRED_REMOVE) { in dev_remove()
1019 param->flags &= ~DM_DEFERRED_REMOVE; in dev_remove()
1023 if (!dm_kobject_uevent(md, KOBJ_REMOVE, param->event_nr, false)) in dev_remove()
1024 param->flags |= DM_UEVENT_GENERATED_FLAG; in dev_remove()
1044 static int dev_rename(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_rename() argument
1047 char *new_data = (char *) param + param->data_start; in dev_rename()
1049 unsigned int change_uuid = (param->flags & DM_UUID_FLAG) ? 1 : 0; in dev_rename()
1051 if (new_data < param->data || in dev_rename()
1052 invalid_str(new_data, (void *) param + param_size) || !*new_data || in dev_rename()
1064 md = dm_hash_rename(param, new_data); in dev_rename()
1068 __dev_status(md, param); in dev_rename()
1074 static int dev_set_geometry(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_set_geometry() argument
1080 char *geostr = (char *) param + param->data_start; in dev_set_geometry()
1083 md = find_device(param); in dev_set_geometry()
1087 if (geostr < param->data || in dev_set_geometry()
1088 invalid_str(geostr, (void *) param + param_size)) { in dev_set_geometry()
1113 param->data_size = 0; in dev_set_geometry()
1120 static int do_suspend(struct dm_ioctl *param) in do_suspend() argument
1126 md = find_device(param); in do_suspend()
1130 if (param->flags & DM_SKIP_LOCKFS_FLAG) in do_suspend()
1132 if (param->flags & DM_NOFLUSH_FLAG) in do_suspend()
1141 __dev_status(md, param); in do_suspend()
1149 static int do_resume(struct dm_ioctl *param) in do_resume() argument
1160 hc = __find_device_hash_cell(param); in do_resume()
1171 param->flags &= ~DM_INACTIVE_PRESENT_FLAG; in do_resume()
1180 if (param->flags & DM_SKIP_LOCKFS_FLAG) in do_resume()
1182 if (param->flags & DM_NOFLUSH_FLAG) in do_resume()
1210 if (!dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr, need_resize_uevent)) in do_resume()
1211 param->flags |= DM_UEVENT_GENERATED_FLAG; in do_resume()
1223 __dev_status(md, param); in do_resume()
1233 static int dev_suspend(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_suspend() argument
1235 if (param->flags & DM_SUSPEND_FLAG) in dev_suspend()
1236 return do_suspend(param); in dev_suspend()
1238 return do_resume(param); in dev_suspend()
1245 static int dev_status(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_status() argument
1249 md = find_device(param); in dev_status()
1253 __dev_status(md, param); in dev_status()
1263 struct dm_ioctl *param, size_t param_size) in retrieve_status() argument
1272 outptr = outbuf = get_result_buffer(param, param_size, &len); in retrieve_status()
1274 if (param->flags & DM_STATUS_TABLE_FLAG) in retrieve_status()
1276 else if (param->flags & DM_IMA_MEASUREMENT_FLAG) in retrieve_status()
1289 param->flags |= DM_BUFFER_FULL_FLAG; in retrieve_status()
1304 param->flags |= DM_BUFFER_FULL_FLAG; in retrieve_status()
1310 if (param->flags & DM_NOFLUSH_FLAG) in retrieve_status()
1318 param->flags |= DM_BUFFER_FULL_FLAG; in retrieve_status()
1323 used = param->data_start + (outptr - outbuf); in retrieve_status()
1330 param->data_size = used; in retrieve_status()
1332 param->target_count = num_targets; in retrieve_status()
1338 static int dev_wait(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_wait() argument
1345 md = find_device(param); in dev_wait()
1352 if (dm_wait_event(md, param->event_nr)) { in dev_wait()
1362 __dev_status(md, param); in dev_wait()
1364 table = dm_get_live_or_inactive_table(md, param, &srcu_idx); in dev_wait()
1366 retrieve_status(table, param, param_size); in dev_wait()
1379 static int dev_arm_poll(struct file *filp, struct dm_ioctl *param, size_t param_size) in dev_arm_poll() argument
1388 static inline blk_mode_t get_mode(struct dm_ioctl *param) in get_mode() argument
1392 if (param->flags & DM_READONLY_FLAG) in get_mode()
1433 struct dm_ioctl *param, size_t param_size) in populate_table() argument
1437 struct dm_target_spec *spec = (struct dm_target_spec *) param; in populate_table()
1438 uint32_t next = param->data_start; in populate_table()
1439 const char *const end = (const char *) param + param_size; in populate_table()
1443 if (!param->target_count) { in populate_table()
1448 for (i = 0; i < param->target_count; i++) { in populate_table()
1496 static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_size) in table_load() argument
1504 md = find_device(param); in table_load()
1508 r = dm_table_create(&t, get_mode(param), param->target_count, md); in table_load()
1514 r = populate_table(t, param, param_size); in table_load()
1561 param->flags |= DM_INACTIVE_PRESENT_FLAG; in table_load()
1562 __dev_status(md, param); in table_load()
1583 static int table_clear(struct file *filp, struct dm_ioctl *param, size_t param_size) in table_clear() argument
1592 hc = __find_device_hash_cell(param); in table_clear()
1608 param->flags &= ~DM_INACTIVE_PRESENT_FLAG; in table_clear()
1609 __dev_status(md, param); in table_clear()
1625 struct dm_ioctl *param, size_t param_size) in retrieve_deps() argument
1635 deps = get_result_buffer(param, param_size, &len); in retrieve_deps()
1648 param->flags |= DM_BUFFER_FULL_FLAG; in retrieve_deps()
1660 param->data_size = param->data_start + needed; in retrieve_deps()
1666 static int table_deps(struct file *filp, struct dm_ioctl *param, size_t param_size) in table_deps() argument
1672 md = find_device(param); in table_deps()
1676 __dev_status(md, param); in table_deps()
1678 table = dm_get_live_or_inactive_table(md, param, &srcu_idx); in table_deps()
1680 retrieve_deps(table, param, param_size); in table_deps()
1692 static int table_status(struct file *filp, struct dm_ioctl *param, size_t param_size) in table_status() argument
1698 md = find_device(param); in table_status()
1702 __dev_status(md, param); in table_status()
1704 table = dm_get_live_or_inactive_table(md, param, &srcu_idx); in table_status()
1706 retrieve_status(table, param, param_size); in table_status()
1747 static int target_message(struct file *filp, struct dm_ioctl *param, size_t param_size) in target_message() argument
1754 struct dm_target_msg *tmsg = (void *) param + param->data_start; in target_message()
1756 char *result = get_result_buffer(param, param_size, &maxlen); in target_message()
1759 md = find_device(param); in target_message()
1763 if (tmsg < (struct dm_target_msg *) param->data || in target_message()
1764 invalid_str(tmsg->message, (void *) param + param_size)) { in target_message()
1812 __dev_status(md, param); in target_message()
1815 param->flags |= DM_DATA_OUT_FLAG; in target_message()
1817 param->flags |= DM_BUFFER_FULL_FLAG; in target_message()
1819 param->data_size = param->data_start + strlen(result) + 1; in target_message()
1922 static void free_params(struct dm_ioctl *param, size_t param_size, int param_flags) in free_params() argument
1925 memset(param, 0, param_size); in free_params()
1928 kvfree(param); in free_params()
1932 int ioctl_flags, struct dm_ioctl **param, int *param_flags) in copy_params() argument
1988 *param = dmi; in copy_params()
1997 static int validate_params(uint cmd, struct dm_ioctl *param) in validate_params() argument
2000 param->flags &= ~DM_BUFFER_FULL_FLAG; in validate_params()
2001 param->flags &= ~DM_UEVENT_GENERATED_FLAG; in validate_params()
2002 param->flags &= ~DM_SECURE_DATA_FLAG; in validate_params()
2003 param->flags &= ~DM_DATA_OUT_FLAG; in validate_params()
2012 if (!*param->name) { in validate_params()
2016 } else if (*param->uuid && *param->name) { in validate_params()
2022 param->name[DM_NAME_LEN - 1] = '\0'; in validate_params()
2023 param->uuid[DM_UUID_LEN - 1] = '\0'; in validate_params()
2034 struct dm_ioctl *param; in ctl_ioctl() local
2071 r = copy_params(user, ¶m_kernel, ioctl_flags, ¶m, ¶m_flags); in ctl_ioctl()
2076 input_param_size = param->data_size; in ctl_ioctl()
2077 r = validate_params(cmd, param); in ctl_ioctl()
2081 param->data_size = offsetof(struct dm_ioctl, data); in ctl_ioctl()
2082 r = fn(file, param, input_param_size); in ctl_ioctl()
2084 if (unlikely(param->flags & DM_BUFFER_FULL_FLAG) && in ctl_ioctl()
2094 if (!r && copy_to_user(user, param, param->data_size)) in ctl_ioctl()
2098 free_params(param, input_param_size, param_flags); in ctl_ioctl()