Fix potentially unterminated string after strncpy() call
[fio.git] / cconv.c
1 #include <string.h>
2
3 #include "thread_options.h"
4
5 static void string_to_cpu(char **dst, const uint8_t *src)
6 {
7         const char *__src = (const char *) src;
8
9         if (strlen(__src))
10                 *dst = strdup(__src);
11 }
12
13 static void string_to_net(uint8_t *dst, const char *src)
14 {
15         if (src)
16                 strcpy((char *) dst, src);
17         else
18                 dst[0] = '\0';
19 }
20
21 static void free_thread_options_to_cpu(struct thread_options *o)
22 {
23         free(o->description);
24         free(o->name);
25         free(o->directory);
26         free(o->filename);
27         free(o->filename_format);
28         free(o->opendir);
29         free(o->ioengine);
30         free(o->mmapfile);
31         free(o->read_iolog_file);
32         free(o->write_iolog_file);
33         free(o->bw_log_file);
34         free(o->lat_log_file);
35         free(o->iops_log_file);
36         free(o->replay_redirect);
37         free(o->exec_prerun);
38         free(o->exec_postrun);
39         free(o->ioscheduler);
40         free(o->profile);
41         free(o->cgroup);
42 }
43
44 void convert_thread_options_to_cpu(struct thread_options *o,
45                                    struct thread_options_pack *top)
46 {
47         int i, j;
48
49         string_to_cpu(&o->description, top->description);
50         string_to_cpu(&o->name, top->name);
51         string_to_cpu(&o->directory, top->directory);
52         string_to_cpu(&o->filename, top->filename);
53         string_to_cpu(&o->filename_format, top->filename_format);
54         string_to_cpu(&o->opendir, top->opendir);
55         string_to_cpu(&o->ioengine, top->ioengine);
56         string_to_cpu(&o->mmapfile, top->mmapfile);
57         string_to_cpu(&o->read_iolog_file, top->read_iolog_file);
58         string_to_cpu(&o->write_iolog_file, top->write_iolog_file);
59         string_to_cpu(&o->bw_log_file, top->bw_log_file);
60         string_to_cpu(&o->lat_log_file, top->lat_log_file);
61         string_to_cpu(&o->iops_log_file, top->iops_log_file);
62         string_to_cpu(&o->replay_redirect, top->replay_redirect);
63         string_to_cpu(&o->exec_prerun, top->exec_prerun);
64         string_to_cpu(&o->exec_postrun, top->exec_postrun);
65         string_to_cpu(&o->ioscheduler, top->ioscheduler);
66         string_to_cpu(&o->profile, top->profile);
67         string_to_cpu(&o->cgroup, top->cgroup);
68
69         o->td_ddir = le32_to_cpu(top->td_ddir);
70         o->rw_seq = le32_to_cpu(top->rw_seq);
71         o->kb_base = le32_to_cpu(top->kb_base);
72         o->unit_base = le32_to_cpu(top->kb_base);
73         o->ddir_seq_nr = le32_to_cpu(top->ddir_seq_nr);
74         o->ddir_seq_add = le64_to_cpu(top->ddir_seq_add);
75         o->iodepth = le32_to_cpu(top->iodepth);
76         o->iodepth_low = le32_to_cpu(top->iodepth_low);
77         o->iodepth_batch = le32_to_cpu(top->iodepth_batch);
78         o->iodepth_batch_complete = le32_to_cpu(top->iodepth_batch_complete);
79         o->size = le64_to_cpu(top->size);
80         o->size_percent = le32_to_cpu(top->size_percent);
81         o->fill_device = le32_to_cpu(top->fill_device);
82         o->file_append = le32_to_cpu(top->file_append);
83         o->file_size_low = le64_to_cpu(top->file_size_low);
84         o->file_size_high = le64_to_cpu(top->file_size_high);
85         o->start_offset = le64_to_cpu(top->start_offset);
86
87         for (i = 0; i < DDIR_RWDIR_CNT; i++) {
88                 o->bs[i] = le32_to_cpu(top->bs[i]);
89                 o->ba[i] = le32_to_cpu(top->ba[i]);
90                 o->min_bs[i] = le32_to_cpu(top->min_bs[i]);
91                 o->max_bs[i] = le32_to_cpu(top->max_bs[i]);
92                 o->bssplit_nr[i] = le32_to_cpu(top->bssplit_nr[i]);
93
94                 if (o->bssplit_nr[i]) {
95                         o->bssplit[i] = malloc(o->bssplit_nr[i] * sizeof(struct bssplit));
96                         for (j = 0; j < o->bssplit_nr[i]; j++) {
97                                 o->bssplit[i][j].bs = le32_to_cpu(top->bssplit[i][j].bs);
98                                 o->bssplit[i][j].perc = le32_to_cpu(top->bssplit[i][j].perc);
99                         }
100                 }
101
102                 o->rwmix[i] = le32_to_cpu(top->rwmix[i]);
103                 o->rate[i] = le32_to_cpu(top->rate[i]);
104                 o->ratemin[i] = le32_to_cpu(top->ratemin[i]);
105                 o->rate_iops[i] = le32_to_cpu(top->rate_iops[i]);
106                 o->rate_iops_min[i] = le32_to_cpu(top->rate_iops_min[i]);
107
108                 o->perc_rand[i] = le32_to_cpu(top->perc_rand[i]);
109         }
110
111         o->ratecycle = le32_to_cpu(top->ratecycle);
112         o->nr_files = le32_to_cpu(top->nr_files);
113         o->open_files = le32_to_cpu(top->open_files);
114         o->file_lock_mode = le32_to_cpu(top->file_lock_mode);
115         o->odirect = le32_to_cpu(top->odirect);
116         o->oatomic = le32_to_cpu(top->oatomic);
117         o->invalidate_cache = le32_to_cpu(top->invalidate_cache);
118         o->create_serialize = le32_to_cpu(top->create_serialize);
119         o->create_fsync = le32_to_cpu(top->create_fsync);
120         o->create_on_open = le32_to_cpu(top->create_on_open);
121         o->create_only = le32_to_cpu(top->create_only);
122         o->end_fsync = le32_to_cpu(top->end_fsync);
123         o->pre_read = le32_to_cpu(top->pre_read);
124         o->sync_io = le32_to_cpu(top->sync_io);
125         o->verify = le32_to_cpu(top->verify);
126         o->do_verify = le32_to_cpu(top->do_verify);
127         o->verifysort = le32_to_cpu(top->verifysort);
128         o->verifysort_nr = le32_to_cpu(top->verifysort_nr);
129         o->experimental_verify = le32_to_cpu(top->experimental_verify);
130         o->verify_interval = le32_to_cpu(top->verify_interval);
131         o->verify_offset = le32_to_cpu(top->verify_offset);
132
133         memcpy(o->verify_pattern, top->verify_pattern, MAX_PATTERN_SIZE);
134         memcpy(o->buffer_pattern, top->buffer_pattern, MAX_PATTERN_SIZE);
135
136         o->verify_pattern_bytes = le32_to_cpu(top->verify_pattern_bytes);
137         o->verify_fatal = le32_to_cpu(top->verify_fatal);
138         o->verify_dump = le32_to_cpu(top->verify_dump);
139         o->verify_async = le32_to_cpu(top->verify_async);
140         o->verify_batch = le32_to_cpu(top->verify_batch);
141         o->use_thread = le32_to_cpu(top->use_thread);
142         o->unlink = le32_to_cpu(top->unlink);
143         o->do_disk_util = le32_to_cpu(top->do_disk_util);
144         o->override_sync = le32_to_cpu(top->override_sync);
145         o->rand_repeatable = le32_to_cpu(top->rand_repeatable);
146         o->allrand_repeatable = le32_to_cpu(top->allrand_repeatable);
147         o->rand_seed = le64_to_cpu(top->rand_seed);
148         o->use_os_rand = le32_to_cpu(top->use_os_rand);
149         o->log_avg_msec = le32_to_cpu(top->log_avg_msec);
150         o->norandommap = le32_to_cpu(top->norandommap);
151         o->softrandommap = le32_to_cpu(top->softrandommap);
152         o->bs_unaligned = le32_to_cpu(top->bs_unaligned);
153         o->fsync_on_close = le32_to_cpu(top->fsync_on_close);
154         o->bs_is_seq_rand = le32_to_cpu(top->bs_is_seq_rand);
155         o->random_distribution = le32_to_cpu(top->random_distribution);
156         o->zipf_theta.u.f = fio_uint64_to_double(le64_to_cpu(top->zipf_theta.u.i));
157         o->pareto_h.u.f = fio_uint64_to_double(le64_to_cpu(top->pareto_h.u.i));
158         o->random_generator = le32_to_cpu(top->random_generator);
159         o->hugepage_size = le32_to_cpu(top->hugepage_size);
160         o->rw_min_bs = le32_to_cpu(top->rw_min_bs);
161         o->thinktime = le32_to_cpu(top->thinktime);
162         o->thinktime_spin = le32_to_cpu(top->thinktime_spin);
163         o->thinktime_blocks = le32_to_cpu(top->thinktime_blocks);
164         o->fsync_blocks = le32_to_cpu(top->fsync_blocks);
165         o->fdatasync_blocks = le32_to_cpu(top->fdatasync_blocks);
166         o->barrier_blocks = le32_to_cpu(top->barrier_blocks);
167
168         o->verify_backlog = le64_to_cpu(top->verify_backlog);
169         o->start_delay = le64_to_cpu(top->start_delay);
170         o->start_delay_high = le64_to_cpu(top->start_delay_high);
171         o->timeout = le64_to_cpu(top->timeout);
172         o->ramp_time = le64_to_cpu(top->ramp_time);
173         o->zone_range = le64_to_cpu(top->zone_range);
174         o->zone_size = le64_to_cpu(top->zone_size);
175         o->zone_skip = le64_to_cpu(top->zone_skip);
176         o->lockmem = le64_to_cpu(top->lockmem);
177         o->offset_increment = le64_to_cpu(top->offset_increment);
178         o->number_ios = le64_to_cpu(top->number_ios);
179
180         o->overwrite = le32_to_cpu(top->overwrite);
181         o->bw_avg_time = le32_to_cpu(top->bw_avg_time);
182         o->iops_avg_time = le32_to_cpu(top->iops_avg_time);
183         o->loops = le32_to_cpu(top->loops);
184         o->mem_type = le32_to_cpu(top->mem_type);
185         o->mem_align = le32_to_cpu(top->mem_align);
186         o->max_latency = le32_to_cpu(top->max_latency);
187         o->stonewall = le32_to_cpu(top->stonewall);
188         o->new_group = le32_to_cpu(top->new_group);
189         o->numjobs = le32_to_cpu(top->numjobs);
190         o->cpumask_set = le32_to_cpu(top->cpumask_set);
191         o->verify_cpumask_set = le32_to_cpu(top->verify_cpumask_set);
192         o->cpus_allowed_policy = le32_to_cpu(top->cpus_allowed_policy);
193         o->iolog = le32_to_cpu(top->iolog);
194         o->rwmixcycle = le32_to_cpu(top->rwmixcycle);
195         o->nice = le32_to_cpu(top->nice);
196         o->ioprio = le32_to_cpu(top->ioprio);
197         o->ioprio_class = le32_to_cpu(top->ioprio_class);
198         o->file_service_type = le32_to_cpu(top->file_service_type);
199         o->group_reporting = le32_to_cpu(top->group_reporting);
200         o->fadvise_hint = le32_to_cpu(top->fadvise_hint);
201         o->fallocate_mode = le32_to_cpu(top->fallocate_mode);
202         o->zero_buffers = le32_to_cpu(top->zero_buffers);
203         o->refill_buffers = le32_to_cpu(top->refill_buffers);
204         o->scramble_buffers = le32_to_cpu(top->scramble_buffers);
205         o->buffer_pattern_bytes = le32_to_cpu(top->buffer_pattern_bytes);
206         o->time_based = le32_to_cpu(top->time_based);
207         o->disable_lat = le32_to_cpu(top->disable_lat);
208         o->disable_clat = le32_to_cpu(top->disable_clat);
209         o->disable_slat = le32_to_cpu(top->disable_slat);
210         o->disable_bw = le32_to_cpu(top->disable_bw);
211         o->unified_rw_rep = le32_to_cpu(top->unified_rw_rep);
212         o->gtod_reduce = le32_to_cpu(top->gtod_reduce);
213         o->gtod_cpu = le32_to_cpu(top->gtod_cpu);
214         o->gtod_offload = le32_to_cpu(top->gtod_offload);
215         o->clocksource = le32_to_cpu(top->clocksource);
216         o->no_stall = le32_to_cpu(top->no_stall);
217         o->trim_percentage = le32_to_cpu(top->trim_percentage);
218         o->trim_batch = le32_to_cpu(top->trim_batch);
219         o->trim_zero = le32_to_cpu(top->trim_zero);
220         o->clat_percentiles = le32_to_cpu(top->clat_percentiles);
221         o->percentile_precision = le32_to_cpu(top->percentile_precision);
222         o->continue_on_error = le32_to_cpu(top->continue_on_error);
223         o->cgroup_weight = le32_to_cpu(top->cgroup_weight);
224         o->cgroup_nodelete = le32_to_cpu(top->cgroup_nodelete);
225         o->uid = le32_to_cpu(top->uid);
226         o->gid = le32_to_cpu(top->gid);
227         o->flow_id = __le32_to_cpu(top->flow_id);
228         o->flow = __le32_to_cpu(top->flow);
229         o->flow_watermark = __le32_to_cpu(top->flow_watermark);
230         o->flow_sleep = le32_to_cpu(top->flow_sleep);
231         o->sync_file_range = le32_to_cpu(top->sync_file_range);
232         o->latency_target = le64_to_cpu(top->latency_target);
233         o->latency_window = le64_to_cpu(top->latency_window);
234         o->latency_percentile.u.f = fio_uint64_to_double(le64_to_cpu(top->latency_percentile.u.i));
235         o->compress_percentage = le32_to_cpu(top->compress_percentage);
236         o->compress_chunk = le32_to_cpu(top->compress_chunk);
237
238         o->trim_backlog = le64_to_cpu(top->trim_backlog);
239
240         for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
241                 o->percentile_list[i].u.f = fio_uint64_to_double(le64_to_cpu(top->percentile_list[i].u.i));
242 #if 0
243         uint8_t cpumask[FIO_TOP_STR_MAX];
244         uint8_t verify_cpumask[FIO_TOP_STR_MAX];
245 #endif
246 }
247
248 void convert_thread_options_to_net(struct thread_options_pack *top,
249                                    struct thread_options *o)
250 {
251         int i, j;
252
253         string_to_net(top->description, o->description);
254         string_to_net(top->name, o->name);
255         string_to_net(top->directory, o->directory);
256         string_to_net(top->filename, o->filename);
257         string_to_net(top->filename_format, o->filename_format);
258         string_to_net(top->opendir, o->opendir);
259         string_to_net(top->ioengine, o->ioengine);
260         string_to_net(top->mmapfile, o->mmapfile);
261         string_to_net(top->read_iolog_file, o->read_iolog_file);
262         string_to_net(top->write_iolog_file, o->write_iolog_file);
263         string_to_net(top->bw_log_file, o->bw_log_file);
264         string_to_net(top->lat_log_file, o->lat_log_file);
265         string_to_net(top->iops_log_file, o->iops_log_file);
266         string_to_net(top->replay_redirect, o->replay_redirect);
267         string_to_net(top->exec_prerun, o->exec_prerun);
268         string_to_net(top->exec_postrun, o->exec_postrun);
269         string_to_net(top->ioscheduler, o->ioscheduler);
270         string_to_net(top->profile, o->profile);
271         string_to_net(top->cgroup, o->cgroup);
272
273         top->td_ddir = cpu_to_le32(o->td_ddir);
274         top->rw_seq = cpu_to_le32(o->rw_seq);
275         top->kb_base = cpu_to_le32(o->kb_base);
276         top->unit_base = cpu_to_le32(o->kb_base);
277         top->ddir_seq_nr = cpu_to_le32(o->ddir_seq_nr);
278         top->iodepth = cpu_to_le32(o->iodepth);
279         top->iodepth_low = cpu_to_le32(o->iodepth_low);
280         top->iodepth_batch = cpu_to_le32(o->iodepth_batch);
281         top->iodepth_batch_complete = cpu_to_le32(o->iodepth_batch_complete);
282         top->size_percent = cpu_to_le32(o->size_percent);
283         top->fill_device = cpu_to_le32(o->fill_device);
284         top->file_append = cpu_to_le32(o->file_append);
285         top->ratecycle = cpu_to_le32(o->ratecycle);
286         top->nr_files = cpu_to_le32(o->nr_files);
287         top->open_files = cpu_to_le32(o->open_files);
288         top->file_lock_mode = cpu_to_le32(o->file_lock_mode);
289         top->odirect = cpu_to_le32(o->odirect);
290         top->oatomic = cpu_to_le32(o->oatomic);
291         top->invalidate_cache = cpu_to_le32(o->invalidate_cache);
292         top->create_serialize = cpu_to_le32(o->create_serialize);
293         top->create_fsync = cpu_to_le32(o->create_fsync);
294         top->create_on_open = cpu_to_le32(o->create_on_open);
295         top->create_only = cpu_to_le32(o->create_only);
296         top->end_fsync = cpu_to_le32(o->end_fsync);
297         top->pre_read = cpu_to_le32(o->pre_read);
298         top->sync_io = cpu_to_le32(o->sync_io);
299         top->verify = cpu_to_le32(o->verify);
300         top->do_verify = cpu_to_le32(o->do_verify);
301         top->verifysort = cpu_to_le32(o->verifysort);
302         top->verifysort_nr = cpu_to_le32(o->verifysort_nr);
303         top->experimental_verify = cpu_to_le32(o->experimental_verify);
304         top->verify_interval = cpu_to_le32(o->verify_interval);
305         top->verify_offset = cpu_to_le32(o->verify_offset);
306         top->verify_pattern_bytes = cpu_to_le32(o->verify_pattern_bytes);
307         top->verify_fatal = cpu_to_le32(o->verify_fatal);
308         top->verify_dump = cpu_to_le32(o->verify_dump);
309         top->verify_async = cpu_to_le32(o->verify_async);
310         top->verify_batch = cpu_to_le32(o->verify_batch);
311         top->use_thread = cpu_to_le32(o->use_thread);
312         top->unlink = cpu_to_le32(o->unlink);
313         top->do_disk_util = cpu_to_le32(o->do_disk_util);
314         top->override_sync = cpu_to_le32(o->override_sync);
315         top->rand_repeatable = cpu_to_le32(o->rand_repeatable);
316         top->allrand_repeatable = cpu_to_le32(o->allrand_repeatable);
317         top->rand_seed = __cpu_to_le64(o->rand_seed);
318         top->use_os_rand = cpu_to_le32(o->use_os_rand);
319         top->log_avg_msec = cpu_to_le32(o->log_avg_msec);
320         top->norandommap = cpu_to_le32(o->norandommap);
321         top->softrandommap = cpu_to_le32(o->softrandommap);
322         top->bs_unaligned = cpu_to_le32(o->bs_unaligned);
323         top->fsync_on_close = cpu_to_le32(o->fsync_on_close);
324         top->bs_is_seq_rand = cpu_to_le32(o->bs_is_seq_rand);
325         top->random_distribution = cpu_to_le32(o->random_distribution);
326         top->zipf_theta.u.i = __cpu_to_le64(fio_double_to_uint64(o->zipf_theta.u.f));
327         top->pareto_h.u.i = __cpu_to_le64(fio_double_to_uint64(o->pareto_h.u.f));
328         top->random_generator = cpu_to_le32(o->random_generator);
329         top->hugepage_size = cpu_to_le32(o->hugepage_size);
330         top->rw_min_bs = cpu_to_le32(o->rw_min_bs);
331         top->thinktime = cpu_to_le32(o->thinktime);
332         top->thinktime_spin = cpu_to_le32(o->thinktime_spin);
333         top->thinktime_blocks = cpu_to_le32(o->thinktime_blocks);
334         top->fsync_blocks = cpu_to_le32(o->fsync_blocks);
335         top->fdatasync_blocks = cpu_to_le32(o->fdatasync_blocks);
336         top->barrier_blocks = cpu_to_le32(o->barrier_blocks);
337         top->overwrite = cpu_to_le32(o->overwrite);
338         top->bw_avg_time = cpu_to_le32(o->bw_avg_time);
339         top->iops_avg_time = cpu_to_le32(o->iops_avg_time);
340         top->loops = cpu_to_le32(o->loops);
341         top->mem_type = cpu_to_le32(o->mem_type);
342         top->mem_align = cpu_to_le32(o->mem_align);
343         top->max_latency = cpu_to_le32(o->max_latency);
344         top->stonewall = cpu_to_le32(o->stonewall);
345         top->new_group = cpu_to_le32(o->new_group);
346         top->numjobs = cpu_to_le32(o->numjobs);
347         top->cpumask_set = cpu_to_le32(o->cpumask_set);
348         top->verify_cpumask_set = cpu_to_le32(o->verify_cpumask_set);
349         top->cpus_allowed_policy = cpu_to_le32(o->cpus_allowed_policy);
350         top->iolog = cpu_to_le32(o->iolog);
351         top->rwmixcycle = cpu_to_le32(o->rwmixcycle);
352         top->nice = cpu_to_le32(o->nice);
353         top->ioprio = cpu_to_le32(o->ioprio);
354         top->ioprio_class = cpu_to_le32(o->ioprio_class);
355         top->file_service_type = cpu_to_le32(o->file_service_type);
356         top->group_reporting = cpu_to_le32(o->group_reporting);
357         top->fadvise_hint = cpu_to_le32(o->fadvise_hint);
358         top->fallocate_mode = cpu_to_le32(o->fallocate_mode);
359         top->zero_buffers = cpu_to_le32(o->zero_buffers);
360         top->refill_buffers = cpu_to_le32(o->refill_buffers);
361         top->scramble_buffers = cpu_to_le32(o->scramble_buffers);
362         top->buffer_pattern_bytes = cpu_to_le32(o->buffer_pattern_bytes);
363         top->time_based = cpu_to_le32(o->time_based);
364         top->disable_lat = cpu_to_le32(o->disable_lat);
365         top->disable_clat = cpu_to_le32(o->disable_clat);
366         top->disable_slat = cpu_to_le32(o->disable_slat);
367         top->disable_bw = cpu_to_le32(o->disable_bw);
368         top->unified_rw_rep = cpu_to_le32(o->unified_rw_rep);
369         top->gtod_reduce = cpu_to_le32(o->gtod_reduce);
370         top->gtod_cpu = cpu_to_le32(o->gtod_cpu);
371         top->gtod_offload = cpu_to_le32(o->gtod_offload);
372         top->clocksource = cpu_to_le32(o->clocksource);
373         top->no_stall = cpu_to_le32(o->no_stall);
374         top->trim_percentage = cpu_to_le32(o->trim_percentage);
375         top->trim_batch = cpu_to_le32(o->trim_batch);
376         top->trim_zero = cpu_to_le32(o->trim_zero);
377         top->clat_percentiles = cpu_to_le32(o->clat_percentiles);
378         top->percentile_precision = cpu_to_le32(o->percentile_precision);
379         top->continue_on_error = cpu_to_le32(o->continue_on_error);
380         top->cgroup_weight = cpu_to_le32(o->cgroup_weight);
381         top->cgroup_nodelete = cpu_to_le32(o->cgroup_nodelete);
382         top->uid = cpu_to_le32(o->uid);
383         top->gid = cpu_to_le32(o->gid);
384         top->flow_id = __cpu_to_le32(o->flow_id);
385         top->flow = __cpu_to_le32(o->flow);
386         top->flow_watermark = __cpu_to_le32(o->flow_watermark);
387         top->flow_sleep = cpu_to_le32(o->flow_sleep);
388         top->sync_file_range = cpu_to_le32(o->sync_file_range);
389         top->latency_target = __cpu_to_le64(o->latency_target);
390         top->latency_window = __cpu_to_le64(o->latency_window);
391         top->latency_percentile.u.i = __cpu_to_le64(fio_double_to_uint64(o->latency_percentile.u.f));
392         top->compress_percentage = cpu_to_le32(o->compress_percentage);
393         top->compress_chunk = cpu_to_le32(o->compress_chunk);
394
395         for (i = 0; i < DDIR_RWDIR_CNT; i++) {
396                 top->bs[i] = cpu_to_le32(o->bs[i]);
397                 top->ba[i] = cpu_to_le32(o->ba[i]);
398                 top->min_bs[i] = cpu_to_le32(o->min_bs[i]);
399                 top->max_bs[i] = cpu_to_le32(o->max_bs[i]);
400                 top->bssplit_nr[i] = cpu_to_le32(o->bssplit_nr[i]);
401
402                 if (o->bssplit_nr[i]) {
403                         unsigned int bssplit_nr = o->bssplit_nr[i];
404
405                         if (bssplit_nr > BSSPLIT_MAX) {
406                                 log_err("fio: BSSPLIT_MAX is too small\n");
407                                 bssplit_nr = BSSPLIT_MAX;
408                         }
409                         for (j = 0; j < bssplit_nr; j++) {
410                                 top->bssplit[i][j].bs = cpu_to_le32(o->bssplit[i][j].bs);
411                                 top->bssplit[i][j].perc = cpu_to_le32(o->bssplit[i][j].perc);
412                         }
413                 }
414
415                 top->rwmix[i] = cpu_to_le32(o->rwmix[i]);
416                 top->rate[i] = cpu_to_le32(o->rate[i]);
417                 top->ratemin[i] = cpu_to_le32(o->ratemin[i]);
418                 top->rate_iops[i] = cpu_to_le32(o->rate_iops[i]);
419                 top->rate_iops_min[i] = cpu_to_le32(o->rate_iops_min[i]);
420
421                 top->perc_rand[i] = cpu_to_le32(o->perc_rand[i]);
422         }
423
424         memcpy(top->verify_pattern, o->verify_pattern, MAX_PATTERN_SIZE);
425         memcpy(top->buffer_pattern, o->buffer_pattern, MAX_PATTERN_SIZE);
426
427         top->size = __cpu_to_le64(o->size);
428         top->verify_backlog = __cpu_to_le64(o->verify_backlog);
429         top->start_delay = __cpu_to_le64(o->start_delay);
430         top->start_delay_high = __cpu_to_le64(o->start_delay_high);
431         top->timeout = __cpu_to_le64(o->timeout);
432         top->ramp_time = __cpu_to_le64(o->ramp_time);
433         top->zone_range = __cpu_to_le64(o->zone_range);
434         top->zone_size = __cpu_to_le64(o->zone_size);
435         top->zone_skip = __cpu_to_le64(o->zone_skip);
436         top->lockmem = __cpu_to_le64(o->lockmem);
437         top->ddir_seq_add = __cpu_to_le64(o->ddir_seq_add);
438         top->file_size_low = __cpu_to_le64(o->file_size_low);
439         top->file_size_high = __cpu_to_le64(o->file_size_high);
440         top->start_offset = __cpu_to_le64(o->start_offset);
441         top->trim_backlog = __cpu_to_le64(o->trim_backlog);
442         top->offset_increment = __cpu_to_le64(o->offset_increment);
443         top->number_ios = __cpu_to_le64(o->number_ios);
444
445         for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++)
446                 top->percentile_list[i].u.i = __cpu_to_le64(fio_double_to_uint64(o->percentile_list[i].u.f));
447 #if 0
448         uint8_t cpumask[FIO_TOP_STR_MAX];
449         uint8_t verify_cpumask[FIO_TOP_STR_MAX];
450 #endif
451
452 }
453
454 /*
455  * Basic conversion test. We'd really need to fill in more of the options
456  * to have a thorough test. Even better, we should auto-generate the
457  * converter functions...
458  */
459 int fio_test_cconv(struct thread_options *__o)
460 {
461         struct thread_options o;
462         struct thread_options_pack top1, top2;
463
464         memset(&top1, 0, sizeof(top1));
465         memset(&top2, 0, sizeof(top2));
466
467         convert_thread_options_to_net(&top1, __o);
468         memset(&o, 0, sizeof(o));
469         convert_thread_options_to_cpu(&o, &top1);
470         convert_thread_options_to_net(&top2, &o);
471
472         free_thread_options_to_cpu(&o);
473
474         return memcmp(&top1, &top2, sizeof(top1));
475 }